Select Git revision
app.js
app.js 1.68 KiB
const express = require('express');
const bodyParser = require('body-parser');
const exec = require('child_process').exec;
const path = require('path');
const fsReaddir = require('fs-readdir');
const exphbs = require('express-handlebars');
//initializer
const initGitRepos = require('./initializers/gitRepos.js');
const app = express();
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(bodyParser.json());
//set handlebars as view engine
app.engine('.hbs', exphbs({extname: '.hbs'}));
app.set('view engine', '.hbs');
//load names of available download files
const downloadFiles = require('./public/data/downloadFiles.json');
const downloadNames = Object.keys(downloadFiles);
app.set('downloadFiles', downloadFiles);
app.set('downloadNames', downloadNames);
//load functions for frontend and backend build
const clientFolder = require('./public/javascripts/clientFolder.js');
const backendFunctions = require('./public/javascripts/backendFunctions.js');
const frontendFunctions = require('./public/javascripts/frontendFunctions.js');
const zipFunctions = require('./public/javascripts/zipFunctions.js');
app.set('clientFolder', clientFolder);
app.set('backendFunctions', backendFunctions);
app.set('frontendFunctions', frontendFunctions);
app.set('zipFunctions', zipFunctions);
//clientCounter holds the number of clients who wants to download files
let clientCounter = 0;
app.locals.clientCounter = clientCounter;
//routes
require('./routes/home.js')(app);
require('./routes/download.js')(app);
//TODO add spinner for telling user to wait until initialization is done
//initGitRepos.initialize(downloadFiles);
app.listen(3000);
console.log("Downloader started on port 3000.");