Skip to content

Commit fd1aa56

Browse files
author
Jon Myrick
authored
Merge pull request CodewarsClone#3 from CodewarsClone/server-file
The base of the server.js file. No endpoints yet
2 parents 3a8a78d + 51ebe52 commit fd1aa56

2 files changed

Lines changed: 37 additions & 1 deletion

File tree

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,12 @@
1616
"bugs": {
1717
"url": "https://github.com/CodewarsClone/Codewars/issues"
1818
},
19-
"homepage": "https://github.com/CodewarsClone/Codewars#readme"
19+
"homepage": "https://github.com/CodewarsClone/Codewars#readme",
20+
"dependencies": {
21+
"body-parser": "^1.15.2",
22+
"cors": "^2.8.1",
23+
"express": "^4.14.0",
24+
"express-session": "^1.14.2",
25+
"massive": "^2.5.0"
26+
}
2027
}

server.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
var express = require('express');
2+
var bodyParser = require('body-parser');
3+
var session = require('express-session');
4+
var cors = require('cors');
5+
var config = require('./config.js');
6+
var massive = require('massive');
7+
var connectionString = config.connectionString;
8+
9+
var app = module.exports = express();
10+
11+
var massiveInstance = massive.connectSync({connectionString : connectionString});
12+
13+
app.use(express.static(__dirname + '/public'));
14+
app.use(bodyParser.json());
15+
app.use(cors());
16+
17+
app.set('db', massiveInstance);
18+
19+
var db = app.get('db');
20+
21+
app.use(session({
22+
secret: config.sessionSecret,
23+
saveUninitialized: false,
24+
resave: false
25+
}));
26+
27+
app.listen(config.port, function() {
28+
console.log('listening to port', config.port);
29+
});

0 commit comments

Comments
 (0)