-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
29 lines (25 loc) · 996 Bytes
/
index.js
File metadata and controls
29 lines (25 loc) · 996 Bytes
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
//create a default express app with cookie parser and body parser
const express = require('express');
const bodyParser = require('body-parser');
const http = require('node:http');
const app = express();
const server = http.createServer(app);
const fs = require('fs');
require('./SliceBot/client.js')(app);
require('./Socket/index.js')(server);
//setup the app to use cookie parser and body parser
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static('public'))
//setup router
var routerFiles = fs.readdirSync('./routes').filter(file => file.endsWith('.js'));
for(const file of routerFiles) {
const router = require('./routes/' + file);
let fileName = file.substring(0, file.length - 3);
if (fileName == 'home') fileName = '';
app.use('/' + fileName, router);
}
//start the server
server.listen(3001, function() {
console.log('listening on *:' + this._connectionKey.substring(this._connectionKey.lastIndexOf(':') + 1));
});