Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

async-app

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-app - npm Package Compare versions

Comparing version 4.7.0 to 4.8.0

2

dist/analyze.d.ts

@@ -17,5 +17,5 @@ import { App, Decorator, Entities, Method } from './types';

}
declare const analyzeApp: <TEntities extends Entities, TSchema>(returnYourAppFromThisFn: () => App<TEntities, TSchema>) => Route<TSchema>[];
declare const analyzeApp: <TEntities extends Entities, TSchema>(getApp: () => App<TEntities, TSchema>) => Route<TSchema>[];
export declare const analyzeFile: (absolutePathToApp: string) => Route<{}>[];
export declare const removeScope: <TSchema>(schema: TSchema) => TSchema;
export default analyzeApp;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const lodash_1 = require("lodash");
const create_app_1 = require("./create-app");
const types_1 = require("./types");

@@ -43,11 +44,23 @@ const Module = require('module');

constructor() {
// express methods
this.all = noop; // All method is not supported in this stub
this.disable = noop;
this.disabled = noop;
this.enable = noop;
this.enabled = noop;
this.engine = noop;
this.listen = noop;
this.METHOD = noop;
this.options = noop;
this.param = noop;
this.path = noop;
this.render = noop;
this.route = noop;
this.set = noop;
// non-express methods
this.permissions = [];
this.response = { end: noop };
this.responseSchema = undefined;
this.routes = [];
this.schema = undefined;
this.responseSchema = undefined;
this.set = noop;
this.delete = this.generateRoute('delete');

@@ -113,21 +126,34 @@ this.get = this.generateRoute('get');

}
const originalAsyncApp = require('async-app');
originalAsyncApp.default = () => new MetadataApp();
// Monkeypatch require to return an `App` instead of an express instance.
const originalRequire = Module.prototype.require;
Module.prototype.require = function require(path) {
if (path === 'express') {
const ctor = () => new MetadataApp();
Object.assign(ctor, {
default: ctor,
static: noop,
});
return ctor;
// For backward compatibility, we need to monkeypatch the `require` function
// This should be removed in the next major version release of async-app
function deprecatedExpressMonkeypatch() {
const originalRequire = Module.prototype.require;
Module.prototype.require = function require(path) {
// Monkeypatch require to return an `App` instead of an express instance.
if (path === 'express') {
const ctor = () => new MetadataApp();
Object.assign(ctor, {
default: ctor,
static: noop,
});
return ctor;
}
// For all the other modules, we just don't patch anything.
return originalRequire.apply(this, arguments); // tslint:disable-line
};
}
const analyzeApp = (getApp) => {
try {
// TODO: remove this in the future
deprecatedExpressMonkeypatch();
// We setup the stub
create_app_1.setProvider(() => new MetadataApp());
// and then analyze the app by getting it's routes.
const app = getApp();
return app.getRoutes();
}
return originalRequire.apply(this, arguments); // tslint:disable-line
finally {
create_app_1.resetProvider();
}
};
const analyzeApp = (returnYourAppFromThisFn) => {
const app = returnYourAppFromThisFn();
return app.getRoutes();
};
exports.analyzeFile = (absolutePathToApp) => analyzeApp(() => require(absolutePathToApp));

@@ -134,0 +160,0 @@ exports.removeScope = (schema) => lodash_1.omit(schema, '$scope');

import { App, Entities, Opts } from './types';
export declare const createApp: <TEntities extends Entities = Entities, TSchema = {}>(opts?: Opts<TEntities, TSchema> | undefined) => App<TEntities, TSchema>;
declare type AppProvider<TEntities extends Entities = Entities, TSchema = {}> = (opts?: Opts<TEntities, TSchema>) => App<TEntities, TSchema>;
export declare const resetProvider: () => AppProvider<Entities, {}>;
export declare const setProvider: (provider: AppProvider<any, any>) => AppProvider<any, any>;
export declare const createApp: <TEntities extends Entities = Entities, TSchema = {}>(opts?: Opts<TEntities, TSchema> | undefined) => App<any, any>;
export default createApp;

@@ -40,3 +40,3 @@ "use strict";

];
exports.createApp = (opts) => {
const asyncAppProvider = (opts) => {
const app = express_1.default();

@@ -61,3 +61,7 @@ const converters = opts && opts.converters || [];

};
let appProvider = asyncAppProvider;
exports.resetProvider = () => (appProvider = asyncAppProvider);
exports.setProvider = (provider) => (appProvider = provider);
exports.createApp = (opts) => appProvider(opts);
exports.default = exports.createApp;
//# sourceMappingURL=create-app.js.map
{
"name": "async-app",
"version": "4.7.0",
"version": "4.8.0",
"description": "An express wrapper for handling async middlewares, order middlewares, schema validator, and other stuff",

@@ -5,0 +5,0 @@ "type": "commonjs",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc