Skip to content
Snippets Groups Projects
Commit 313e8b34 authored by Wilson JALLET's avatar Wilson JALLET :money_with_wings:
Browse files

Gitlab CI update

Modif route vers db dans index.js

Ajout favicon

Correction faute dans README
parent 8a87d05b
No related branches found
No related tags found
No related merge requests found
migrations/ migrations/
seeds/ seeds/
build/ build/
\ No newline at end of file node_modules/
\ No newline at end of file
...@@ -2,4 +2,5 @@ ...@@ -2,4 +2,5 @@
# JS files will have LF line endings # JS files will have LF line endings
# because of linting # because of linting
*.js text eol= lf *.js text eol=lf
\ No newline at end of file *.jsx text eol=lf
\ No newline at end of file
# This file is a template, and might need editing before it works on your project.
# Official framework image. Look for the different tagged releases at: # Official framework image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/node/tags/ # https://hub.docker.com/r/library/node/tags/
image: node:latest image: node:latest
...@@ -6,18 +5,46 @@ image: node:latest ...@@ -6,18 +5,46 @@ image: node:latest
# Pick zero or more services to be used on all builds. # Pick zero or more services to be used on all builds.
# Only needed when using a docker container to run your tests in. # Only needed when using a docker container to run your tests in.
# Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-a-service # Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-a-service
services:
- postgres
# This folder is cached between builds # This folder is cached between builds
# http://docs.gitlab.com/ce/ci/yaml/README.html#cache
cache: cache:
paths: paths:
- node_modules/ - node_modules/
test_async: stages:
- install
- build
- test
installation:
stage: install
script:
- npm install
- npm install -g knex
- npm install -g eslint eslint-plugin-react babel-eslint
artifacts:
paths:
- node_modules/
build:
stage: build
script:
- npm run build
- knex migrate:latest
- knex seed:run
tags:
- database
test:lint:
stage: test
script:
- npm run lint
test:async:
stage: test
script: script:
- npm install
- npm run build
- npm test - npm test
tags: tags:
- backend
- development - development
...@@ -66,7 +66,7 @@ On utilisera Webpack pour transpiler le fichier source [`src/index.js`](./src/in ...@@ -66,7 +66,7 @@ On utilisera Webpack pour transpiler le fichier source [`src/index.js`](./src/in
Pour faire tourner le serveur, il y a deux options : Pour faire tourner le serveur, il y a deux options :
* `npm start` fait tourner le serveur `bundle.js` en mode prod sur le port 8888 (donc il faut consulter https://localhost:8888) * `npm start` fait tourner le serveur `bundle.js` en mode prod sur le port 3000 (donc il faut consulter https://localhost:3000)
* `npm test` le démarre avec [nodemon](https://nodemon.io/), outil dév qui redémarre automatiquement le serveur dans `bundle.js` dès que celui-ci est modifié. * `npm test` le démarre avec [nodemon](https://nodemon.io/), outil dév qui redémarre automatiquement le serveur dans `bundle.js` dès que celui-ci est modifié.
Donc, lancer `npm run watch` dans un terminal et `npm test` dans un autre permet de recompiler le serveur __et__ le redémarrer automatiquement dès qu'il y a une modification. Donc, lancer `npm run watch` dans un terminal et `npm test` dans un autre permet de recompiler le serveur __et__ le redémarrer automatiquement dès qu'il y a une modification.
......
assets/favicon.ico

1.37 KiB

const environment = process.env.NODE_ENV || 'development'; const environment = process.env.NODE_ENV || 'development';
const config = require('./knexfile')[environment]; const config = require('./knexfile')[environment];
console.log(config); console.log("Knex configuration:\n",config);
module.exports = require('knex')(config); module.exports = require('knex')(config);
\ No newline at end of file
import server from './server'; import server from './server';
import knex from '../knex_router'; import knex from '../knex_router';
import colors from 'colors/safe'; import colors from 'colors';
server.get('/', function(req, res) { server.get('/', function(req, res) {
console.log('Connectting to '+req.url); console.log('Connectting to '+req.url);
...@@ -9,8 +9,8 @@ server.get('/', function(req, res) { ...@@ -9,8 +9,8 @@ server.get('/', function(req, res) {
Hello, world ! This is server talking to you live on port `+port+' !'); Hello, world ! This is server talking to you live on port `+port+' !');
}); });
server.get('/db/:table', function(req, res) { server.get('/db/:id', function(req, res) {
knex.select().from(req.params.table).then(function(table) { knex.select().from(req.params.id).then(function(table) {
res.write(JSON.stringify(table,null,2)); res.write(JSON.stringify(table,null,2));
res.end(); res.end();
}); });
......
import express from 'express'; import express from 'express';
import bodyParser from 'body-parser'; import bodyParser from 'body-parser';
import favicon from 'serve-favicon';
import morgan from 'morgan'; import morgan from 'morgan';
import path from 'path';
const server = express(); const server = express();
...@@ -9,6 +11,10 @@ server.use(bodyParser.urlencoded({ ...@@ -9,6 +11,10 @@ server.use(bodyParser.urlencoded({
extended: false extended: false
})); }));
// sigma by Sumana Chamrunworakiat from the Noun Project
server.use(favicon(path.resolve('./','assets','favicon.ico')));
// Morgan is middleware for logging requests // Morgan is middleware for logging requests
server.use(morgan('dev')); server.use(morgan('dev'));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment