-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.js
31 lines (25 loc) · 849 Bytes
/
server.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
28
29
30
31
const express = require('express')
const bodyParser = require('body-parser')
const methodOverride = require('method-override')
const mongoose = require('mongoose')
const restify = require('express-restify-mongoose')
const morgan = require('morgan')
const app = express()
const router = express.Router()
const compression = require('compression')
app.use(morgan('combined'))
app.use(compression({}))
app.use(bodyParser.json())
app.use(methodOverride())
mongoose.connect('mongodb://localhost:27017/test')
app.use('/', express.static(__dirname + '/client'));
restify.serve(router, mongoose.model('User', new mongoose.Schema({
someData: {type: String},
name: {type: String, required: true},
age: {type: Number},
gender: {type: String}
})))
app.use(router)
app.listen(8080, () => {
console.log('Express server listening on port 8080')
})