-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
58 lines (50 loc) · 1.57 KB
/
Copy pathapp.js
File metadata and controls
58 lines (50 loc) · 1.57 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
/*
* app.js - Servidor express simples
*/
/*jslint node : true, continue : true,
devel : true, indent : 2, maxerr : 50,
newcap : true, nomen : true, plusplus : true,
regexp : true, sloppy : true, vars : false,
white : true
*/
/*global */
// ------------ BEGIN MODULE SCOPE VARIABLES --------------
'use strict';
var
http = require( 'http' ),
express = require( 'express' ),
body_parser = require('body-parser'),
method_override = require('method-override'),
routes = require('./lib/routes'),
crud = require('./lib/crud'),
app = express(),
server = http.createServer( app ),
dev_enviroment;
// ------------- END MODULE SCOPE VARIABLES ---------------
// ------------- BEGIN SERVER CONFIGURATION ---------------
dev_enviroment = app.get('env');
app.use(body_parser.urlencoded({
extended: true
}) );
app.use( method_override() );
app.use( express.static( __dirname + '/public' ) );
// app.use( app.router );
if ( dev_enviroment === 'development' ) {
// app.use( logger );
// app.use( error_handler({
// dumpExceptions : true,
// showStack : true
// }) );
}
if ( dev_enviroment === 'production' ) {
// app.use( error_handler () );
};
routes.configRoutes( app, server );
// -------------- END SERVER CONFIGURATION ----------------
// ----------------- BEGIN START SERVER -------------------
server.listen( 3000 );
console.log(
'Servidor Express na porta %d em modo %s',
server.address().port, app.settings.env
);
// ------------------ END START SERVER --------------------