This project runs with NodeJS, therefore you should install it from the official page. For this project you may install the LTS Stable
After installation, validate using node --version
, it may show the installed version, and npm --version
, it may show the latest version.
-
Install MongoDB
-
At e-backend-logger root, create a .env file, then set MONGODB_URI environment variable. It should look something like this
-
For Windows, go to a terminal and execute the following command:
mkdir C:\data\db
. Then go to CMD and put the following command:cd "\Program Files\MongoDB\Server\<MONGO DB VERSION HERE>\bin"
thenmongod
. The database local server should execute successfully. -
For Linux, go to a terminal, change directory to root, then execute the following command:
mkdir data/db
. Then execute the commandmongod
and the local server should execute succesfully.
Check .env.example
file to fulfill the variables needed to run the application. Remember to pass them into a solely .env
file
Run npm install
to install all the necessary npm dependencies
After following the previous steps, open a terminal and run npm run start
. The terminal may show a log regarding the database was successfully connected. Then, if you're running locally and didn't set a port, do a request to localhost:3000
. After that, the terminal may show some logs of the request that has been performed and the server may return an HTML.
This application uses JWT for authentication for all its endpoints. Follow these steps to successfully authenticate and use the endpoints.
-
From a DB Manager, create a document in the
Applications
schema and get its id. -
Send a request to
POST /api/auth
with a body with the application id. It may look something like this:"applicationId":"(ID GOES HERE)
-
If you successfully followed the first step, you may receive a response from the server that looks like this:
"message": "Successfully authenticated", "token": "(AUTH TOKEN COMES HERE)"
-
Get the token from the response and set it to the headers of the request you need to perform like this:
authorization: (AUTH TOKEN HERE)