1
- var createError = require ( ' http-errors' ) ;
2
- const express = require ( ' express' ) ;
3
- const path = require ( ' path' ) ;
4
- const cookieParser = require ( ' cookie-parser' ) ;
5
- const logger = require ( ' morgan' ) ;
6
- const { engine } = require ( ' express-handlebars' ) ;
7
- const helpers = require ( ' handlebars-helpers' ) ;
1
+ var createError = require ( " http-errors" ) ;
2
+ const express = require ( " express" ) ;
3
+ const path = require ( " path" ) ;
4
+ const cookieParser = require ( " cookie-parser" ) ;
5
+ const logger = require ( " morgan" ) ;
6
+ const { engine } = require ( " express-handlebars" ) ;
7
+ const helpers = require ( " handlebars-helpers" ) ;
8
8
9
- const indexRouter = require ( ' ./routes/index' ) ;
10
- const connectionRouter = require ( ' ./routes/connection' ) ;
11
- const proofRouter = require ( ' ./routes/proof' ) ;
9
+ const indexRouter = require ( " ./routes/index" ) ;
10
+ const connectionRouter = require ( " ./routes/connection" ) ;
11
+ const proofRouter = require ( " ./routes/proof" ) ;
12
12
13
13
const app = express ( ) ;
14
14
15
15
// view engine setup
16
- app . set ( 'views' , path . join ( __dirname , 'views' ) ) ;
17
- app . set ( 'view engine' , 'hbs' ) ;
18
- app . engine ( 'hbs' , engine ( {
19
- extname : 'hbs' ,
20
- defaultView : 'default' ,
21
- layoutsDir : path . join ( __dirname , '/views/layouts/' ) ,
22
- partialsDir : [
23
- path . join ( __dirname , '/views/partials' ) ,
24
- path . join ( __dirname , '/views/partials/connection' ) ,
25
- path . join ( __dirname , '/views/partials/home' ) ,
26
- path . join ( __dirname , '/views/partials/proof' ) ,
27
- ] ,
28
- helpers : helpers ( [ 'array' , 'comparison' ] )
29
- } ) ) ;
16
+ app . set ( "views" , path . join ( __dirname , "views" ) ) ;
17
+ app . set ( "view engine" , "hbs" ) ;
18
+ app . engine (
19
+ "hbs" ,
20
+ engine ( {
21
+ extname : "hbs" ,
22
+ defaultView : "default" ,
23
+ layoutsDir : path . join ( __dirname , "/views/layouts/" ) ,
24
+ partialsDir : [
25
+ path . join ( __dirname , "/views/partials" ) ,
26
+ path . join ( __dirname , "/views/partials/connection" ) ,
27
+ path . join ( __dirname , "/views/partials/home" ) ,
28
+ path . join ( __dirname , "/views/partials/proof" ) ,
29
+ ] ,
30
+ helpers : helpers ( [ "array" , "comparison" ] ) ,
31
+ } )
32
+ ) ;
30
33
31
- app . use ( logger ( ' dev' ) ) ;
34
+ app . use ( logger ( " dev" ) ) ;
32
35
app . use ( express . json ( ) ) ;
33
36
app . use ( express . urlencoded ( { extended : false } ) ) ;
34
37
app . use ( cookieParser ( ) ) ;
35
- app . use ( express . static ( path . join ( __dirname , ' public' ) ) ) ;
38
+ app . use ( express . static ( path . join ( __dirname , " public" ) ) ) ;
36
39
37
- app . use ( '/' , indexRouter ) ;
38
- app . use ( ' /connections' , connectionRouter ) ;
39
- app . use ( ' /proofs' , proofRouter ) ;
40
+ app . use ( "/" , indexRouter ) ;
41
+ app . use ( " /connections" , connectionRouter ) ;
42
+ app . use ( " /proofs" , proofRouter ) ;
40
43
41
44
// catch 404 and forward to error handler
42
- app . use ( function ( req , res , next ) {
45
+ app . use ( function ( req , res , next ) {
43
46
next ( createError ( 404 ) ) ;
44
47
} ) ;
45
48
46
49
// error handler
47
- app . use ( function ( err , req , res , next ) {
50
+ app . use ( function ( err , req , res , next ) {
48
51
// set locals, only providing error in development
49
52
res . locals . message = err . message ;
50
- res . locals . error = req . app . get ( ' env' ) === ' development' ? err : { } ;
53
+ res . locals . error = req . app . get ( " env" ) === " development" ? err : { } ;
51
54
52
55
// render the error page
53
56
res . status ( err . status || 500 ) ;
54
- res . render ( ' error' ) ;
57
+ res . render ( " error" ) ;
55
58
} ) ;
56
59
57
60
// Start the server
@@ -60,5 +63,4 @@ app.listen(PORT, () => {
60
63
console . log ( `Server is running on port ${ PORT } ` ) ;
61
64
} ) ;
62
65
63
-
64
66
module . exports = app ;
0 commit comments