flayre-server/server/index.js
William Brawner 7f14bc11e7 Add static file routing
Signed-off-by: William Brawner <me@wbrawner.com>
2020-09-15 07:31:58 -07:00

22 lines
680 B
JavaScript

const express = require('express');
const eventRouter = require('./event.js').router;
const port = require('./config.js').port;
const appRouter = require('./app.js').router;
const cors = require('cors');
const app = express();
app.use(express.json());
app.use(cors()); // TODO: Enable this for event creation only
// app.get('/id', (req, res) => {
// const length = Number.parseInt(req.query['length']) || 32;
// res.send(require('./util.js').randomId(length));
// });
app.use(express.static('server/static'));
app.use('/api/apps', appRouter);
app.use('/api/events', eventRouter);
app.listen(port, () => {
console.log(`Started Flayre server on port ${port}`);
});