This bot is a part of a back-end challenge. His main function is catch information from Auto Esporte (https://revistaautoesporte.globo.com/rss/ultimas/feed.xml) that is a Brazilian TV program and a Brazilian magazine dedicated to the automotive sector and published for Globo. It works as a crawler and catch information of the website above and return in Json format exactly like was requested in the challenge
- [✓] Easy to use
- [✓] Catches each item and their respective title, link, p, div//ul and div//img
- [✓] Formats the response to Json
- [✓] Test coverage (using JEST)
- [✓] Organizable and readable code (using ESlint)
- [✓] "Dockerized"
- [✓] Implemented as a Webservice for test environments
- Download or Clone the project and extract it
- Download Node.js and install it.
- Run
npm installinnode-crawlerfolder - Start the bot via command line
node ./src/app.js - The project now is running on
3000port. In the next topic you can see how to login and get a response from the API
This project has a database simulated in a js file /src/models/dbSimulator.js, because the intention is to do a login validation for a test enviroment and it will just works if there is only single entries into dbSimulator.js
- Download Postman and install it
- With the API running just do a
POSTrequest with the URLhttp://localhost:3000/api/v1/login - Remember to pass username:
rootand password:123into the body of this request with the optionx-www-for-urlencodedselected - Copy the request response
- Open a
GETrequest with the URLhttp://localhost:3000/api/v1/infoand choose the tab "Authorization" with the typeBearer Token - Then paste the request response previously copied in step 4 into "Token" input and send the request
Demo:
Dockerfile:
FROM node:8
WORKDIR /docker/src/app/
COPY package.json /docker/src/app/
RUN npm install
COPY . /docker/src/app/
CMD node ./src/app.js
EXPOSE 3002
- First Install docker and let it running
- Into the project folder
node-crawlerrun the commanddocker build -t node-crawler .to create the docker image - Then run
docker run -p 3002:3000 node-crawler - run
docker psif you want to see the containers started - Now with the API running into the container just do a
POSTrequest with the URLhttp://localhost:3002/api/v1/login - Remember that as configured in Dockerfile the port now is
3002 - Don't forget to pass username:
rootand password:123into the body of this request with the optionx-www-for-urlencodedselected - Copy the request response
- Open a
GETrequest with the URLhttp://localhost:3000/api/v1/infoand choose the tab "Authorization" with the typeBearer Token - Then paste the request response previously copied in step 7 into "Token" input and send the request
Demo:
- As simple as possible, just run the command
npm testinto the project folder
ESLint is a code linting that is frequently used to find problematic patterns or code that doesn't adhere to certain style guidelines.
Demo:
- Run the command
$ ./node_modules/.bin/eslint yourfile.js - Change
yourfile.jsfor the file wanted - exemple:
$ ./node_modules/.bin/eslint ./src/app.js
- if you enjoyed about this project add a star ⭐
- Don't forget to follow me on Instagram @riantba ❤️
- And follow me also here on github :)
GNU GENERAL PUBLIC LICENSE
Copyright (c) 2018 Rian Tavares


