/node-root-server

Node.js web server with a in-memory database built-in without any external libraries

Primary LanguageJavaScript

Node Root Server

PRs welcome! License

Github - João Bispo Linkedin - João Bispo Email - João Bispo

Project   |    Techs   |    How to contribute


💻 Project

This project is a user CRUD API with an in-memory database built in Node.js without any external libraries.

🚀 Techs

The project is based on the following technologies:

🔖 Documentation

Setup

Install Node.js 18 and run the following command:

npm run dev

Routes

GET /users - list users

curl --request GET --url http://localhost:3333/users
Response code 200 and click here to see the response body
[
	{
    "id": "8bc91d7d-1733-4fc8-a280-f3723d5f9a03",
		"name": "John Doe",
		"email": "john.doe@gmail.com"
	},
	{
    "id": "1bc91d7d-1733-4fc8-a280-f3723d5f9a06",
		"name": "John Doe 2",
		"email": "john.doe2@gmail.com"
	}
]

POST /users - create an user

curl --request POST --url http://localhost:3333/users --header 'Content-Type: application/json' --data '{"name": "John Doe", "email": "john.doe@gmail.com"}'
Response code 201 and click here to see the request body
{
	"name": "John Doe",
	"email": "jjjj"
}

If you want to search for an specific user, you can use the query param search:

curl --request GET --url 'http://localhost:3333/users?search=John Doe'

There is no response body for this request.

PUT /users/:id - update an user

curl --request PUT --url http://localhost:3333/users/8bc91d7d-1733-4fc8-a280-f3723d5f9a03 --header 'Content-Type: application/json' --data '{"name": "John Doe 2", "email": "john2.doe@gmail.com"}'
Response code 204 and click here to see the request body
{
	"email": "updatedmail",
	"name": "updated name"
}

There is no response body for this request.

DELETE /users/:id - delete an user

curl --request DELETE --url http://localhost:3333/users/8bc91d7d-1733-4fc8-a280-f3723d5f9a03

Response code 204, there is no request/response body for this request.

♻️ How to contribute

  • Fork this repository;
  • Create a new branch with your feature: git checkout -b feature/my-feature;
  • Commit your changes: git commit -m 'feat: awesome feature';
  • Push to your branch: git push origin feature/my-feature.

Once your pull request has been merged, you can delete your branch.


Made with 💙 & ☕ by João Bispo😎