Skip to content

fq962/reign_test

Repository files navigation

Some Facilities

NestJS: 8.2.6 (Currently used)

NodeJS: v16.17.0 LTS (Currently used)

NPM: 8.15.0 (Currently used)

NVM: 1.1.9 (Currently used)

Install MongoDB

To install MongoDB we need to execute a series of steps

First step

We need to install MongoDB on our PC, we can do this in the following link:

Second step

We are going to create in our local disk C: a folder called data and inside it a folder called db, it would look like this: C:\data\db

Third step

We have to add the file bin to the path of our environment variables, normally this is located in C:\Program Files\MongoDB\Server\6.0\bin

Fourth step

Finally we start our MongoDB service, in our terminal we execute the following command

$  mongod

NOTE

We can use Compass to see our DB when it is created or some other IDE that can connect to a Mongo DB like Navicat or another

RAISE the API

First step

We clone the project, and get our node_modules

$  npm install

Second step

We run the API with the NestJS command

$  nest start

Or we can execute the following command to see the changes in the API automatically

$  nest start:dev

NOTE

The API has a CRON (Task scheduling) and when the application is started it runs every hour, what it does is get the news from the provided URL and insert the information in the DB.

We can modify the time so that it runs every 10 seconds or every 10 minutes and thus be able to see the functionality and have records in the DB.

In our node-new.service we can change the CRON time from EVERY_HOUR to EVERY_10_MINUTES or EVERY_10_SECONDS or even some specific time.

Endpoints and Routes

Swagger

I have generated a swagger to make it easier to request and consume the API.
This can be found in the following link:

Postman

I have also generated a collection in Postman which you can import and use in your client. The routes and request are ready to be used

How to use routes?

In the endpoint that obtains the information from the database, it has filters (node-news/hits/filters) such as: Pagination: here it shows the news 5 by 5 and the default page is 1.
Filter by Author: for this filter the author field is used where it shows us the author's news that we place in the request.
Filter by title: in this filter we use the storytitle field since the title field returns null in all news.
Filter by tags: In this filter we use the tags field to filter the API response.

IMPORTANT!

Please use exact words to use the filters, for example:
I have one or several elements with the title "Node News in this year", if I want to use the title filter, I have to search for any word that is equal to any of the title but the same as it is written in the registry

Not this wayFilter title: node news or ❌ Filter title: news this Year

Correct wayFilter title: Node News or ✅ Filter title: News this year

LINTER

For the configuration of the Linter I use the TypeScript and Prettier rules, you can see it in the file .eslintrc.js.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published