The NodeGoat application is an Express-based server that connects to a MongoDB instance. The server configuration involves setting up middleware for body parsing, session management, static assets, and a templating engine (Swig via Consolidate).
Core Configuration Details:
- Database: Uses
mongodb.MongoClient to connect to the database provided in the application config. - Session Management: Uses
express-session with a secret defined in the application config. saveUninitialized and resave are both set to true. - Templating: Uses
swig as the view engine. Note that autoescape is explicitly set to false in the current configuration (which is a security vulnerability). - Static Assets: Served from
${__dirname}/app/assets. - Routing: Routes are initialized by passing the
app instance and the db instance to the routes module.
MongoClient.connect(db, (err, db) => {
// ... middleware setup ...
routes(app, db);
http.createServer(app).listen(port, () => {
console.log(`Express http server listening on port ${port}`);
});
});