This app is meant to be used as a starting point for creating backend APIs. The app is a simple express app with built in token authentication for users.
- Clone the repository.
- Run
npm install
. - If running in a dev environment, set up the mongo db.
- Create the following directory paths in your home folder:
~/mongodb/<api-name>/data/db
~/mongodb/<api-name>/logs
- Update the mongo conf file in
/models/mongod.conf
. Thepath
anddbpath
variables should point to paths you just created.
- Create the following directory paths in your home folder:
- In a new terminal window run
npm run mongo
to start the mongdb database.- In order to later stop the mongo database run
npm run mongo-stop
.
- In order to later stop the mongo database run
- In the same window run
npm run start
to start the api.
POST /auth/login
body
{
email,
password
}
Returns
{
token: (token)
}
POST /users
body:
{
email,
password
}
Returns
{
token: (token)
}
GET /users
body:
token (can also be in the header as 'x-access-token')
Returns
user object
PUT /users
body:
token (can also be in the header as 'x-access-token'),
The body should contain the updated user object
Returns
nothing
DELETE /users
body:
token (can also be in the header as 'x-access-token')
Returns
nothing