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" ) ;
88
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" ) ;
1212
1313const app = express ( ) ;
1414
1515// 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+ ) ;
3033
31- app . use ( logger ( ' dev' ) ) ;
34+ app . use ( logger ( " dev" ) ) ;
3235app . use ( express . json ( ) ) ;
3336app . use ( express . urlencoded ( { extended : false } ) ) ;
3437app . use ( cookieParser ( ) ) ;
35- app . use ( express . static ( path . join ( __dirname , ' public' ) ) ) ;
38+ app . use ( express . static ( path . join ( __dirname , " public" ) ) ) ;
3639
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 ) ;
4043
4144// catch 404 and forward to error handler
42- app . use ( function ( req , res , next ) {
45+ app . use ( function ( req , res , next ) {
4346 next ( createError ( 404 ) ) ;
4447} ) ;
4548
4649// error handler
47- app . use ( function ( err , req , res , next ) {
50+ app . use ( function ( err , req , res , next ) {
4851 // set locals, only providing error in development
4952 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 : { } ;
5154
5255 // render the error page
5356 res . status ( err . status || 500 ) ;
54- res . render ( ' error' ) ;
57+ res . render ( " error" ) ;
5558} ) ;
5659
5760// Start the server
@@ -60,5 +63,4 @@ app.listen(PORT, () => {
6063 console . log ( `Server is running on port ${ PORT } ` ) ;
6164} ) ;
6265
63-
6466module . exports = app ;
0 commit comments