Express server.js template

    0

    0

    methodOverride is a middleware that allows you to override a method on a specific object. We are using it to override the _method on the app object. This method is used to get the list of routes that are available.

    Library: express

    const express = require('express');
    const methodOverride = require('method-override');
    
    const app = express();
    const routes = require('./routes')
    
    app.use(express.static("public"))
    app.use(methodOverride('_method'));
    app.use(express.urlencoded({extended: true}));
    
    app.use('/path1', routes.path1)
    app.use('/path2', routes.path2)
    
    app.listen(3000, () => {
      console.log('I am listening on port 3000');
    })
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.