-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
66 lines (51 loc) · 1.39 KB
/
app.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// node app.js
//
// Module dependencies.
//
var express = require('express');
var routes = require('./server/routes/index');
var http = require('http');
var path = require('path');
var _ = require('underscore');
var Bookshelf = require('bookshelf');
// var bookshelf = require('./server/db/development.js');
var bookshelf = require('./server/db/production.js');
var api = require('./server/routes/api');
// initialize express
var app = express();
//
// environment configuration
//
app.set('port', process.env.PORT || 1337);
app.set('views', __dirname + '../');
app.set('view engine', 'html');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.urlencoded());
app.use(express.methodOverride());
app.use(express.cookieParser('your secret here'));
app.use(express.session());
app.use(express.bodyParser());
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
//
// development only - error checking
//
if ('development' == app.get('env')) {
app.use(express.errorHandler());
}
//
// routes
//
app.get('/', routes.index);
app.get('/client/*', routes.client);
app.get('/api/users/', api.users);
app.post('/api/users/', api.addUser);
//
// create and launch server
//
http.createServer(app).listen(app.get('port'), function(){
console.log('this ya boi EXPRESS.COM we outchea on ' + app.get('port'));
});
// could also use:
// app.listen(app.get('port'));