coding with ☕️
2 subscribers
262 photos
14 videos
11 files
165 links
Anwendungsentwicklung
Download Telegram
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
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
Kompyuter va dasturiy injiniring yo‘nalishi uchun kirish imtihoni (to‘lov-kontrakt asosida) 21-iyun (Shanba)
# 💫 About Me:
I'm currently studying


# 💻 Tech Stack:
![C](https://img.shields.io/badge/c-%2300599C.svg?style=for-the-badge&logo=c&logoColor=white) ![HTML5](https://img.shields.io/badge/html5-%23E34F26.svg?style=for-the-badge&logo=html5&logoColor=white) ![JavaScript](https://img.shields.io/badge/javascript-%23323330.svg?style=for-the-badge&logo=javascript&logoColor=%23F7DF1E) ![CSS3](https://img.shields.io/badge/css3-%231572B6.svg?style=for-the-badge&logo=css3&logoColor=white) ![Codeberg](https://img.shields.io/badge/Codeberg-2185D0?style=for-the-badge&logo=Codeberg&logoColor=white) ![Bootstrap](https://img.shields.io/badge/bootstrap-%238511FA.svg?style=for-the-badge&logo=bootstrap&logoColor=white) ![Fastify](https://img.shields.io/badge/fastify-%23000000.svg?style=for-the-badge&logo=fastify&logoColor=white) ![Express.js](https://img.shields.io/badge/express.js-%23404d59.svg?style=for-the-badge&logo=express&logoColor=%2361DAFB) ![JWT](https://img.shields.io/badge/JWT-black?style=for-the-badge&logo=JSON%20web%20tokens) ![NodeJS](https://img.shields.io/badge/node.js-6DA55F?style=for-the-badge&logo=node.js&logoColor=white) ![Nodemon](https://img.shields.io/badge/NODEMON-%23323330.svg?style=for-the-badge&logo=nodemon&logoColor=%BBDEAD) ![Node-RED](https://img.shields.io/badge/Node--RED-%238F0000.svg?style=for-the-badge&logo=node-red&logoColor=white) ![NPM](https://img.shields.io/badge/NPM-%23CB3837.svg?style=for-the-badge&logo=npm&logoColor=white) ![SASS](https://img.shields.io/badge/SASS-hotpink.svg?style=for-the-badge&logo=SASS&logoColor=white) ![TailwindCSS](https://img.shields.io/badge/tailwindcss-%2338B2AC.svg?style=for-the-badge&logo=tailwind-css&logoColor=white) ![Postgres](https://img.shields.io/badge/postgres-%23316192.svg?style=for-the-badge&logo=postgresql&logoColor=white) ![MongoDB](https://img.shields.io/badge/MongoDB-%234ea94b.svg?style=for-the-badge&logo=mongodb&logoColor=white) ![GitHub](https://img.shields.io/badge/github-%23121011.svg?style=for-the-badge&logo=github&logoColor=white) ![Git](https://img.shields.io/badge/git-%23F05033.svg?style=for-the-badge&logo=git&logoColor=white) ![Postman](https://img.shields.io/badge/Postman-FF6C37?style=for-the-badge&logo=postman&logoColor=white)
# 📊 GitHub Stats:
![](https://github-readme-stats.vercel.app/api?username=fotimaDev&theme=dark&hide_border=false&include_all_commits=false&count_private=false)<br/>
![](https://nirzak-streak-stats.vercel.app/?user=fotimaDev&theme=dark&hide_border=false)<br/>
![](https://github-readme-stats.vercel.app/api/top-langs/?username=fotimaDev&theme=dark&hide_border=false&include_all_commits=false&count_private=false&layout=compact)

## 🏆 GitHub Trophies
![](https://github-profile-trophy.vercel.app/?username=fotimaDev&theme=radical&no-frame=false&no-bg=true&margin-w=4)

### ✍️ Random Dev Quote
![](https://quotes-github-readme.vercel.app/api?type=horizontal&theme=radical)

### 🔝 Top Contributed Repo
![](https://github-contributor-stats.vercel.app/api?username=fotimaDev&limit=5&theme=dark&combine_all_yearly_contributions=true)

---
[![](https://visitcount.itsvg.in/api?id=fotimaDev&icon=0&color=0)](https://visitcount.itsvg.in)

## 💰 You can help me by Donating
[![BuyMeACoffee](https://img.shields.io/badge/Buy%20Me%20a%20Coffee-ffdd00?style=for-the-badge&logo=buy-me-a-coffee&logoColor=black)](https://buymeacoffee.com/Buy me a Coffee)


<!-- Proudly created with GPRM ( https://gprm.itsvg.in ) -->
Back end bn Front end ma'lumotlar almashuvida doim JSON formatda yuboriladi
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.
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
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;
}