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.