You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Then, rename or copy the .env.sample file to .env:
mv .env.sample .env
Open your favourite editor and edit the .env file. You can change the port, the debug mode, the environment etc. as you want, but the default values should work, except one entry. You have to modify the MONGODB_URI, based on your own Mongo DB settings:
Now close the editor, go back to the frw folder and install the packages:
npm install
Build the project:
npm run build
Now you can run it with node:
node dist/index.js
Or, if you want, can be launch in developer mode too, using nodemon package. Just simply type in:
npm start
Both cases, you should get the following message: Test task is listening on port 3000. (If you set the APP_NAME and/or the APP_PORT, you'll see your entries instead of Test task and 3000.)
Now the API is ready to handle the requests.
Endpoints
Producers
Get a single producer by ID
GET/producer/{id}
Parameters
name
type
data type
description
id
required
string
the producer's ObjectId
Responses
http code
content-type
response
200
application/json
the producer object
404
application/json
producer not found
Example cURL
curl -X GET -H "Content-Type: application/json" http://localhost:3000/producer/655a3f745bb339041f09a4b8
Keep in mind, when you call this method, it responses immediately a started: true message with status code 202 Accepted.
In the background, it forks a new instance, and starts to process the given CSV url. It takes 5 to 10 seconds to see the
output on the console.
Query string
name
type
data type
description
url
required
string
A link to a valid remote CSV file
POST data (JSON)
none
Responses
http code
content-type
response
202
application/json
started: true
Example cURL
curl -X POST -H "Content-Type: application/json" http://localhost:3000/product/csv/?url=https://foobar.baz/path/to/a/valid.csv