Archived
0

Изменение конфигурации

This commit is contained in:
2017-11-10 13:38:51 +03:00
parent 1d77fa6f58
commit 758f6ae9c6
5 changed files with 51 additions and 34 deletions

View File

@@ -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'));