aboutsummaryrefslogtreecommitdiff
path: root/node_modules/app-builder
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/app-builder')
-rw-r--r--node_modules/app-builder/LICENSE21
-rw-r--r--node_modules/app-builder/README.md45
-rw-r--r--node_modules/app-builder/lib/app-builder.d.ts8
-rw-r--r--node_modules/app-builder/lib/app-builder.js29
-rw-r--r--node_modules/app-builder/lib/compose.d.ts13
-rw-r--r--node_modules/app-builder/lib/compose.js48
-rw-r--r--node_modules/app-builder/lib/test.spec.d.ts1
-rw-r--r--node_modules/app-builder/package.json93
8 files changed, 258 insertions, 0 deletions
diff --git a/node_modules/app-builder/LICENSE b/node_modules/app-builder/LICENSE
new file mode 100644
index 0000000..4868875
--- /dev/null
+++ b/node_modules/app-builder/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2015-20 Caleb Boyd
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/node_modules/app-builder/README.md b/node_modules/app-builder/README.md
new file mode 100644
index 0000000..a12feab
--- /dev/null
+++ b/node_modules/app-builder/README.md
@@ -0,0 +1,45 @@
+# app-builder
+
+[![Actions Status](https://github.com/calebboyd/app-builder/workflows/app-builder-ci/badge.svg)](https://github.com/calebboyd/app-builder/actions)
+
+Create composable promise based middleware pipelines, using the "onion" middleware model.
+
+## Install:
+
+`npm install app-builder`
+
+## Example
+
+```javascript
+import { compose } from 'app-builder'
+
+const app = compose([
+ async function (ctx, next) {
+ ctx.value += 1
+ await next()
+ ctx.value += 4
+ },
+ async function (ctx, next) {
+ ctx.value += 2
+ await next()
+ ctx.value += 3
+ }
+]);
+
+const context = { value: '' }
+app(context).then(() => console.log(context.value)) // --> '1234'
+
+```
+
+All composed functions are also valid middleware functions.
+
+```javascript
+const superApp = compose(
+ async function (ctx, next) {
+ ctx.value += 'first'
+ await next()
+ ctx.value += 'last'
+ },
+ app
+)
+```
diff --git a/node_modules/app-builder/lib/app-builder.d.ts b/node_modules/app-builder/lib/app-builder.d.ts
new file mode 100644
index 0000000..e475725
--- /dev/null
+++ b/node_modules/app-builder/lib/app-builder.d.ts
@@ -0,0 +1,8 @@
+import { compose, Middleware, ContinuationMiddleware, functionList } from './compose';
+export declare class AppBuilder<T = any> {
+ private middleware;
+ build(): ContinuationMiddleware<T>;
+ use(mw: Middleware<T>): this;
+}
+export default function createAppBuilder<T = any>(): AppBuilder<T>;
+export { compose, functionList, Middleware, ContinuationMiddleware };
diff --git a/node_modules/app-builder/lib/app-builder.js b/node_modules/app-builder/lib/app-builder.js
new file mode 100644
index 0000000..c2c0cd4
--- /dev/null
+++ b/node_modules/app-builder/lib/app-builder.js
@@ -0,0 +1,29 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+const compose_1 = require("./compose");
+exports.compose = compose_1.compose;
+exports.functionList = compose_1.functionList;
+class AppBuilder {
+ constructor() {
+ this.middleware = [];
+ }
+ build() {
+ if (!this.middleware.length) {
+ throw new Error('Usage error: must have at least one middleware');
+ }
+ return compose_1.compose(this.middleware);
+ }
+ use(mw) {
+ if ('function' !== typeof mw) {
+ throw new TypeError(`${mw}, must be a middleware function accpeting (context, next) arguments`);
+ }
+ this.middleware.push(mw);
+ return this;
+ }
+}
+exports.AppBuilder = AppBuilder;
+function createAppBuilder() {
+ return new AppBuilder();
+}
+exports.default = createAppBuilder;
+//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBwLWJ1aWxkZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvYXBwLWJ1aWxkZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSx1Q0FBcUY7QUF5QjVFLGtCQXpCQSxpQkFBTyxDQXlCQTtBQUFFLHVCQXpCb0Msc0JBQVksQ0F5QnBDO0FBdkI5QixNQUFhLFVBQVU7SUFBdkI7UUFDVSxlQUFVLEdBQXlCLEVBQUUsQ0FBQTtJQWdCL0MsQ0FBQztJQWRDLEtBQUs7UUFDSCxJQUFJLENBQUMsSUFBSSxDQUFDLFVBQVUsQ0FBQyxNQUFNLEVBQUU7WUFDM0IsTUFBTSxJQUFJLEtBQUssQ0FBQyxnREFBZ0QsQ0FBQyxDQUFBO1NBQ2xFO1FBQ0QsT0FBTyxpQkFBTyxDQUFDLElBQUksQ0FBQyxVQUFVLENBQUMsQ0FBQTtJQUNqQyxDQUFDO0lBRUQsR0FBRyxDQUFDLEVBQWlCO1FBQ25CLElBQUksVUFBVSxLQUFLLE9BQU8sRUFBRSxFQUFFO1lBQzVCLE1BQU0sSUFBSSxTQUFTLENBQUMsR0FBRyxFQUFFLHFFQUFxRSxDQUFDLENBQUE7U0FDaEc7UUFDRCxJQUFJLENBQUMsVUFBVSxDQUFDLElBQUksQ0FBQyxFQUFFLENBQUMsQ0FBQTtRQUN4QixPQUFPLElBQUksQ0FBQTtJQUNiLENBQUM7Q0FDRjtBQWpCRCxnQ0FpQkM7QUFFRCxTQUF3QixnQkFBZ0I7SUFDdEMsT0FBTyxJQUFJLFVBQVUsRUFBSyxDQUFBO0FBQzVCLENBQUM7QUFGRCxtQ0FFQyJ9 \ No newline at end of file
diff --git a/node_modules/app-builder/lib/compose.d.ts b/node_modules/app-builder/lib/compose.d.ts
new file mode 100644
index 0000000..7c848af
--- /dev/null
+++ b/node_modules/app-builder/lib/compose.d.ts
@@ -0,0 +1,13 @@
+export interface Middleware<T> {
+ (context: T, next: ContinuationMiddleware<T>): any;
+}
+export interface ContinuationMiddleware<T> {
+ (context?: T, next?: Middleware<T>): any;
+}
+export declare function functionList<T = any>(list: Function | Function[], ...args: any[]): Middleware<T>[];
+/**
+ * Create a function to invoke all passed middleware functions
+ * with a single argument <T>context
+ * @param middleware
+ */
+export declare function compose<T = any>(...middleware: (Middleware<T> | Middleware<T>[])[]): ContinuationMiddleware<T>;
diff --git a/node_modules/app-builder/lib/compose.js b/node_modules/app-builder/lib/compose.js
new file mode 100644
index 0000000..e615d57
--- /dev/null
+++ b/node_modules/app-builder/lib/compose.js
@@ -0,0 +1,48 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+const flatten = (values) => [].concat(...values), noop = function noop() {
+ return Promise.resolve();
+};
+function throwIfHasBeenCalled(fn) {
+ if (fn.__appbuildercalled) {
+ throw new Error('Cannot call next more than once');
+ }
+ return (fn.__appbuildercalled = true);
+}
+function tryInvokeMiddleware(context, middleware, next = noop) {
+ try {
+ return Promise.resolve(middleware ? middleware(context, next) : context);
+ }
+ catch (error) {
+ return Promise.reject(error);
+ }
+}
+function functionList(list, ...args) {
+ const arrayList = Symbol.iterator in list ? Array.from(list) : [list];
+ return arrayList.map((x) => {
+ return (_, next) => Promise.resolve(x(...args)).then(next);
+ });
+}
+exports.functionList = functionList;
+/**
+ * Create a function to invoke all passed middleware functions
+ * with a single argument <T>context
+ * @param middleware
+ */
+function compose(...middleware) {
+ return flatten(middleware)
+ .filter((x) => {
+ if ('function' !== typeof x) {
+ throw new TypeError(`${x}, must be a middleware function accpeting (context, next) arguments`);
+ }
+ return x;
+ })
+ .reduceRight((composed, mw) => {
+ return function (context, nextFn) {
+ const next = () => throwIfHasBeenCalled(next) && composed(context, nextFn);
+ return tryInvokeMiddleware(context, mw, next);
+ };
+ }, tryInvokeMiddleware);
+}
+exports.compose = compose;
+//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tcG9zZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9jb21wb3NlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBT0EsTUFBTSxPQUFPLEdBQUcsQ0FBSSxNQUEyQixFQUFFLEVBQUUsQ0FBRSxFQUFVLENBQUMsTUFBTSxDQUFDLEdBQUcsTUFBTSxDQUFRLEVBQ3RGLElBQUksR0FBRyxTQUFTLElBQUk7SUFDbEIsT0FBTyxPQUFPLENBQUMsT0FBTyxFQUFFLENBQUE7QUFDMUIsQ0FBQyxDQUFBO0FBRUgsU0FBUyxvQkFBb0IsQ0FBQyxFQUFPO0lBQ25DLElBQUksRUFBRSxDQUFDLGtCQUFrQixFQUFFO1FBQ3pCLE1BQU0sSUFBSSxLQUFLLENBQUMsaUNBQWlDLENBQUMsQ0FBQTtLQUNuRDtJQUNELE9BQU8sQ0FBQyxFQUFFLENBQUMsa0JBQWtCLEdBQUcsSUFBSSxDQUFDLENBQUE7QUFDdkMsQ0FBQztBQUVELFNBQVMsbUJBQW1CLENBQUksT0FBVSxFQUFFLFVBQXlCLEVBQUUsT0FBa0MsSUFBSTtJQUMzRyxJQUFJO1FBQ0YsT0FBTyxPQUFPLENBQUMsT0FBTyxDQUFDLFVBQVUsQ0FBQyxDQUFDLENBQUMsVUFBVSxDQUFDLE9BQU8sRUFBRSxJQUFJLENBQUMsQ0FBQyxDQUFDLENBQUMsT0FBTyxDQUFDLENBQUE7S0FDekU7SUFBQyxPQUFPLEtBQUssRUFBRTtRQUNkLE9BQU8sT0FBTyxDQUFDLE1BQU0sQ0FBQyxLQUFLLENBQ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0FBQyxJQUFJLFFBQVEsQ0FBQyxPQUFPLEVBQUUsTUFBTSxDQUFDLENBQUE7WUFDMUUsT0FBTyxtQkFBbUIsQ0FBQyxPQUFPLEVBQUUsRUFBRSxFQUFFLElBQUksQ0FBQyxDQUFBO1FBQy9DLENBQUMsQ0FBQTtJQUNILENBQUMsRUFBRSxtQkFBbUIsQ0FBOEIsQ0FBQTtBQUN4RCxDQUFDO0FBZEQsMEJBY0MifQ== \ No newline at end of file
diff --git a/node_modules/app-builder/lib/test.spec.d.ts b/node_modules/app-builder/lib/test.spec.d.ts
new file mode 100644
index 0000000..cb0ff5c
--- /dev/null
+++ b/node_modules/app-builder/lib/test.spec.d.ts
@@ -0,0 +1 @@
+export {};
diff --git a/node_modules/app-builder/package.json b/node_modules/app-builder/package.json
new file mode 100644
index 0000000..07ed1d8
--- /dev/null
+++ b/node_modules/app-builder/package.json
@@ -0,0 +1,93 @@
+{
+ "name": "app-builder",
+ "version": "6.2.2",
+ "description": "Promise based composable functions for middleware",
+ "main": "./lib/app-builder.js",
+ "typings": "./lib/app-builder.d.ts",
+ "author": "Caleb Boyd (https://github.com/calebboyd)",
+ "license": "MIT",
+ "bugs": {
+ "url": "https://github.com/calebboyd/app-builder/issues"
+ },
+ "homepage": "https://github.com/calebboyd/app-builder",
+ "files": [
+ "lib",
+ "!**/*.spec.js"
+ ],
+ "scripts": {
+ "lint": "eslint \"src/**/*\" --fix",
+ "build": "npm run lint && tsc",
+ "prepublish": "npm run test",
+ "watch:typescript": "tsc -w",
+ "watch:test": "jest --watchAll",
+ "watch": "npm run build && concurrently -k \"npm:watch:typescript\" \"npm:watch:test\" -c blue,green",
+ "test": "npm run build && jest --passWithNoTests"
+ },
+ "jest": {
+ "testRegex": ".*?(\\.spec).js",
+ "watchPathIgnorePatterns": [
+ "\\.ts$"
+ ]
+ },
+ "prettier": {
+ "parser": "typescript",
+ "semi": false,
+ "singleQuote": true,
+ "printWidth": 120
+ },
+ "eslintConfig": {
+ "parser": "@typescript-eslint/parser",
+ "extends": [
+ "plugin:@typescript-eslint/recommended",
+ "prettier/@typescript-eslint",
+ "plugin:prettier/recommended"
+ ],
+ "parserOptions": {
+ "project": "./tsconfig.json"
+ },
+ "overrides": [
+ {
+ "files": [
+ "*.spec.ts"
+ ],
+ "env": {
+ "jest": true
+ }
+ }
+ ],
+ "rules": {
+ "@typescript-eslint/explicit-function-return-type": 0,
+ "@typescript-eslint/no-explicit-any": 0,
+ "@typescript-eslint/no-non-null-assertion": 0,
+ "@typescript-eslint/no-var-requires": 0,
+ "@typescript-eslint/no-use-before-define": 0
+ }
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/calebboyd/app-builder.git"
+ },
+ "keywords": [
+ "middleware",
+ "functional",
+ "composable",
+ "composition",
+ "pipeline",
+ "onion",
+ "async",
+ "compose"
+ ],
+ "devDependencies": {
+ "@types/jest": "^25.2.1",
+ "@typescript-eslint/eslint-plugin": "^2.29.0",
+ "@typescript-eslint/parser": "^2.29.0",
+ "concurrently": "^5.1.0",
+ "eslint": "^6.8.0",
+ "eslint-config-prettier": "~6.11.0",
+ "eslint-plugin-prettier": "^3.1.3",
+ "eslint-watch": "^6.0.1",
+ "jest": "^25.4.0",
+ "prettier": "^2.0.5",
+ "typescript": "^3.8.3"
+ }
+}