-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathserver.js
More file actions
82 lines (61 loc) · 1.89 KB
/
Copy pathserver.js
File metadata and controls
82 lines (61 loc) · 1.89 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/* --------------------
// NODE PACKAGES
-----------------------*/
var express = require('express')
, http = require('http')
, path = require('path')
, util = require('util')
, fs = require('fs')
, nodeStatic = require('node-static')
, file = new nodeStatic.Server('./public')
, mongodb = require('mongodb')
, mongoose = require('mongoose')
/* --------------------
// APPLICATION SETUP
-----------------------*/
var config = require('./app/config')
, model = require('./app/models/model')
, controller = require('./app/controllers/controller')
, view = require('./app/views/view')
process.env.NODE_ENV = "development";
var config = {
fs : {
publicDir: "./public"
}
}
var app = express(),
publicDir = path.join(__dirname, config.fs.publicDir)
// app.configure("production", function() {
app.set('port', 22223);
// app.use(express.logger('dev'));
// app.use(express.bodyParser()); //parses json, multi-part (file), url-encoded
// app.use(app.router); //need to be explicit, (automatically adds it if you forget)
// app.use(express.static(clientDir)); //should cache static assets
// });
app.get('*', function(req, res) {
// file.serve(req, res);
res.send('hello world');
console.dir(app)
var obj = {
foo: "bar",
bob: "doe",
sayFoo: function( ) {
console.log(this.foo)
}
}
obj.sayFoo();
// console.dir(req)
// if (req.url.indexOf('\0') !== -1) {
// return respond('That was evil.');
// }
// fs.exists(path.join(publicDir, req.url), function(exists) {
// if (exists) {
// res.sendfile(path.join(publicDir, req.url));
// } else {
// res.send('404');
// }
// });
});
var server = app.listen(app.get('port'), function() {
console.log("\nNode.js server listening on port " + (app.get('port')))
})