Create environmental variables or define them in a .env file in the project root.
| VARIABLE | DEFAULT | DESCRIPTION |
|---|---|---|
| PORT | 3000 | The port on wich the server will run |
| MONGODB_URL | mongodb://localhost:27017 | The URL to the MongoDB database |
| JWT_SECRET | "a-really-(in)secure-secret-key" | The secret key for JWT |
Note: To generate a jwt secret key, You can use the node's in-built package called crypto to create random strings:
node
require("crypto").randomBytes(35).toString("hex")
To run the server locally, follow these steps:
- Clone the repository.
- Install dependencies with
npm install. - Build with
npm run build. - Start the server with
npm startornpm run devfor development mode.
Explore the available endpoints by running the server in dev mode (npm run dev) and visiting the localhost:3000/api-docs route.
This documentation is auto-generated through comments in the code.
This server implements Bearer token authentication. To access protected endpoints, follow these steps:
-
Obtain a valid access token through the authentication flow (user login);
-
Include the obtained access token in the request by adding a new header:
- Key:
Authorization - Value:
Bearer <your-access-token>
Replace
<your-access-token>with the actual access token obtained during the authentication process. - Key:
Contributions are welcome! If you find any issues or have suggestions, please open an issue or submit a pull request.
This project is licensed under the Apache License.