Изменение конфигурации
This commit is contained in:
11
server.js
11
server.js
@@ -3,13 +3,12 @@
|
||||
const express = require('express');
|
||||
const bodyParser = require('body-parser');
|
||||
const concatStream = require('concat-stream');
|
||||
const config = require('config');
|
||||
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
|
||||
const config = require('./config');
|
||||
|
||||
/* --- SETUP ---------------------------- */
|
||||
|
||||
// Express
|
||||
@@ -38,12 +37,12 @@ function mkdir(dir) {
|
||||
}
|
||||
|
||||
function toOsPath(urlPath) {
|
||||
return config.maven.dir + urlPath.substr(config.maven.url.length + 1);
|
||||
return config.get('maven.dir') + urlPath.substr(config.get('maven.url').length + 1);
|
||||
}
|
||||
|
||||
/* --- ROUTING -------------------------- */
|
||||
|
||||
app.route(`/${config.maven.url}/*`)
|
||||
app.route(`/${config.get('maven.url')}/*`)
|
||||
.get((req, res) => {
|
||||
let osPath = toOsPath(req.path);
|
||||
fs.exists(osPath, (value) => {
|
||||
@@ -71,5 +70,5 @@ app.route(`/${config.maven.url}/*`)
|
||||
|
||||
/* --- START APP ------------------------ */
|
||||
|
||||
console.info(`Start web server :: ${config.web.host}:${config.web.port}`);
|
||||
app.listen(config.web.port, config.web.host);
|
||||
console.info(`Start web server :: ${config.get('web.host')}:${config.get('web.port')}`);
|
||||
app.listen(config.get('web.port'), config.get('web.host'));
|
||||
|
||||
Reference in New Issue
Block a user