forked from bee-queue/arena
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
27 lines (19 loc) · 788 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const express = require('express');
const path = require('path');
const Arena = require('./src/server/app');
const routes = require('./src/server/views/routes');
function run(config, listenOpts = {}) {
const {app, Queues} = Arena();
if (config) Queues.setConfig(config);
Queues.useCdn = typeof listenOpts.useCdn !== 'undefined' ? listenOpts.useCdn : true;
app.locals.basePath = listenOpts.basePath || app.locals.basePath;
app.use(app.locals.basePath, express.static(path.join(__dirname, 'public')));
app.use(app.locals.basePath, routes);
const port = listenOpts.port || 4567;
if (!listenOpts.disableListen) {
app.listen(port, () => console.log(`Arena is running on port ${port}`));
}
return app;
}
if (require.main === module) run();
module.exports = run;