This is a NodeJS API that supports username and password authentication with JWTs and has APIs that return Employee details
POST to /admin
to create a new admin.
The body must have:
username
: The usernamepassword
: The passwordextra
: Some extra information you want to save from the user (It's a string)
It returns the following:
{
"id_token": {jwt},
"access_token": {jwt}
}
You can do a POST to /sessions/create
to log a user in.
The body must have:
username
: The usernamepassword
: The password
It returns the following:
{
"id_token": {jwt},
"access_token": {jwt}
}
The id_token
and access_token
are signed with the secret located at the config.json
file. The id_token
will contain the username
and the extra
information sent, while the access_token
will contain the audience
, jti
, issuer
and scope
.
It returns a status of API and no authentication required.
It returns a Random employee and no authentication required.
It returns a employees and authentication required.
It returns employee by ID and authentication required.
Add Employee details
The body must have:
id
: int, requiredname
: string, optionalsalary
: int , requiredage
: int , requiredprofile_image
: string, optional
Update Employee details
The body must have:
id
: int, requiredname
: string, optionalsalary
: int , requiredage
: int , requiredprofile_image
: string, optional
Delete Employee details
Just clone the repository, run npm install
and then npm run start
. That's it :).
If you want to run it on another port, just run PORT=3001 node server.js
to run it on port 3001 for example