Node.js + Express.js RESTful API Development Roadmap & Guide
✅ 1. Tushuncha: RESTful API nima?REST (Representational State Transfer) bu arxitektura uslubi bo‘lib, HTTP orqali ma’lumotlarga kirishish uchun ishlatiladi. RESTful API - bu shu printsiplarga asoslangan API.
Asosiy HTTP metodlari:
GET — ma'lumot olish.
POST — yangi ma'lumot yaratish.
PUT/PATCH — mavjud ma'lumotni yangilash.
DELETE — ma'lumotni o‘chirish.
✅ 2. Kerakli vositalarNode.js
Express.js
VS Code / IDE
Postman (API test qilish uchun)
✅ 3. Loyihani boshlashmkdir books-api
module.exports = router;✅ 5. API test qilishPostman orqali quyidagilarni sinab ko‘ring:
GET /api/books - barcha kitoblar.
GET /api/books/:id - bitta kitob.
POST /api/books - yangi kitob.
DELETE /api/books/:id - kitobni o‘chirish.
✅ 6. Qo‘shimcha takliflar:Joi bilan validatsiya: npm install joi
nodemon bilan hot reload: npm install --save-dev nodemon
.env bilan konfiguratsiya
✅ 7. Deployment (keyinchalik):Railway, Render, Cyclic, yoki Vercel (serverless)
.env fayl va process.env.PORT
✅ 8. XulosaNode.js va Express.js orqali RESTful API yaratish oddiy, lekin muhim tushunchalarni o'z ichiga oladi. Har bir HTTP metodga mos marshrut, kontroller, va model orqali ishlash sizga real loyihalarda mustahkam asos yaratadi.
Tayyorlovchi: Fotima Nishonova
GitHub: github.com/fotimaDev
LinkedIn: linkedin.com/in/fotima-nishonova
✅ 1. Tushuncha: RESTful API nima?REST (Representational State Transfer) bu arxitektura uslubi bo‘lib, HTTP orqali ma’lumotlarga kirishish uchun ishlatiladi. RESTful API - bu shu printsiplarga asoslangan API.
Asosiy HTTP metodlari:
GET — ma'lumot olish.
POST — yangi ma'lumot yaratish.
PUT/PATCH — mavjud ma'lumotni yangilash.
DELETE — ma'lumotni o‘chirish.
✅ 2. Kerakli vositalarNode.js
Express.js
VS Code / IDE
Postman (API test qilish uchun)
✅ 3. Loyihani boshlashmkdir books-api
cd books-api
npm init -y
npm install expressLoyiha strukturasini yarating:
books-api/
|-- index.js
|-- routes/
| |-- books.js
|-- controllers/
| |-- bookController.js
|-- models/
| |-- book.js✅ 4. Kod yozish4.1 index.js (asosiy fayl):const express = require('express');
const app = express();
const bookRoutes = require('./routes/books');
app.use(express.json());
app.use('/api/books', bookRoutes);
app.listen(3000, () => {
console.log('Server running on port 3000');
});4.2 models/book.jslet books = [
{ id: 1, title: 'Clean Code', author: 'Robert C. Martin' },
];
module.exports = books;4.3 controllers/bookController.jsconst books = require('../models/book');
exports.getBooks = (req, res) => {
res.json(books);
};
exports.getBookById = (req, res) => {
const book = books.find(b => b.id === parseInt(req.params.id));
if (!book) return res.status(404).send('Book not found');
res.json(book);
};
exports.createBook = (req, res) => {
const newBook = {
id: books.length + 1,
title: req.body.title,
author: req.body.author,
};
books.push(newBook);
res.status(201).json(newBook);
};
exports.deleteBook = (req, res) => {
const index = books.findIndex(b => b.id === parseInt(req.params.id));
if (index === -1) return res.status(404).send('Book not found');
const deleted = books.splice(index, 1);
res.json(deleted);
};4.4 routes/books.jsconst express = require('express');
const router = express.Router();
const bookController = require('../controllers/bookController');
router.get('/', bookController.getBooks);
router.get('/:id', bookController.getBookById);
router.post('/', bookController.createBook);
router.delete('/:id', bookController.deleteBook);
module.exports = router;✅ 5. API test qilishPostman orqali quyidagilarni sinab ko‘ring:
GET /api/books - barcha kitoblar.
GET /api/books/:id - bitta kitob.
POST /api/books - yangi kitob.
DELETE /api/books/:id - kitobni o‘chirish.
✅ 6. Qo‘shimcha takliflar:Joi bilan validatsiya: npm install joi
nodemon bilan hot reload: npm install --save-dev nodemon
.env bilan konfiguratsiya
✅ 7. Deployment (keyinchalik):Railway, Render, Cyclic, yoki Vercel (serverless)
.env fayl va process.env.PORT
✅ 8. XulosaNode.js va Express.js orqali RESTful API yaratish oddiy, lekin muhim tushunchalarni o'z ichiga oladi. Har bir HTTP metodga mos marshrut, kontroller, va model orqali ishlash sizga real loyihalarda mustahkam asos yaratadi.
Tayyorlovchi: Fotima Nishonova
GitHub: github.com/fotimaDev
LinkedIn: linkedin.com/in/fotima-nishonova
GitHub
fotimaDev - Overview
Software Engineer / Project Manager
Teesside University of UK at MDIST - fotimaDev
Teesside University of UK at MDIST - fotimaDev
Kompyuter va dasturiy injiniring yo‘nalishi uchun kirish imtihoni (to‘lov-kontrakt asosida) 21-iyun (Shanba)
# 💫 About Me:
I'm currently studying
# 💻 Tech Stack:
                   
