diff --git a/package.json b/package.json index d049d8e..6d70680 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "connect-flash": "^0.1.1", "connect-mongo": "^4.6.0", "cookie-parser": "^1.4.6", + "debug": "^4.3.3", "ejs": "^3.1.6", "express": "^4.17.2", "express-session": "^1.17.2", diff --git a/src/app.js b/src/app.js index 0ca0bf5..50c4eeb 100644 --- a/src/app.js +++ b/src/app.js @@ -50,10 +50,8 @@ if (["production"].indexOf(env) !== -1) { /* eslint-disable func-names */ app.use((req, res, next) => { if (req.secure) { - // request was via https, so do no special handling next(); } else { - // request was via http, so redirect to https res.redirect(`https://${req.headers.host}${req.url}`); } }); diff --git a/src/bin/www.js b/src/bin/www.js index 1723d8a..3fc7b77 100644 --- a/src/bin/www.js +++ b/src/bin/www.js @@ -4,54 +4,49 @@ * Module dependencies. */ -import app from '../app'; -import debugLib from 'debug'; -import http from 'http'; -import {port} from '../config'; +import debugLib from "debug"; +import http from "http"; +import app from "../app"; +import { port } from "../config"; -const debug = debugLib('nodecdtheque:server'); +const debug = debugLib("nodecdtheque:server"); const server = http.createServer(app); -server.listen(port); -server.on('error', onError); -server.on('listening', onListening); - /** * Event listener for HTTP server "error" event. * @param {*} error */ function onError(error) { - if (error.syscall !== 'listen') { - throw error; - } + if (error.syscall !== "listen") { + throw error; + } - const bind = typeof port === 'string' ? - 'Pipe ' + port : - 'Port ' + port; + const bind = typeof port === "string" ? `Pipe ${port}` : `Port ${port}`; - // handle specific listen errors with friendly messages - switch (error.code) { - case 'EACCES': - console.error(bind + ' requires elevated privileges'); - process.exit(1); - break; - case 'EADDRINUSE': - console.error(bind + ' is already in use'); - process.exit(1); - break; - default: - throw error; - } + switch (error.code) { + case "EACCES": + console.error(`${bind} requires elevated privileges`); + process.exit(1); + break; + case "EADDRINUSE": + console.error(`${bind} is already in use`); + process.exit(1); + break; + default: + throw error; + } } /** * Event listener for HTTP server "listening" event. */ function onListening() { - const addr = server.address(); - const bind = typeof addr === 'string' ? - 'pipe ' + addr : - 'port ' + addr.port; - debug('Listening on ' + bind); + const addr = server.address(); + const bind = + typeof addr === "string" ? `pipe ${addr}` : `port ${addr.port}`; + debug(`Listening on ${bind}`); } +server.listen(port); +server.on("error", onError); +server.on("listening", onListening); diff --git a/src/views/error.ejs b/src/views/error.ejs index d2057dd..5c36b8a 100644 --- a/src/views/error.ejs +++ b/src/views/error.ejs @@ -1,23 +1,22 @@ -<%- include('partials/head', {page: page, user: user}); %> - - - <%- include('partials/header'); %> -
-
-
-

<%= page.title %>

- <% if ( errorCode && errorCode === 404 ) { %> - Erreur 404 - <% } %> -

- <%= page.error %> -

-
-
-
- <%- include('partials/footer', {page: page, user: user, blog: null}); %> - + <%- include('partials/head', {page: page, user: user}); %> + + <%- include('partials/header'); %> +
+
+
+

<%= page.title %>

+ <% if ( errorCode && errorCode === 404 ) { %> + Erreur 404 + <% } %> +

+ <%= page.error %> +

+
+
+
+ <%- include('partials/footer', {page: page, user: user, blog: null}); %> + \ No newline at end of file diff --git a/src/views/index.ejs b/src/views/index.ejs index 4c21a1f..063569a 100644 --- a/src/views/index.ejs +++ b/src/views/index.ejs @@ -1,26 +1,27 @@ - <%- include('partials/head'); %> - - <%- include('partials/header'); %> + <%- include('partials/head'); %> + + <%- include('partials/header'); %> - <% if ( page.failureFlash ) {%> - - <% } %> - <% - if (error && error.length > 0) { - for( let i = 0 ; i < error.length ; i += 1 ) { - %> - - <% - } - } - %> - <%- include(viewname) %> - <%- include('partials/footer'); %> - + <% if ( page.failureFlash ) {%> + + <% } %> + + <% + if (error && error.length > 0) { + for( let i = 0 ; i < error.length ; i += 1 ) { + %> + + <% + } + } + %> + <%- include(viewname) %> + <%- include('partials/footer'); %> + diff --git a/src/views/pages/connexion.ejs b/src/views/pages/connexion.ejs index 5c3c444..162a205 100644 --- a/src/views/pages/connexion.ejs +++ b/src/views/pages/connexion.ejs @@ -1,26 +1,24 @@
-
-
-
- DarKou -

Connexion

+
+
+ + DarKou +

Connexion

-
- - +
+ + +
+ +
+ + +
+ + + +

Pas encore inscrit ? Inscrivez-vous

+
- -
- - -
- - - -

Pas encore inscrit ? - Inscrivez-vous -

-
-
\ No newline at end of file diff --git a/src/views/pages/inscription.ejs b/src/views/pages/inscription.ejs index 9ca3a04..4b7e2b6 100644 --- a/src/views/pages/inscription.ejs +++ b/src/views/pages/inscription.ejs @@ -1,31 +1,29 @@
-
-
-
- DarKou -

Inscription

+
+
+ + DarKou +

Inscription

-
- - +
+ + +
+ +
+ + +
+ +
+ + +
+ + + +

Déjà inscrit ? Connectez-vous

+
- -
- - -
- -
- - -
- - - -

Déjà inscrit ? - Connectez-vous -

-
-
\ No newline at end of file diff --git a/src/views/partials/head.ejs b/src/views/partials/head.ejs index 7b0f74f..448c4ec 100644 --- a/src/views/partials/head.ejs +++ b/src/views/partials/head.ejs @@ -1,18 +1,17 @@ - - - + + - <% if (page.title) { %><%= page.title %> <% } else { %> DarKou - Ma CDThèque <% } %> - + <% if (page.title) { %><%= page.title %> <% } else { %> DarKou - Ma CDThèque <% } %> + - - + + - - - + + + - + \ No newline at end of file diff --git a/src/views/partials/header.ejs b/src/views/partials/header.ejs index 74d6c0e..0de3caf 100644 --- a/src/views/partials/header.ejs +++ b/src/views/partials/header.ejs @@ -1,25 +1,24 @@ \ No newline at end of file