This repository contains the backend service built with Nest.js that connects to a MongoDB database. The service is designed to retrieve user data, specifically logs of the URLs they have visited on the frontend web app. The API routes are guarded by authorization to ensure secure access to the data.
- Secure user data retrieval.
- Integration with MongoDB for storing and retrieving URL visit logs.
- Authorization guards on API routes.
- Built with Nest.js, a progressive Node.js framework.
Before you begin, ensure you have met the following requirements:
- Node.js and npm installed.
- MongoDB database set up and running.
-
Clone this repository:
git clone https://github.com/austinb847/top-news-backend.git cd top-news-backend
-
Install the dependencies:
npm install
-
Set up the environment variables:
cp .env.example .env
-
Start the server:
npm run start:dev
The API routes are guarded by authorization. To access the routes, you will need to provide a valid JWT token in the Authorization
header of the request. The token can be obtained by logging in to the frontend web app.
- Description: Get logs of URLs visited by a user.
- Authorization: Required.
- URL parameters:
userId
: The ID of the user whose logs are to be retrieved.
- Status code:
200 OK
- Body: An array of objects, each representing a log entry. Each object has the following properties:
url
: The URL visited by the user.timestamp
: The timestamp of the visit.
- Description: Add a log of a URL visited by a user.
- Authorization: Required.
- URL parameters:
userId
: The ID of the user whose logs are to be retrieved.
- Body: An object representing the log entry. It has the following properties:
url
: The URL visited by the user.
- Status code:
201 Created
- Body: An object representing the log entry. It has the following properties:
url
: The URL visited by the user.timestamp
: The timestamp of the visit.