-
Notifications
You must be signed in to change notification settings - Fork 229
Expand file tree
/
Copy pathindex.js
More file actions
42 lines (33 loc) · 1.05 KB
/
index.js
File metadata and controls
42 lines (33 loc) · 1.05 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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(config);
Queues.useCdn =
typeof listenOpts.useCdn !== 'undefined' ? listenOpts.useCdn : true;
app.locals.appBasePath = listenOpts.basePath || app.locals.appBasePath;
app.use(
app.locals.appBasePath,
express.static(path.join(__dirname, 'public'))
);
app.use(app.locals.appBasePath, routes);
const port = listenOpts.port || 4567;
const host = listenOpts.host || '0.0.0.0'; // Default: listen to all network interfaces.
if (!listenOpts.disableListen) {
app.listen(port, host, () => {
console.log(`Arena is running on port ${port} at host ${host}`);
});
}
return {
app,
queues: Queues,
};
}
function runDefault(config, listenOpts = {}) {
return run(config, listenOpts).app;
}
// default export remains unchanged
module.exports = runDefault;
// named exports
module.exports.run = run;