Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

core.io-express-server

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

core.io-express-server

core.io Express server module

latest
Source
npmnpm
Version
0.1.2
Version published
Maintainers
1
Created
Source

core.io-express

Express server module.

Config

  • port:
    • process.env.PORT
    • process.env.NODE_APP_PORT
    • 3000
  • basepath: Used to create the path to views and public.
  • locals: It will be made available to all requests through app.locals.
  • routeLocas: Specify locals per route. Example:
routeLocals: {
    '/admin': {
        layout: require('path').resolve('./modules/dashboard/views/layout.ejs')
    }
}

NOTE: Good idea to name all functions passed to app.use or router.use. Makes it easier to debug, which is true in general, since otherwise you would see <anonymous> as the output.

TODO

  • Handle unique assets, like favicon. config: { favicon: <ABSOLUTE_PATH>}
  • Provide a way to override layout for error.ejs
  • Default app: take config options
    • merge middleware
  • Asset pipeline:

Final Error Handler

For API calls:

res.send({
    success: false,
    message: error.message
});

Custom Error views

If our sub-app has the following view structure:

.
├── views
│   ├── error-layout.ejs
│   ├── 401.ejs
│   └── 403.ejs

The error view will be rendered with the following locals:

let locals = {
    isErrorView: true,
    status: status,
    message: err.message,
    error: err
};

Keywords

core.io

FAQs

Package last updated on 19 Aug 2018

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