32 lines
819 B
JavaScript
32 lines
819 B
JavaScript
const fshelpers = require('./lib/fshelpers');
|
|
const express = require('express');
|
|
const repository = require('./lib/repository');
|
|
const facade = require('./lib/facade');
|
|
|
|
|
|
async function asyncMain()
|
|
{
|
|
if (await fshelpers.exists('config.js'))
|
|
global.config = require('./config.js');
|
|
else
|
|
global.config = require('./config.default.js');
|
|
|
|
|
|
facade.init(global.config.contacts);
|
|
await repository.init(global.config.dataFilename, global.config.salt);
|
|
|
|
const app = express();
|
|
|
|
app.use(express.json());
|
|
app.use(express.urlencoded({ extended: false }));
|
|
|
|
app.use('/api', require('./routes/api'));
|
|
app.use('/', express.static('frontend/dist'));
|
|
|
|
app.listen(global.config.port, () =>
|
|
{
|
|
console.log(`NotificationLatch listening at http://localhost:${global.config.port}`);
|
|
});
|
|
}
|
|
|
|
asyncMain(); |