Socket
Socket
Sign inDemoInstall

@foal/core

Package Overview
Dependencies
86
Maintainers
1
Versions
96
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.1 to 1.2.0

19

lib/express/create-app.d.ts

@@ -7,2 +7,3 @@ import * as express from 'express';

interface ExpressOptions {
expressInstance?: ExpressApplication;
preMiddlewares?: (express.RequestHandler | express.ErrorRequestHandler)[];

@@ -18,2 +19,4 @@ postMiddlewares?: (express.RequestHandler | express.ErrorRequestHandler)[];

* Express middlewares.
* @param {ExpressApplication} [expressInstanceOrOptions.expressInstance] - Express instance to be used as base for the
* returned application.
* @param {(express.RequestHandler | express.ErrorRequestHandler)[]} [expressInstanceOrOptions.preMiddlewares] Express

@@ -23,5 +26,19 @@ * middlewares to be executed before the controllers and hooks.

* middlewares to be executed after the controllers and hooks, but before the 500 or 404 handler get called.
* @returns The express application.
* @returns {ExpressApplication} The express application.
*/
export declare function createApp(rootControllerClass: Class, expressInstanceOrOptions?: ExpressApplication | ExpressOptions): ExpressApplication;
/**
* Create an Express application from the root controller and call its "init" method if it exists.
*
* @export
* @param {Class} rootControllerClass - The root controller, usually called `AppController` and located in `src/app`.
* @param {(ExpressApplication|ExpressOptions)} [expressInstanceOrOptions] - Express instance or options containaining
* Express middlewares.
* @param {(express.RequestHandler | express.ErrorRequestHandler)[]} [expressInstanceOrOptions.preMiddlewares] Express
* middlewares to be executed before the controllers and hooks.
* @param {(express.RequestHandler | express.ErrorRequestHandler)[]} [expressInstanceOrOptions.postMiddlewares] Express
* middlewares to be executed after the controllers and hooks, but before the 500 or 404 handler get called.
* @returns {Promise<ExpressApplication>} The express application.
*/
export declare function createAndInitApp(rootControllerClass: Class, expressInstanceOrOptions?: ExpressApplication | ExpressOptions): Promise<ExpressApplication>;
export {};

@@ -20,2 +20,4 @@ "use strict";

* Express middlewares.
* @param {ExpressApplication} [expressInstanceOrOptions.expressInstance] - Express instance to be used as base for the
* returned application.
* @param {(express.RequestHandler | express.ErrorRequestHandler)[]} [expressInstanceOrOptions.preMiddlewares] Express

@@ -25,3 +27,3 @@ * middlewares to be executed before the controllers and hooks.

* middlewares to be executed after the controllers and hooks, but before the 500 or 404 handler get called.
* @returns The express application.
* @returns {ExpressApplication} The express application.
*/

@@ -34,2 +36,5 @@ function createApp(rootControllerClass, expressInstanceOrOptions) {

if (expressInstanceOrOptions && typeof expressInstanceOrOptions === 'object') {
if (expressInstanceOrOptions.expressInstance) {
app = expressInstanceOrOptions.expressInstance;
}
for (const middleware of expressInstanceOrOptions.preMiddlewares || []) {

@@ -107,1 +112,23 @@ app.use(middleware);

exports.createApp = createApp;
/**
* Create an Express application from the root controller and call its "init" method if it exists.
*
* @export
* @param {Class} rootControllerClass - The root controller, usually called `AppController` and located in `src/app`.
* @param {(ExpressApplication|ExpressOptions)} [expressInstanceOrOptions] - Express instance or options containaining
* Express middlewares.
* @param {(express.RequestHandler | express.ErrorRequestHandler)[]} [expressInstanceOrOptions.preMiddlewares] Express
* middlewares to be executed before the controllers and hooks.
* @param {(express.RequestHandler | express.ErrorRequestHandler)[]} [expressInstanceOrOptions.postMiddlewares] Express
* middlewares to be executed after the controllers and hooks, but before the 500 or 404 handler get called.
* @returns {Promise<ExpressApplication>} The express application.
*/
async function createAndInitApp(rootControllerClass, expressInstanceOrOptions) {
const app = createApp(rootControllerClass, expressInstanceOrOptions);
const controller = app.foal.services.get(rootControllerClass);
if (controller.init) {
await controller.init();
}
return app;
}
exports.createAndInitApp = createAndInitApp;

2

lib/express/index.d.ts

@@ -1,1 +0,1 @@

export { createApp } from './create-app';
export { createApp, createAndInitApp } from './create-app';

@@ -5,1 +5,2 @@ "use strict";

exports.createApp = create_app_1.createApp;
exports.createAndInitApp = create_app_1.createAndInitApp;
{
"name": "@foal/core",
"version": "1.1.1",
"version": "1.2.0",
"description": "High level web framework to create enterprise-grade Node.JS applications.",

@@ -89,3 +89,3 @@ "main": "./lib/index.js",

"devDependencies": {
"@foal/ejs": "^1.1.1",
"@foal/ejs": "^1.2.0",
"@types/mocha": "^2.2.43",

@@ -111,3 +111,3 @@ "@types/node": "^10.1.2",

},
"gitHead": "787c440d4c8bec0e4d7d9897aca8a58f69778d2d"
"gitHead": "e910c717ff6c6c62de715087426cac585a213cb0"
}

@@ -37,2 +37,5 @@ <p align="center">

</a>
<a href="https://discord.gg/QUrJv98">
<img src="https://img.shields.io/badge/Chat-Discord-blue.svg" alt="2FA">
</a>
</p>

@@ -39,0 +42,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc