# बेसिक रूटिंग — Fastify

Source: https://www.geekswithgeeks.com/hi/fastify/ff-basic-routing

> HTTP verbs और resource patterns के लिए routes परिभाषित करें।

## HTTP methods

Fastify `fastify.get()`, `fastify.post()`, `fastify.put()`, `fastify.delete()`, `fastify.patch()`, और `fastify.head()` को expose करता है हर HTTP verb के लिए।

## RESTful resource routes

विशिष्ट CRUD patterns मानक HTTP verbs से map होते हैं।

```javascript
// List all
fastify.get('/items', async () => []);

// Create one
fastify.post('/items', async (req, reply) => {
  return { id: 1, created: true };
});

// Read one
fastify.get('/items/:id', async (req) => {
  return { id: req.params.id };
});

// Update one
fastify.put('/items/:id', async (req) => {
  return { id: req.params.id, updated: true };
});

// Delete one
fastify.delete('/items/:id', async (req, reply) => {
  return reply.status(204).send();
});
```

**Quiz:** किसी resource को आंशिक रूप से अपडेट करने के लिए कौन-सी HTTP method का उपयोग किया जाता है?

- [ ] PUT
- [x] PATCH
- [ ] POST

*Answer:* PATCH. PATCH आंशिक updates के लिए है; PUT पूरे resource को replace करता है।
