-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.coffee
executable file
·39 lines (30 loc) · 1.16 KB
/
index.coffee
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
path = require 'path'
fs = require 'fs'
express = require 'express'
bodyParser = require 'body-parser'
http = require 'http'
serveStatic = require 'serve-static' # use this because of mime type issues with express.static
socketio = require 'socket.io'
# create web server instance
app = express()
# TODO: do we need this?
app.use bodyParser.json()
app.use bodyParser.urlencoded({ extended: false })
server = http.Server app
# use own instance of mongoose for faking and stuff, couldnt get mers mongoose to work properly
m = require 'mongoose'
m.connect 'mongodb://localhost/moedit'
models = require('./server/models')(m)
fakeData = require './server/fakedata'
fakeData(models)
io = socketio(server) #create web socket for pushing data to clients
io.on 'connection', (socket) =>
console.log "#{io.sockets.sockets.length} socket(s) connected"
port = process.env.NODEPORT || 3030
server.listen port, ->
console.log "web server is listening on port #{port}"
# Set the public folder as static assets
app.use serveStatic path.join(__dirname, 'client', 'public')
# load routes
routes = require ('./server/routes')
routes(app, models, __dirname)