New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

express-zero-config

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-zero-config

Create an express app with a default configuration. Based on the official express generator.

1.1.2
latest
Source
npm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Express Zero Config

Create an express app with a default configuration. Based on the official express generator.

Install

npm install -S express-zero-config
#or
yarn add express-zero-config

Quick Start:

const ezc = require('express-zero-config');

const router = ezc.createRouter();

router.get('/', (req, res, next) => {
  res.json({
    message: 'Hello World!'
  })
});

ezc.startServer(router); // startServer parameters: (express.Router, port_number)

For more advanced usage and configuration options see the Examples section.

Included Defaults:

  • Handlebars view engine
  • 404 and uncaught error handlers
  • middleware:
    • morgan (development logger)
    • cookie-parser
    • body-parser

express-zero-config on github

If you get some use out of express-zero-config please star the repo on github.

Make an issue on github to report bugs and request new features.

Examples

Source code for the below examples is available in the examples folder.

Usage with views and static configuration

const path = require('path');
const ezc = require('express-zero-config');

const router = ezc.createRouter();

router.get('/', (req, res, next) => {
  res.json({
    message: 'Hello World!'
  })
});

const app = ezc.createApp({
  router,
  view_path: path.join(__dirname, 'views'),
  static_dir: path.join(__dirname, 'public')
});

const server = ezc.createServer(app); // createServer parameters: (express app, port_number)

server.start();

Usage with multiple routers and middleware

const path = require('path');
const session = require('express-session');
const passport = require('passport');
const ezc = require('express-zero-config');

const auth = require('./auth'); // Exports an express router
const api = require('./api'); // Exports an express router

const router = ezc.createRouter();
router.use('/auth', auth);
router.use('/api/v1', api);

const app = ezc.createApp({
  router,
  use: [
    session({ secret: process.env.SESSION_SECRET }),
    passport.initialize(),
    passport.session()
  ],
  view_path: path.join(__dirname, 'views'),
  static_dir: path.join(__dirname, 'public')
});

const server = ezc.createServer(app);
server.start();

Keywords

express

FAQs

Package last updated on 20 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts