Title / Description
Code const express = require('express');sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss const morgan = require('morgan'); const session = require('express-session'); const flash = require('connect-flash'); require('dotenv').config(); require('./libs/dbConnect'); const { verifyUser } = require('./libs/middleware'); const userRouter = require('./routes/user.route'); const dashboardRouter = require('./routes/dashboard.route'); const app = express(); app.set('views', './views'); app.set('view engine', 'ejs'); app.use(morgan('dev')); app.use(express.static('./public')); app.use(express.urlencoded({ extended: false })); app.use( session({ secret: process.env.AUTH_SECRET, saveUninitialized: true, resave: false, }) ); app.use(flash()); app.use('/', userRouter); app.use('/dashboard', verifyUser, dashboardRouter); app.get('*', (req, res) => { res.status(404).render('index', { title:'Not Found', message: 'Not Found' }); }); const PORT = 3000; app.listen(PORT, () => { console.log(`Server running on port ${PORT}`); });
Author
Highlight as C C++ CSS Clojure Delphi ERb Groovy (beta) HAML HTML JSON Java JavaScript PHP Plain text Python Ruby SQL XML YAML diff code