I am learning about APIs and CURD operations.This is the second time I am buildin an API. This is a simple API using nodejs and fastify framework. I have used a fake data created by ChatGPT to build this API.
I have used fasify-openapi-docs
plugin to generate docs autometically.
localhost:5000/docs/
- Fork the repository in your account in Github.
- Make project directory and go inside the directory.
- Clone the repository.
- Install dependencies.
- Start or run your API on the local machine.
- Access the API in your browser or tools like Postman. I have used Rest Client VS Code extension.
# Make a directory
mkdir items-api-fastify
# go inside the directory
cd items-api-fastify
# Clone the repo
git clone https://github.com/...(repo url)
# Install dependencies
npm install
# Start the API
npm start
# Access the API in your web browser
http://localhost:5000/items
# To get all the items
localhost:5000/items
# To get a single item
localhost:5000/items/:itemId
# To add a new item
localhost:5000/items
# To update a single item
localhost:5000/items/:itemId
# To delete a single item
localhost:5000/items/:itemId
Here are some of the major dependencies used in this project:
- Fastify: [^4.23.2]
- fastify-openapi-docs: [^2.2.1]
- nanoid: [^5.0.1]
- nodemon: [^3.0.1]
- pino-pretty: [^10.2.3]
Dipankar Paul ๐ | ๐ [email protected] ๐