Guest User

Untitled

a guest
Sep 20th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 KB | None | 0 0
  1. var createError = require('http-errors');
  2. var express = require('express');
  3. var path = require('path');
  4. var cookieParser = require('cookie-parser');
  5. var logger = require('morgan');
  6. var minifyHTML = require('express-minify-html');
  7. var minify = require('express-minify');
  8.  
  9.  
  10.  
  11. var indexRouter = require('./routes/index');
  12. var aboutRouter = require('./routes/about');
  13. var productsRouter = require('./routes/products');
  14. var contactRouter = require('./routes/contact');
  15.  
  16. var app = express();
  17.  
  18. // view engine setup
  19. app.set('views', path.join(__dirname, 'views'));
  20. app.set('view engine', 'hbs');
  21.  
  22.  
  23. // Minifying HTML Code
  24. app.use(minifyHTML({
  25. override: true,
  26. exception_url: false,
  27. htmlMinifier: {
  28. removeComments: true,
  29. collapseWhitespace: true,
  30. collapseBooleanAttributes: true,
  31. removeAttributeQuotes: true,
  32. removeEmptyAttributes: true,
  33. minifyJS: true
  34. }
  35. }));
  36.  
  37. //Minifying JS Code
  38. app.use(minify({
  39. cache: false,
  40. uglifyJsModule: null,
  41. errorHandler: null,
  42. jsMatch: /js/,
  43. cssMatch: /css/,
  44. jsonMatch: /json/,
  45. sassMatch: /scss/,
  46. lessMatch: /less/,
  47. stylusMatch: /stylus/,
  48. coffeeScriptMatch: /coffeescript/,
  49. }));
  50.  
  51. app.use(logger('dev'));
  52. app.use(express.json());
  53. app.use(express.urlencoded({ extended: false }));
  54. app.use(cookieParser());
  55. app.use(express.static(path.join(__dirname, 'public')));
  56.  
  57. app.use('/', indexRouter);
  58. app.use('/about-us', aboutRouter);
  59. app.use('/products', productsRouter);
  60. app.use('/contact-us', contactRouter);
  61.  
  62.  
  63. // catch 404 and forward to error handler
  64. app.use(function(req, res, next) {
  65. next(createError(404));
  66. });
  67.  
  68. // error handler
  69. app.use(function(err, req, res, next) {
  70. // set locals, only providing error in development
  71. res.locals.message = err.message;
  72. res.locals.error = req.app.get('env') === 'development' ? err : {};
  73.  
  74. // render the error page
  75. res.status(err.status || 500);
  76. res.render('error');
  77. });
  78.  
  79. module.exports = app;
  80.  
  81. var express = require('express');
  82. var router = express.Router();
  83.  
  84. /* GET users listing. */
  85. router.get('/hospital-cubical-track-system', function(req, res, next) {
  86. res.render('products/hospital-cubical-track-system', { title : 'Hospital Cubical Track System'});
  87. });
  88.  
  89. router.get('/telescopic-iv-bag-hanger', function(req, res, next) {
  90. res.render('products/telescopic-iv-bag-hanger', { title : 'Telescopic IV Bag Hanger'});
  91. });
  92.  
  93. router.get('/wall-protection-system', function(req, res, next) {
  94. res.render('products/wall-protection-system', { title : 'Wall Protection System'});
  95. });
  96.  
  97. router.get('/hospital-blinds', function(req, res, next) {
  98. res.render('products/hospital-blinds', { title : 'Hospital Blinds'});
  99. });
  100.  
  101. router.get('/nurse-call-system', function(req, res, next) {
  102. res.render('products/nurse-call-system', { title : 'Nurse Call System'});
  103. });
  104.  
  105. router.get('/hospital-linen', function(req, res, next) {
  106. res.render('products/hospital-linen', { title : 'Hospital Linen'});
  107. });
  108.  
  109.  
  110. module.exports = router;
Add Comment
Please, Sign In to add comment