Skip to content

Commit

Permalink
Release 0.5.0
Browse files Browse the repository at this point in the history
Includes API release 1.0
  • Loading branch information
Ugo committed Nov 4, 2018
1 parent 0e97679 commit 5ca249b
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 118 deletions.
58 changes: 27 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,52 @@
# Grocerybot
# Gastronomycon

[![Codacy Badge](https://api.codacy.com/project/badge/Grade/b1a78fa78eba4b649d7d45c7db63a35e)](https://app.codacy.com/app/ugobriasco/grocerybot-server?utm_source=github.com&utm_medium=referral&utm_content=ugobriasco/grocerybot-server&utm_campaign=Badge_Grade_Dashboard)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/9551ffcba0e0422fa1b1a09985ebe09f)](https://www.codacy.com/app/ugobriasco/grocerybot-server?utm_source=github.com&utm_medium=referral&utm_content=ugobriasco/gastronomycon-server&utm_campaign=Badge_Grade)
[![Build Status](https://travis-ci.org/ugobriasco/grocerybot-server.svg?branch=master)](https://travis-ci.org/ugobriasco/grocerybot-server)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

## Intro

This is the server-side application of Grocerybot - a microservice for multilingual grocery lists. It provides and handles a customizable list of grocery products, accessable via REST API. The default client application can be found [here](https://github.com/ugobriasco/grocerybot-cli).
This is the server-side application of Gastronomycon - a microservice for multilingual groceries. It provides and handles groceries, accessable via REST API. The default client application can be found [here](https://github.com/ugobriasco/grocerybot-cli).

Visit the [official page](http://46.101.201.71:3000), collaborate to the project on [GitHub](https://github.com/ugobriasco/grocerybot-server), or contact the author [Ugo Briasco](http://ugobriasco.me) on [Slack](https://matchyourtie.slack.com/messages/general/whats_new/).

## Release Notes

The v. 0.0.1 of Grocerybot includes

1. Full user management
..+ email service
..+ basic profile
2. Full item-list management
..+ it supports the following languages: DE, PL, IT
3. REST API
..+ API Documentation
..+ JWT autentification compliant with the [ietf standards](https://tools.ietf.org/html/rfc6750)
4. User Signup limitations option
Visit the [official page](http://46.101.201.71:3000), collaborate to the project on [GitHub](https://github.com/ugobriasco/gastronomycon-server), or contact the author [Ugo Briasco](http://ugobriasco.me) on [Slack](https://matchyourtie.slack.com/messages/general/whats_new/).

## Framework

This a RESTful API based on:

* [mongo](https://docs.mongodb.com/getting-started/shell/)
* [node](https://nodejs.org/en/)
* [express](http://expressjs.com/)

## Usage

Please refer to the [API documentation](http://gb.matchyourtie.com/documentation) for released versions, or check [here](https://github.com/ugobriasco/grocerybot-server/blob/master/server/api/api-doc.json).
Please refer to the [API documentation](https://github.com/ugobriasco/gastronomycon-server/wiki/API-v1.0-reference) for released versions, or check [here](https://github.com/ugobriasco/grocerybot-server/blob/master/server/api/v1.0/api-doc.json).

## Development server
## Development

Start the server side with `npm start` and it is accessable via port `3000`(it requires a target mongo database running). The API documentation is accessable under `http://localhost:3000/api/`
### Prerequisites

- node 8+
- npm 6+
- Nodemon 1.4+
- mongoDB 4+

### Setup

Install the dependancies with `npm install`.
Create the root user, by sending a `POST` request to `http://localhost:3000/api/signup` with the following body (x-www-form-urlencoded):
`{"email":"[email protected]","passowrd":"root","role": "Admin"}` (remove the entry point 'role' in the [`postSignUp`](https://github.com/ugobriasco/grocerybot-server/blob/master/server/auth/auth.controller.js) method, after the root user has been created)
- Install dependencies

```bash
git clone [email protected]:ugobriasco/gastronomycon-server.git && cd gastronomycon-server
npm i
mongod
npm start
```

Optional - SignupCode
In order to control the signup, it is possible to provide e signup code option, which -if enabled- requires a signup code by the signup. This option can be created by an admin user as following:
`POST http://localhost/api/settings`
`{"name": "signupCode", "value": "foo"}`
- Create the root user, by sending a `POST` request to `http://localhost:3000/api/v1.0/signup` with the following body:
`{"email":"ROOT_EMAIL","passowrd":"ROOT_PASSWORD","role": "Admin"}` (remove the entry point 'role' in the [`postSignUp`](https://github.com/ugobriasco/grocerybot-server/blob/master/server/auth/auth.controller.js) method, after the root user has been created)

- Optional - SignupCode
In order to control the signup, it is possible to provide e signup code option, which -if enabled- requires a signup code by the signup. This option can be created by an admin user as following:
`POST http://localhost/api/settings`
`{"name": "signupCode", "value": "foo"}`

### Test

Expand All @@ -70,4 +67,3 @@ In lieu of a formal style guide, take care to maintain the existing coding style
## License

[MIT](https://github.com/ugobriasco/grocerybot-server/blob/master/LICENSE.md)

15 changes: 7 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
{
"name": "grocerybot-server",
"version": "0.0.1",
"name": "gastronomycon-server",
"version": "0.5.0",
"license": "MIT",
"author": "Ugo Briasco",
"scripts": {
"start": "nodemon server",
"start": "node server",
"dev": "nodemon server",
"test": "mocha --opts ./mocha.opts || true",
"coverage": "clear && mocha --opts ./mocha.opts && istanbul cover _mocha $(find ./server/*/ -name \"*.js\" -not -path \"./node_modules/*\" -not -name \"*.spec.js\" -not -name \"*.utils.js\") || true && open coverage/lcov-report/index.html ",
"coverage":
"clear && mocha --opts ./mocha.opts && istanbul cover _mocha $(find ./server/*/ -name \"*.js\" -not -path \"./node_modules/*\" -not -name \"*.spec.js\" -not -name \"*.utils.js\") || true && open coverage/lcov-report/index.html ",
"precommit": "lint-staged"
},
"lint-staged": {
"*.js": [
"prettier --write",
"git add"
]
"*.js": ["prettier --write", "git add"]
},
"dependencies": {
"async": "^2.6.0",
Expand Down
110 changes: 34 additions & 76 deletions server/api/v1.0/api-doc.json
Original file line number Diff line number Diff line change
@@ -1,96 +1,54 @@
{
"apiUrl": "http://localhost:3000/api/v0.1/",
"apiUrl": "http://localhost:3000/api/v1.0/",
"endpoints": [
{
"name": "all items",
"name": "query groceries",
"req": {
"type": "GET",
"params": "/items/",
"params":
"/grocery?lang=de_DE&primaryName=garlic&translate[]=en_GB&translate[]=it_IT&translate[]=de_DE'",
"body": "",
"header": ""
"header":
"-H 'Content-Type: application/json' -H 'x-api-key: YOUR_API_KEY' "
},
"res": {
"status": 200,
"body": {
"data": [
{
"_id": "587a64f2c35acc9f57f13d65",
"type": "legumi",
"__v": 0,
"pic":
"https://upload.wikimedia.org/wikipedia/commons/1/1e/Crimson_cranberrybeans.jpg",
"name": {
"de": {
"main": "Bohnen",
"spec": "schwarz"
},
"pl": {
"main": "Fasola",
"spec": "czarna"
},
"it": {
"main": "Fagioli",
"spec": "borlotti"
}
}
"en_GB": {
"name": "garlic",
"gen": "n"
},
"it_IT": {
"name": "aglio",
"gen": "m"
},
"de_DE": {
"name": "Knoblauch",
"gen": "m"
},
"category": "vegetable",
"primaryName": "garlic"
},
{
"_id": "587a6d436da65aa7f484a135",
"pic":
"https://pbs.twimg.com/profile_images/720276641532870657/zONL97lB.jpg",
"type": "legumi",
"__v": 0,
"name": {
"de": {
"main": "Ravioli",
"spec": "ricotta und spinat"
},
"pl": {
"main": "Ravioli",
"spec": "ricotta ze szpinakiem"
},
"it": {
"main": "Ravioli",
"spec": "ricotta e spinaci"
}
}
}
]
}
}
},
{
"name": "one item",
"req": {
"type": "GET",
"params": "/item/587a64f2c35acc9f57f13d65",
"body": "",
"header": ""
},
"res": {
"status": 200,
"body": {
"data": {
"_id": "587a64f2c35acc9f57f13d65",
"type": "legumi",
"__v": 0,
"pic":
"https://upload.wikimedia.org/wikipedia/commons/1/1e/Crimson_cranberrybeans.jpg",
"name": {
"de": {
"main": "Bohnen",
"spec": "schwarz"
"en_GB": {
"name": "fresh garlic",
"gen": "n"
},
"it_IT": {
"name": "aglio fresco",
"gen": "m"
},
"pl": {
"main": "Fasola",
"spec": "czarna"
"de_DE": {
"name": "frischer Knoblauch",
"gen": "m"
},
"it": {
"main": "Fagioli",
"spec": "borlotti"
}
"category": "vegetable",
"primaryName": "garlic"
}
}
],
"count": 2
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions server/grocery/grocery-find/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const findGrocery = req => {
const primaryName = req.query.primaryName;
const name = req.query.name;

const locale = mapLocale(req.query.lang);
const locale = req.query.lang ? mapLocale(req.query.lang) : 'en_GB';
const translate = getTranslationQueryString(req.query.translate);

const query = buildQuery({
Expand Down Expand Up @@ -57,8 +57,6 @@ function buildQuery({ category, primaryName, locale, name, _id }) {
}

function getTranslationQueryString(translateParam) {
console.log(translateParam);

if (typeof translateParam === 'string') {
return mapLocale(translateParam);
}
Expand Down

0 comments on commit 5ca249b

Please sign in to comment.