@keystonejs-contrib/app-express
v0.2.1
Published
Provides functionality similar to Keystone 4 views.
Downloads
5
Readme
section: packages title: Express App
Express App
This package helps create custom middleware using express config
initialize
Constructor
new ExpressApp({
app = express(),
...expressOptions
}, configureExpress = app => {})
Paremeters
app
: used for providing custom express instance.expressOptions
: all those things can be set usingapp.set(key, value)
configureExpress
: function argument which will be called similar toconfigureExpress
method.
expressOptions
can be skipped altogether and onlyconfigureExpress
may be used
example:
const customApp = new ExpressApp({
views: './templates',
'view engine': 'pug',
},
app => {
app.use(bodyParser.urlencoded({ extended: true }));
someOtherMethod(keystone, app);
}
);
// OR when skipping expressOptions
new ExpressApp(app => {
app.set(...);
app.use(...);
app.get(...);
app.post(...);
})
Methods
configureExpress(fn)
useful for configuring the express instance for more settings.
const customApp = new ExpressApp({....config});
customApp.configureExpress(app => {
app.use(....);
someOthermethod(app);
})
use(middleware)
proxy for app.use
method for express instance wrapped inside
const customApp = new ExpressApp({....config});
customApp.use(bodyParser());
set(key, value)
proxy for app.set
method for express instance wrapped inside
const customApp = new ExpressApp({....config});
customApp.set('my option', 'my value');