2020-08-30 20:42:50 +00:00
|
|
|
import express from 'express';
|
2020-09-01 16:13:40 +00:00
|
|
|
import { eventRouter } from './event.js';
|
|
|
|
import { port } from './config.js';
|
|
|
|
import { randomId } from './util.js';
|
|
|
|
import { appRouter } from './app.js';
|
2020-08-30 20:42:50 +00:00
|
|
|
|
|
|
|
const app = express();
|
|
|
|
app.use(express.json());
|
|
|
|
|
|
|
|
app.get('/', (req, res) => {
|
|
|
|
res.send('Hello, world!');
|
|
|
|
});
|
|
|
|
|
|
|
|
app.get('/id', (req, res) => {
|
|
|
|
const length = Number.parseInt(req.query['length']) || 32;
|
|
|
|
res.send(randomId(length));
|
|
|
|
});
|
|
|
|
|
2020-09-01 16:13:40 +00:00
|
|
|
app.use('/apps', appRouter)
|
|
|
|
app.use('/events', eventRouter)
|
2020-08-30 20:42:50 +00:00
|
|
|
|
|
|
|
app.listen(port, () => {
|
|
|
|
console.log(`Started Flayre server on port ${port}`);
|
2020-09-01 16:13:40 +00:00
|
|
|
});
|