# 📊 GitHub Stats:
<br/>
<br/>

## 🏆 GitHub Trophies

### ✍️ Random Dev Quote

### 🔝 Top Contributed Repo

---
[](https://visitcount.itsvg.in)
## 💰 You can help me by Donating
[](https://buymeacoffee.com/Buy me a Coffee)
<!-- Proudly created with GPRM ( https://gprm.itsvg.in ) -->
I'm currently studying
# 💻 Tech Stack:
                   
# 📊 GitHub Stats:
<br/>
<br/>

## 🏆 GitHub Trophies

### ✍️ Random Dev Quote

### 🔝 Top Contributed Repo

---
[](https://visitcount.itsvg.in)
## 💰 You can help me by Donating
[](https://buymeacoffee.com/Buy me a Coffee)
<!-- Proudly created with GPRM ( https://gprm.itsvg.in ) -->
Agar siz C tilini bilsangiz, Java, Python, C++, C# va boshqalar kabi mashhur dasturlash tillarini o'rganishda muammo bo'lmaydi, chunki sintaksis o'xshash
Git cheat sheet:
git clone — At the beginning of work.
git commit — After making changes. Remember to add a clear name for the commit.
git push origin — To save changes to a remote server.
git status — The current state of the repository.
Do not push object files or executable files to the repository! Never!
Always work in branches. Use the develop branch to do all your work.
git clone — At the beginning of work.
git commit — After making changes. Remember to add a clear name for the commit.
git push origin — To save changes to a remote server.
git status — The current state of the repository.
Do not push object files or executable files to the repository! Never!
Always work in branches. Use the develop branch to do all your work.
C Variables
Variables are containers for storing data values, like numbers and characters.
In C, there are different types of variables (defined with different keywords), for example:
int - stores integers (whole numbers), without decimals, such as 123 or -123
float - stores floating point numbers, with decimals, such as 19.99 or -19.99
char - stores single characters, such as 'a' or 'B'. Characters are surrounded by single quotes
Variables are containers for storing data values, like numbers and characters.
In C, there are different types of variables (defined with different keywords), for example:
int - stores integers (whole numbers), without decimals, such as 123 or -123
float - stores floating point numbers, with decimals, such as 19.99 or -19.99
char - stores single characters, such as 'a' or 'B'. Characters are surrounded by single quotes
int main() {
int age = 12;
int born = 23;
int birth = age + born;
printf( "%d", birth);
return 0;
}int main() {
int birthYear = 2007;
int currentYear = 2025;
int age = currentYear - birthYear;
printf("Sizning yoshingiz: %d\n", age);
return 0;
}int main() {
int firstNumber = 33;
printf("firstNumber = %d", firstNumber);
return 0;
}int myNum = 15; // Integer (whole numbe
r)
float myFloatNum = 5.99; // Floating point number
char myLetter = 'D'; // Character
// Print variables
printf("%d\n", myNum);
printf("%f\n", myFloatNum);
printf("%c\n", myLetter);int main() {
int number1 = 33;
printf("%d\n", number1);
printf("%d", number1);
return 0;
}
coding with ☕️
int main() { int number1 = 33; printf("%d\n", number1); printf("%d", number1); return 0; }
difference between this
printf("%d\n", number1);
and this printf("%d", number1);