Built a secure NodeJs REST API uses best API practice. Implemented JWT "AccessToken, refreshToken" and "Roles and permissions". The data are stored in JSON file.
This REST API allows you to create, read, update and delete employees and users data. The employees file is located in the ./model/employees.json
file and the users file is located in the ./model/users.json
file.
The employees json won't be updated. That is I designed it. However, the users json file will be updated. You can add, edit and delete users.
- Clone the project
- Run
npm install
- Run
npm run dev
- Open your browser and go to
http://localhost:3500/
You can import the postman collection from the ./postmanCollection
folder.
-
login with one of the user below
{ user: "UserOnly" pwd: "Aa$12345" } { user: "UserEditor" pwd: "Aa$12345" } { user: "UserEditorAdmin" pwd: "Aa$12345" }
-
Other endpoints
.../register .../refresh .../logout
1. get all employees
1. get employee by id
1. create employee
1. update employee
1. delete employee
-
UserOnly: can only view the data and can not edit it.
-
UserEditor: can view and edit the data.
-
UserEditorAdmin: can view, edit and delete the data.
-
JWT implementation
- access token
- refresh token
-
Authentication
-
Authorization
-
Roles and permissions
-
Database
- JSON files