Skip to content
This repository was archived by the owner on Dec 13, 2019. It is now read-only.
Raphael edited this page May 28, 2019 · 4 revisions

Welcome to the TasteHealthy wiki!

API

Response

Here is an example of response returned by the the server side.

{
  "success": true,
  "limit": 20,
  "page": 1,
  "offset": 0,
  "results": 1,
  "items": []
}

In some cases, the API returns an error.

{
  "success": false,
  "errorMessage": "\"query\" length must be at least 3 characters long"
}

Querying

Searching products

curl -X GET http://localhost:3000/products?query=nut

Pagination

curl -X GET http://localhost:3000/products?query=nut&page=2

Populate database

Processing CSV to SQL

# Copy the first 10000 lines (example)
head -10000 ~/Téléchargements/fr.openfoodfacts.org.products.csv > ./scripts/test2.csv

# Fix delimiter char if needed (e.g replace tab with comma)
# sed -i -- 's/ /,/g' ./scripts/test2.csv

# NOTE: make sure the csv path is correctly written in the script.

# Run script
node scripts/populate.js

Contribute

Of course you can contribute to this repository by forking it and making a pull request.

Note that we use a commit linter, make sure to learn how to use it, it's dead simple!

Scopes :

  • build
  • chore
  • ci
  • docs
  • feat
  • fix
  • perf
  • refactor
  • revert
  • style
  • test

Example :

# type(scope?): subject  # scope is optional
$ git commit -m "refactor(server): add products post route"
Clone this wiki locally