Move app source to src/; more es6

This commit is contained in:
Mikołaj Pich 2017-12-11 17:37:46 +01:00
parent fffe7667c8
commit e19b122f3f
19 changed files with 38 additions and 45 deletions

12
app.js
View file

@ -7,16 +7,16 @@ const sassMiddleware = require('node-sass-middleware');
// const favicon = require('serve-favicon');
const subdomain = require('express-subdomain');
const index = require('./routes/index');
const cufs = require('./routes/cufs');
const uonetplus = require('./routes/uonetplus');
const uonetplusOpiekun = require('./routes/uonetplus-opiekun');
const uonetplusUzytkownik = require('./routes/uonetplus-uzytkownik');
const index = require('./src/routes/index');
const cufs = require('./src/routes/cufs');
const uonetplus = require('./src/routes/uonetplus');
const uonetplusOpiekun = require('./src/routes/uonetplus-opiekun');
const uonetplusUzytkownik = require('./src/routes/uonetplus-uzytkownik');
const app = express();
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('views', path.join(__dirname, 'src/views'));
app.set('view engine', 'pug');
// uncomment after placing your favicon in /public

25
bin/www
View file

@ -3,28 +3,24 @@
/**
* Module dependencies.
*/
var app = require('../app');
var debug = require('debug')('fake-log:server');
var http = require('http');
const app = require('../app');
const debug = require('debug')('fake-log:server');
const http = require('http');
/**
* Get port from environment and store in Express.
*/
var port = normalizePort(process.env.PORT || '3000');
const port = normalizePort(process.env.PORT || '3000');
app.set('port', port);
/**
* Create HTTP server.
*/
var server = http.createServer(app);
const server = http.createServer(app);
/**
* Listen on provided port, on all network interfaces.
*/
server.listen(port);
server.on('error', onError);
server.on('listening', onListening);
@ -32,9 +28,8 @@ server.on('listening', onListening);
/**
* Normalize a port into a number, string, or false.
*/
function normalizePort(val) {
var port = parseInt(val, 10);
let port = parseInt(val, 10);
if (isNaN(port)) {
// named pipe
@ -52,13 +47,12 @@ function normalizePort(val) {
/**
* Event listener for HTTP server "error" event.
*/
function onError(error) {
if (error.syscall !== 'listen') {
throw error;
}
var bind = typeof port === 'string'
let bind = typeof port === 'string'
? 'Pipe ' + port
: 'Port ' + port;
@ -80,10 +74,9 @@ function onError(error) {
/**
* Event listener for HTTP server "listening" event.
*/
function onListening() {
var addr = server.address();
var bind = typeof addr === 'string'
let addr = server.address();
let bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port;
debug('Listening on ' + bind);

View file

@ -1,8 +1,8 @@
var express = require('express');
var router = express.Router();
const express = require('express');
const router = express.Router();
/* GET home page. */
router.get('/', function(req, res) {
router.get('/', (req, res) => {
res.render('index', { title: 'fake-log', domain: req.get('host') });
});

View file

@ -1,38 +1,38 @@
var express = require('express');
var router = express.Router();
const express = require('express');
const router = express.Router();
global.opiekunRoot = "/Default/123456";
router.get("/", function(req, res) {
router.get("/", (req, res) => {
res.json({
"name" : "uonetplus-opiekun",
"message": "Not implemented yet"
});
});
router.get("/Default/123456/", function (req, res) {
router.get("/Default/123456/", (req, res) => {
res.redirect("/Default/123456/Start/Index/");
});
router.get("/Default/123456/Start/Index/", function (req, res) {
router.get("/Default/123456/Start/Index/", (req, res) => {
res.render("opiekun/start", { title: "Witryna ucznia i rodzica Strona główna" });
});
router.get("/Default/123456/Uczen.mvc/DanePodstawowe", function (req, res) {
router.get("/Default/123456/Uczen.mvc/DanePodstawowe", (req, res) => {
res.render("opiekun/dane", {
title: "Witryna ucznia i rodzica Dane ucznia",
data: require("../data/opiekun/dane.json")
data: require("../../data/opiekun/dane.json")
});
});
router.get("/Default/123456/Oceny(\.mvc|)/Wszystkie", function (req, res) {
router.get("/Default/123456/Oceny(\.mvc|)/Wszystkie", (req, res) => {
if (req.query.details === '2') {
res.render("opiekun/oceny-szczegolowy", {
data: require("../data/opiekun/oceny-szczegolowy.json")
data: require("../../data/opiekun/oceny-szczegolowy.json")
});
} else {
res.render("opiekun/oceny-skrocony", {
data: require("../data/opiekun/oceny-skrocony.json")
data: require("../../data/opiekun/oceny-skrocony.json")
});
}
});

View file

@ -1,7 +1,7 @@
var express = require('express');
var router = express.Router();
const express = require('express');
const router = express.Router();
router.get("/", function(req, res) {
router.get("/", (req, res) => {
res.json({
"name" : "uonetplus-uzytkownik",
"message": "Not implemented yet"

View file

@ -1,15 +1,15 @@
var express = require('express');
var router = express.Router();
var protocol = require('../utils/connection');
const express = require('express');
const router = express.Router();
const protocol = require('../utils/connection');
router.get("/", function(req, res) {
router.get("/", (req, res) => {
res.json({
"name" : "uonetplus",
"message": "Not implemented yet"
});
});
router.post("/Default/LoginEndpoint.aspx", function (req, res) {
router.post("/Default/LoginEndpoint.aspx", (req, res) => {
if (req.body.wa && req.body.wresult) {
return res.redirect("/Default/")
}
@ -17,11 +17,11 @@ router.post("/Default/LoginEndpoint.aspx", function (req, res) {
res.json({message: "error"});
});
router.get("/Default/", function (req, res) {
router.get("/Default/", (req, res) => {
res.redirect("/Default/Start.mvc/Index");
});
router.get("/Default/Start.mvc/Index", function (req, res) {
router.get("/Default/Start.mvc/Index", (req, res) => {
res.render("homepage", {
title: "Uonet+",
uonetplusOpiekun: protocol(req) + "://" + req.get('host').replace("uonetplus", "uonetplus-opiekun")