This project is about a CRUD API that deals with accounts data structure. It uses a .json file for storing data.
- Language: Javascript(ES6+)
- Stack: Nodejs + Express
- Documentation: Swagger
- Log lib: Winston
- 1 - Download or clone this project and rename .env.example to .env, setting variables to:
DATA_PATH="data"
DATA_LOCATION="data/accounts.json"
PORT=8080
-
2 - Open a terminal in project´s root folder and run the following commands:
-
$ npm install
-
$ npm install -g nodemon
(if nodemon isn´t installed) -
$ nodemon
Now API can be consumed in localhost:8080 and Swagger docs can be viewed in localhost:8080/swagger
You can test this API by browsing the Swagger documentation provided here. If you prefer, you can also create requests to API endpoints by using applications like Insomnia or Postman. Here is the list of http verbs followed by the available endpoints:
GET /account
- Fetches all accountsGET /account/{id}
- Fetches an account by IdPOST /account
- Creates a new accountPUT /account
- Updates an account entirelyDELETE /account/{id}
- Deletes an accountPATCH /account/withdraw/{id}
- Withdraws from accountsPATCH /account/deposit/{id}
- Deposits on accountsPATCH /account/transfer?fromAccountWithId={fromId}&toAccountWithId={toId}
- Transfers between accounts
- Routing for CRUD operations with REST verbs
- Data persistence in a .json file
- Daily logs with configured levels
- Fully documented with Swagger
- Errors handling with API´s custom messages