Obs.: That's a technical challenge applied by @alcmoraes to Neoway
Obs².: Refer to go-data-integration-challenge for the Go version of this challenge
- Docker
- Docker Compose
- Ports
3005
,8081
and8082
It will build a mongo and restify docker containers, where the restify container automatically starts
two proccess in background
- The API client on port
3005
- A
node-schedule
cronjob that runs each 15 seconds and takes the last file fromcsv/uploaded
folder to import into the database.
CSV's uploaded via API are not imported right away. They are stored in csv/uploaded
folder so the node-schedule
crobjob can import it in another thread.
Use make
to show the following commands in your terminal
Command | Description |
---|---|
help | Gets this table in your terminal |
setup | Installs the docker containers and import initial data |
start | Starts the project and open API on port 3005 |
stop | Stops the project |
logs | Shows the logs from the project |
check | Run unit tests |
nyc | Serve the Tests Coverage UI on port 8081 |
docs | Serve the Swagger Explorer UI on port 8082 |
lcov | Output coverage lcov data |
remove | Stops and removes the containers from this project |
Ensure the project is running (make start
).
Execute make docs
, this will start server on port 8082
.
For running the api docs outside localhost, remember changing the host
config parameter on config/{environment}.json
.
First ensure project is running. If not go and start it with make start
.
Execute make check
.
To see the coverage UI, go for make nyc
. It will start a server on port 8081
.
The project have an importer that works via command line:
docker exec -it yawoen_api bash
Now you can execute the following command to be given help
node /var/www/tasks/import_from_file.js help
Obs.: Please be aware that by default this script WILL NOT MERGE the content from the CSV file.
For merging source into database instead of creating new entries, remember to use merge=true
flag.