Skip to content

Commit

Permalink
doc(api): adding install and launch documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Debrej committed Jan 6, 2020
1 parent 263e6d9 commit 3115562
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
15 changes: 15 additions & 0 deletions api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,18 @@ La documentation de l'api se situe à l'adresse suivante :
Les technologies utilisées sont :
+ Express, qui sert de serveur web, [site officiel](https://expressjs.com)
+ Sequelize, qui sert d'ORM, [site officiel](https://sequelize.org/)

## Installation et lancement
Pour installer l'API :
`npm install`.

Pour créer la base de données :
`sudo npm run create_database`.
Si on ne lance pas le script avec `sudo` ou avec root, on ne peut pas se connecter à MySQL en root.

Pour lancer l'API :
`npm start index.js` ou `nodemon index.js`.
Au niveau du serveur à distance, on utilise [pm2](https://pm2.keymetrics.io/) qui est un gestionnaire de processus
permettant de facilement les gérer ainsi que d'ajouter du load-balancing.
On y ajoute le plugin [pm2-logrotate](https://www.npmjs.com/package/pm2-logrotate) pour limiter la taille des fichiers de log.
Pour utiliser pm2 : `pm2 start index.js`.
7 changes: 7 additions & 0 deletions api/server/create_database.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
echo "Enter the root password for mysql"
mysql -u root -p <<EOF
CREATE DATABASE project_a;
CREATE USER 'project_a'@'localhost' IDENTIFIED WITH mysql_native_password BY 'project_a';
GRANT ALL PRIVILEGES ON project_a.* TO 'project_a'@'localhost';
EOF
3 changes: 2 additions & 1 deletion api/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"description": "Project A is the new Assomaker",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"create_database": "./create_database.sh"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit 3115562

Please sign in to comment.