From 40fc9e6e4dd80e5cc5bd9350550ba241cda10035 Mon Sep 17 00:00:00 2001 From: sundowndev Date: Sun, 20 Oct 2019 19:30:18 +0200 Subject: [PATCH 01/11] feat: init docker setup --- client/Dockerfile | 13 +++++++++++ client/nginx.conf | 46 +++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 54 ++++++++++++++++++++++++++++++++++++++++++++++ server/Dockerfile | 12 +++++++++++ 4 files changed, 125 insertions(+) create mode 100644 client/Dockerfile create mode 100644 client/nginx.conf create mode 100644 docker-compose.yml create mode 100644 server/Dockerfile diff --git a/client/Dockerfile b/client/Dockerfile new file mode 100644 index 0000000..939a4a3 --- /dev/null +++ b/client/Dockerfile @@ -0,0 +1,13 @@ +# build stage +FROM node:lts-alpine as build-stage +WORKDIR /app +COPY package*.json ./ +RUN npm install +COPY . . +RUN npm run build + +# production stage +FROM nginx:stable-alpine as production-stage +COPY --from=build-stage /app/public /usr/share/nginx/html +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/client/nginx.conf b/client/nginx.conf new file mode 100644 index 0000000..7025312 --- /dev/null +++ b/client/nginx.conf @@ -0,0 +1,46 @@ +server { + listen 80; + server_name localhost; + + #charset koi8-r; + #access_log /var/log/nginx/host.access.log main; + + root /usr/share/nginx/html; + index index.html; + + location / { + try_files $uri /index.html; + } + + #error_page 404 /404.html; + + # redirect server error pages to the static page /50x.html + # + # error_page 500 502 503 504 /50x.html; + # location = /50x.html { + # root /usr/share/nginx/html; + # } + + # proxy the PHP scripts to Apache listening on 127.0.0.1:80 + # + #location ~ \.php$ { + # proxy_pass http://127.0.0.1; + #} + + # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 + # + #location ~ \.php$ { + # root html; + # fastcgi_pass 127.0.0.1:9000; + # fastcgi_index index.php; + # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; + # include fastcgi_params; + #} + + # deny access to .htaccess files, if Apache's document root + # concurs with nginx's one + # + #location ~ /\.ht { + # deny all; + #} +} diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..7db8365 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,54 @@ +version: '3' + +services: + client: + container_name: hve_client + restart: on-failure + build: + context: . + dockerfile: ./Dockerfile + volumes: + - ./client/nginx.conf:/etc/nginx/conf.d/default.conf:ro + environment: + - NODE_ENV=production + networks: + - default + - web + command: ['nginx', '-g', 'daemon off;'] + # labels: + # - 'traefik.docker.network=web' + # - 'traefik.enable=true' + # - 'traefik.domain=hve.crvx.fr' + # - 'traefik.basic.frontend.rule=Host:hve.crvx.fr' + # - 'traefik.basic.port=80' + # - 'traefik.basic.protocol=http' + # - 'traefik.frontend.headers.SSLRedirect=true' + # - 'traefik.frontend.headers.STSSeconds=315360000' + # - 'traefik.frontend.headers.browserXSSFilter=true' + # - 'traefik.frontend.headers.contentTypeNosniff=true' + # - 'traefik.frontend.headers.forceSTSHeader=true' + # - "traefik.frontend.headers.contentSecurityPolicy=default-src 'self';frame-ancestors 'self';style-src 'self';script-src 'self';img-src 'self';font-src 'self'" + # - 'traefik.frontend.headers.referrerPolicy=no-referrer' + # - 'traefik.frontend.headers.frameDeny=true' + + api: + container_name: hve_api + restart: on-failure + image: node:8 + build: + context: . + dockerfile: ./server/Dockerfile + env_file: + - .env + environment: + - NODE_ENV=production + ports: + - '3000:3000' + networks: + - default + - postgres + command: ['node', '/api/server/index.js'] + +networks: + web: + external: true diff --git a/server/Dockerfile b/server/Dockerfile new file mode 100644 index 0000000..76dd737 --- /dev/null +++ b/server/Dockerfile @@ -0,0 +1,12 @@ +FROM node:8 + +WORKDIR /api + +COPY ./package-lock.json . +COPY ./package.json . +COPY ./server ./server + +# Build +RUN npm install --prefix /api + +EXPOSE 3000 \ No newline at end of file From b76bee58542d6308f3161a522459f69be9234342 Mon Sep 17 00:00:00 2001 From: sundowndev Date: Sun, 20 Oct 2019 20:10:24 +0200 Subject: [PATCH 02/11] feat: init package scripts --- package.json | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 package.json diff --git a/package.json b/package.json new file mode 100644 index 0000000..7f40eba --- /dev/null +++ b/package.json @@ -0,0 +1,21 @@ +{ + "name": "HETICvsEEMI", + "version": "1.0.0", + "description": "Plus Eemien ou Héticien ? Le jeu qui ne fait pas rire les élèves.", + "main": "index.js", + "scripts": { + "install": "cd client && npm i && cd ../server && npm i && cd ..", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/sundowndev/HETICvsEEMI.git" + }, + "keywords": [], + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/sundowndev/HETICvsEEMI/issues" + }, + "homepage": "https://github.com/sundowndev/HETICvsEEMI#readme" +} From ade0f699a4b8ba1f673d54ad252de5995af75b79 Mon Sep 17 00:00:00 2001 From: sundowndev Date: Sun, 20 Oct 2019 20:21:01 +0200 Subject: [PATCH 03/11] refactor: add client ci scripts --- package.json | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 7f40eba..74abc4e 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,13 @@ "description": "Plus Eemien ou Héticien ? Le jeu qui ne fait pas rire les élèves.", "main": "index.js", "scripts": { - "install": "cd client && npm i && cd ../server && npm i && cd ..", - "test": "echo \"Error: no test specified\" && exit 1" + "install": "npm run server:install && npm run client:install", + "server:install": "cd server && npm i", + "client:install": "cd client && npm i", + "client:build": "cd client && npm build", + "client:lint": "cd client && npm run lint", + "client:test": "cd client && npm test", + "test": "npm run client:test" }, "repository": { "type": "git", From 86498806c802d6ffb7cd0d1350c3c3e205a53dea Mon Sep 17 00:00:00 2001 From: sundowndev Date: Sun, 20 Oct 2019 22:59:25 +0200 Subject: [PATCH 04/11] refactor(client): install axios & tslint --- client/package-lock.json | 37 +++++++++++++++++++++++++++++++++++++ client/package.json | 2 ++ 2 files changed, 39 insertions(+) diff --git a/client/package-lock.json b/client/package-lock.json index edb159c..4be8ec8 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -2120,6 +2120,43 @@ "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==", "dev": true }, + "axios": { + "version": "0.19.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.0.tgz", + "integrity": "sha512-1uvKqKQta3KBxIz14F2v06AEHZ/dIoeKfbTRkK1E5oqjDnuEerLmYTgJB5AiQZHJcljpg1TuRzdjDR06qNk0DQ==", + "requires": { + "follow-redirects": "1.5.10", + "is-buffer": "^2.0.2" + }, + "dependencies": { + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "requires": { + "ms": "2.0.0" + } + }, + "follow-redirects": { + "version": "1.5.10", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz", + "integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==", + "requires": { + "debug": "=3.1.0" + } + }, + "is-buffer": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz", + "integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A==" + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + } + } + }, "babel-code-frame": { "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", diff --git a/client/package.json b/client/package.json index 67a07f2..76afbc3 100644 --- a/client/package.json +++ b/client/package.json @@ -10,6 +10,7 @@ "test:unit": "vue-cli-service test:unit" }, "dependencies": { + "axios": "^0.19.0", "core-js": "^2.6.5", "register-service-worker": "^1.6.2", "vue": "^2.6.10", @@ -29,6 +30,7 @@ "node-sass": "^4.9.0", "sass-loader": "^7.1.0", "ts-jest": "^23.0.0", + "tslint": "^5.20.0", "typescript": "^3.4.3", "vue-template-compiler": "^2.6.10" } From 2012c19050511c8dbcfc64bcaa12593fd900a21d Mon Sep 17 00:00:00 2001 From: sundowndev Date: Sun, 20 Oct 2019 22:59:59 +0200 Subject: [PATCH 05/11] refactor(server): data --- server/data/questions.json | 12 ++++++++++-- server/data/schools.json | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/server/data/questions.json b/server/data/questions.json index c5c3c35..2b3b2cc 100644 --- a/server/data/questions.json +++ b/server/data/questions.json @@ -1,8 +1,16 @@ { "questions": [ { - "q": "Vous travaillez sur votre projet de visualisation de données durant la pause. Vous voudriez pouvoir y passer plus de temps, mais votre cours de team-building va commencer.", - "a": 1 + "text": "Vous travaillez sur votre projet de visualisation de données durant la pause. Vous voudriez pouvoir y passer plus de temps, mais votre cours de team-building va commencer.", + "answer": 1 + }, + { + "text": "Le BDE de l'école organise une soirée de ouf. Ça se passe mercredi soir.", + "answer": 1 + }, + { + "text": "question 3", + "answer": 2 } ] } diff --git a/server/data/schools.json b/server/data/schools.json index 7061dae..d953b23 100644 --- a/server/data/schools.json +++ b/server/data/schools.json @@ -1,3 +1,3 @@ { - "schools": [{ "id": 1, "name": "Hetic" }, { "id": 2, "name": "EEMI" }] + "schools": [{ "id": 1, "name": "HÉTIC" }, { "id": 2, "name": "EEMI" }] } From ef9d1b91ed9c9dca6f40a241f750812fe80d3ada Mon Sep 17 00:00:00 2001 From: sundowndev Date: Sun, 20 Oct 2019 23:03:16 +0200 Subject: [PATCH 06/11] refactor(client): init quizz game with api calls Using Axios and vuex state manager --- client/public/index.html | 2 +- client/src/App.vue | 8 ++--- client/src/main.ts | 2 +- client/src/models/question.ts | 9 ++++++ client/src/router.ts | 16 +++++----- client/src/store.ts | 16 ---------- client/src/store/store.ts | 52 ++++++++++++++++++++++++++++++ client/src/utils/index.ts | 12 +++++++ client/src/views/Home.vue | 59 ++++++++++++++++++++++++++++++++--- 9 files changed, 139 insertions(+), 37 deletions(-) create mode 100644 client/src/models/question.ts delete mode 100644 client/src/store.ts create mode 100644 client/src/store/store.ts create mode 100644 client/src/utils/index.ts diff --git a/client/public/index.html b/client/public/index.html index 29ad87c..517ed81 100644 --- a/client/public/index.html +++ b/client/public/index.html @@ -5,7 +5,7 @@ - api-directory + HETIC vs EEMI