A small deadly simple server, including endpoints to: Signup, Login, Refresh Token, Chance Profile Password, Reset Password and User Roles.
Download or clone the repository.
Install dependencies:
npm install
Running the App:
npm start
(Optimal)To generate new API document:
npm run docs
POST: to http://localhost:3000/api/register
{
"username":"Jhonny Cash",
"email": "jhonny@example.com",
"password": "123456",
"type": "Admin"
}
To see more details available go to: http://localhost:3000/apidoc/#api-User-PostApiRegister
POST: to http://localhost:3000/api/signup
{
"email": "jhonny@example.com",
"password": "123456"
}
To see more details available go to: http://localhost:3000/apidoc/#api-User-PostApiSignup
All endpoints created by the Json-Server database file (db.json
) are protected by token authentication, this means that you must be logged in with a valid user and must use the following header:
{
"Authorization": "Bearer <token>"
}
You receive this token in the success of the login endpoint, according to the following object:
{
"auth": true,
"token": "eyJhbGciOiJIUzI1NiIsInR...",
"user": {
"email": "johnny@cash.com",
"username": "Johnny Cash",
"password": "123456",
"type": "Amin",
"id": 1
}
}
It is very easy to add new endpoints, you can create them in the Json-Server database file: db.json
, simply by adding new objects, you can read more about it here.
If you need to create prototypes quickly and unplugged for your front-end application, or you need to develop proof of concept about some Restful application, this project is for you. Since we have here common things in every application such as user authentication, login, signup, change password among other things.
MIT