@novice1/app - v0.3.4

@novice1/app

Create Express applications.

$ npm install @novice1/app
const routing = require('@novice1/routing'),
{ FrameworkApp } = require('@novice1/app');

// Router
const router = routing().get('/', (req, res) => {
// ...
}).put('/', (req, res) => {
// ...
});

// FrameworkApp
const app = new FrameworkApp({
framework: {
// middlewares
middlewares: [
(req, res, next) => {
next();
}
],
// authorization middlewares
auth: [
(req, res, next) => {
next();
}
],
// validation middlewares
validators: [
(req, res, next) => {
next();
}
]
},
// routers
routers: [
router
]
});

// http.Server
const server = app.listen(8000, '0.0.0.0', () => {
console.log('Application started ...');
console.log(app.meta)
});

Concatenate current application options with new options.

app.addOptions({
// add more routers
routers: [router]
});
app.addRouters([router]);
app.get({
path: '/index',
name: 'Home',
tags: ['Index']
}, function homepage(req, res) {
// ...
});

app.put('/add', (req, res) => {
// ...
});

app.use((err, req, res) => {
// ...
});
const lazyRouter = app.lazyrouter();
lazyRouter.get({
path: '/index',
name: 'Home',
tags: ['Index']
}, function homepage(req, res) {
// ...
});

lazyRouter.put('/add', (req, res) => {
// ...
});

lazyRouter.use((err, req, res) => {
// ...
});
const httpServerOptions = {};

const server = app.build(httpServerOptions);
server.listen(8000, '0.0.0.0', () => {
console.log('Application started ...');
console.log(app.meta)
});
const https = require('https');
const httpsServerOptions = {};

const server = app.build(httpsServerOptions, https);
server.listen(8000);