@etohq/framework 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build-tools/compiler.d.ts.map +1 -1
- package/dist/build-tools/compiler.js +38 -32
- package/dist/build-tools/compiler.js.map +1 -1
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js +1 -0
- package/dist/config/config.js.map +1 -1
- package/dist/config/loader.d.ts +7 -2
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/loader.js +28 -6
- package/dist/config/loader.js.map +1 -1
- package/dist/config/types.d.ts +4 -166
- package/dist/config/types.d.ts.map +1 -1
- package/dist/context/index.d.ts +6 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +50 -0
- package/dist/context/index.js.map +1 -0
- package/dist/error/index.d.ts +205 -0
- package/dist/error/index.d.ts.map +1 -0
- package/dist/error/index.js +273 -0
- package/dist/error/index.js.map +1 -0
- package/dist/eto-app-loader.d.ts +6 -4
- package/dist/eto-app-loader.d.ts.map +1 -1
- package/dist/eto-app-loader.js +53 -11
- package/dist/eto-app-loader.js.map +1 -1
- package/dist/eto.d.ts +39 -0
- package/dist/eto.d.ts.map +1 -0
- package/dist/eto.js +148 -0
- package/dist/eto.js.map +1 -0
- package/dist/feature-flags/feature-flag-loader.d.ts +4 -3
- package/dist/feature-flags/feature-flag-loader.d.ts.map +1 -1
- package/dist/feature-flags/feature-flag-loader.js +36 -25
- package/dist/feature-flags/feature-flag-loader.js.map +1 -1
- package/dist/http/encore.d.ts +191 -0
- package/dist/http/encore.d.ts.map +1 -0
- package/dist/http/encore.js +3 -0
- package/dist/http/encore.js.map +1 -0
- package/dist/http/index.d.ts +1 -3
- package/dist/http/index.d.ts.map +1 -1
- package/dist/http/index.js +1 -3
- package/dist/http/index.js.map +1 -1
- package/dist/http/middlewares/apply-default-filters.d.ts +2 -2
- package/dist/http/middlewares/apply-default-filters.d.ts.map +1 -1
- package/dist/http/middlewares/apply-default-filters.js +8 -6
- package/dist/http/middlewares/apply-default-filters.js.map +1 -1
- package/dist/http/middlewares/apply-params-as-filters.d.ts +2 -2
- package/dist/http/middlewares/apply-params-as-filters.d.ts.map +1 -1
- package/dist/http/middlewares/apply-params-as-filters.js +7 -4
- package/dist/http/middlewares/apply-params-as-filters.js.map +1 -1
- package/dist/http/middlewares/authenticate-middleware.d.ts +2 -2
- package/dist/http/middlewares/authenticate-middleware.d.ts.map +1 -1
- package/dist/http/middlewares/authenticate-middleware.js +25 -22
- package/dist/http/middlewares/authenticate-middleware.js.map +1 -1
- package/dist/http/middlewares/clear-filters-by-key.d.ts +2 -2
- package/dist/http/middlewares/clear-filters-by-key.d.ts.map +1 -1
- package/dist/http/middlewares/clear-filters-by-key.js +2 -2
- package/dist/http/middlewares/clear-filters-by-key.js.map +1 -1
- package/dist/http/middlewares/ensure-publishable-api-key.d.ts +2 -2
- package/dist/http/middlewares/ensure-publishable-api-key.d.ts.map +1 -1
- package/dist/http/middlewares/ensure-publishable-api-key.js +7 -5
- package/dist/http/middlewares/ensure-publishable-api-key.js.map +1 -1
- package/dist/http/middlewares/error-handler.d.ts +2 -3
- package/dist/http/middlewares/error-handler.d.ts.map +1 -1
- package/dist/http/middlewares/error-handler.js +6 -3
- package/dist/http/middlewares/error-handler.js.map +1 -1
- package/dist/http/middlewares/set-context.d.ts +2 -2
- package/dist/http/middlewares/set-context.d.ts.map +1 -1
- package/dist/http/middlewares/set-context.js +4 -4
- package/dist/http/middlewares/set-context.js.map +1 -1
- package/dist/http/types.d.ts +41 -31
- package/dist/http/types.d.ts.map +1 -1
- package/dist/http/types.js.map +1 -1
- package/dist/http/utils/http-compression.d.ts +1 -4
- package/dist/http/utils/http-compression.d.ts.map +1 -1
- package/dist/http/utils/http-compression.js +35 -30
- package/dist/http/utils/http-compression.js.map +1 -1
- package/dist/http/utils/maybe-apply-link-filter.d.ts +2 -2
- package/dist/http/utils/maybe-apply-link-filter.d.ts.map +1 -1
- package/dist/http/utils/maybe-apply-link-filter.js +7 -6
- package/dist/http/utils/maybe-apply-link-filter.js.map +1 -1
- package/dist/http/utils/refetch-entities.d.ts +2 -2
- package/dist/http/utils/refetch-entities.d.ts.map +1 -1
- package/dist/http/utils/refetch-entities.js.map +1 -1
- package/dist/http/utils/unless-path.d.ts +4 -4
- package/dist/http/utils/unless-path.d.ts.map +1 -1
- package/dist/http/utils/unless-path.js +20 -11
- package/dist/http/utils/unless-path.js.map +1 -1
- package/dist/http/utils/validate-body.d.ts +1 -4
- package/dist/http/utils/validate-body.d.ts.map +1 -1
- package/dist/http/utils/validate-body.js +31 -20
- package/dist/http/utils/validate-body.js.map +1 -1
- package/dist/http/utils/validate-query.d.ts +9 -4
- package/dist/http/utils/validate-query.d.ts.map +1 -1
- package/dist/http/utils/validate-query.js +63 -20
- package/dist/http/utils/validate-query.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/jobs/job-loader.d.ts +12 -4
- package/dist/jobs/job-loader.d.ts.map +1 -1
- package/dist/jobs/job-loader.js +56 -38
- package/dist/jobs/job-loader.js.map +1 -1
- package/dist/link-modules-sdk/index.d.ts +2 -0
- package/dist/link-modules-sdk/index.d.ts.map +1 -0
- package/dist/link-modules-sdk/index.js +18 -0
- package/dist/link-modules-sdk/index.js.map +1 -0
- package/dist/loader.d.ts +24 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +104 -0
- package/dist/loader.js.map +1 -0
- package/dist/mikro-orm-cli/bin.js +0 -0
- package/dist/subscribers/subscriber-loader.d.ts +15 -1
- package/dist/subscribers/subscriber-loader.d.ts.map +1 -1
- package/dist/subscribers/subscriber-loader.js +44 -17
- package/dist/subscribers/subscriber-loader.js.map +1 -1
- package/dist/types/container.d.ts +2 -23
- package/dist/types/container.d.ts.map +1 -1
- package/dist/zod/zod-helpers.js +1 -1
- package/dist/zod/zod-helpers.js.map +1 -1
- package/package.json +12 -9
- package/dist/http/express-loader.d.ts +0 -8
- package/dist/http/express-loader.d.ts.map +0 -1
- package/dist/http/express-loader.js +0 -85
- package/dist/http/express-loader.js.map +0 -1
- package/dist/http/router.d.ts +0 -100
- package/dist/http/router.d.ts.map +0 -1
- package/dist/http/router.js +0 -764
- package/dist/http/router.js.map +0 -1
- package/dist/http/utils/define-middlewares.d.ts +0 -18
- package/dist/http/utils/define-middlewares.d.ts.map +0 -1
- package/dist/http/utils/define-middlewares.js +0 -40
- package/dist/http/utils/define-middlewares.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etohq/framework",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Framework",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -27,11 +27,13 @@
|
|
|
27
27
|
"./feature-flags": "./dist/feature-flags/index.js",
|
|
28
28
|
"./utils": "./dist/utils/index.js",
|
|
29
29
|
"./types": "./dist/types/index.js",
|
|
30
|
+
"./types/http": "./dist/types/http/index.js",
|
|
30
31
|
"./build-tools": "./dist/build-tools/index.js",
|
|
31
32
|
"./orchestration": "./dist/orchestration/index.js",
|
|
32
33
|
"./workflows-sdk": "./dist/workflows-sdk/index.js",
|
|
33
34
|
"./workflows-sdk/composer": "./dist/workflows-sdk/composer.js",
|
|
34
|
-
"./modules-sdk": "./dist/modules-sdk/index.js"
|
|
35
|
+
"./modules-sdk": "./dist/modules-sdk/index.js",
|
|
36
|
+
"./link-modules-sdk": "./dist/link-modules-sdk/index.js"
|
|
35
37
|
},
|
|
36
38
|
"engines": {
|
|
37
39
|
"node": ">=20"
|
|
@@ -53,7 +55,7 @@
|
|
|
53
55
|
"test": "jest --runInBand --bail --passWithNoTests --forceExit"
|
|
54
56
|
},
|
|
55
57
|
"devDependencies": {
|
|
56
|
-
"@etohq/cli": "^1.
|
|
58
|
+
"@etohq/cli": "^1.2.0",
|
|
57
59
|
"@mikro-orm/cli": "5.9.7",
|
|
58
60
|
"@mikro-orm/core": "5.9.7",
|
|
59
61
|
"@mikro-orm/knex": "5.9.7",
|
|
@@ -74,11 +76,12 @@
|
|
|
74
76
|
"vite": "^5.2.11"
|
|
75
77
|
},
|
|
76
78
|
"dependencies": {
|
|
77
|
-
"@etohq/modules-sdk": "^1.
|
|
78
|
-
"@etohq/
|
|
79
|
-
"@etohq/
|
|
80
|
-
"@etohq/
|
|
81
|
-
"@etohq/
|
|
79
|
+
"@etohq/link-modules-sdk": "^1.2.0",
|
|
80
|
+
"@etohq/modules-sdk": "^1.2.0",
|
|
81
|
+
"@etohq/orchestration": "^1.2.0",
|
|
82
|
+
"@etohq/types": "^1.2.0",
|
|
83
|
+
"@etohq/utils": "^1.2.0",
|
|
84
|
+
"@etohq/workflows-sdk": "^1.2.0",
|
|
82
85
|
"@jercle/yargonaut": "^1.1.5",
|
|
83
86
|
"@opentelemetry/api": "^1.9.0",
|
|
84
87
|
"@types/express": "^4.17.17",
|
|
@@ -95,7 +98,7 @@
|
|
|
95
98
|
"zod": "3.22.4"
|
|
96
99
|
},
|
|
97
100
|
"peerDependencies": {
|
|
98
|
-
"@etohq/cli": "^1.
|
|
101
|
+
"@etohq/cli": "^1.1.0",
|
|
99
102
|
"@mikro-orm/cli": "5.9.7",
|
|
100
103
|
"@mikro-orm/core": "5.9.7",
|
|
101
104
|
"@mikro-orm/knex": "5.9.7",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"express-loader.d.ts","sourceRoot":"","sources":["../../src/http/express-loader.ts"],"names":[],"mappings":"AAEA,OAAgB,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAW1C,wBAAsB,aAAa,CAAC,EAAE,GAAG,EAAE,EAAE;IAAE,GAAG,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC;IACtE,GAAG,EAAE,OAAO,CAAA;IACZ,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAC9B,CAAC,CAsFD"}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.expressLoader = expressLoader;
|
|
7
|
-
const connect_redis_1 = __importDefault(require("connect-redis"));
|
|
8
|
-
const cookie_parser_1 = __importDefault(require("cookie-parser"));
|
|
9
|
-
const express_1 = __importDefault(require("express"));
|
|
10
|
-
const express_session_1 = __importDefault(require("express-session"));
|
|
11
|
-
const ioredis_1 = __importDefault(require("ioredis"));
|
|
12
|
-
const morgan_1 = __importDefault(require("morgan"));
|
|
13
|
-
const path_1 = __importDefault(require("path"));
|
|
14
|
-
const logger_1 = require("../logger");
|
|
15
|
-
const config_1 = require("../config");
|
|
16
|
-
const NOISY_ENDPOINTS_CHUNKS = ["@fs", "@id", "@vite", "@react", "node_modules"];
|
|
17
|
-
async function expressLoader({ app }) {
|
|
18
|
-
const baseDir = config_1.configManager.baseDir;
|
|
19
|
-
const configModule = config_1.configManager.config;
|
|
20
|
-
const isProduction = config_1.configManager.isProduction;
|
|
21
|
-
const NODE_ENV = process.env.NODE_ENV || "development";
|
|
22
|
-
const IS_DEV = NODE_ENV.startsWith("dev");
|
|
23
|
-
const isStaging = NODE_ENV === "staging";
|
|
24
|
-
const isTest = NODE_ENV === "test";
|
|
25
|
-
let sameSite = false;
|
|
26
|
-
let secure = false;
|
|
27
|
-
if (isProduction || isStaging) {
|
|
28
|
-
secure = true;
|
|
29
|
-
sameSite = "none";
|
|
30
|
-
}
|
|
31
|
-
const { http, sessionOptions } = configModule.projectConfig;
|
|
32
|
-
const sessionOpts = {
|
|
33
|
-
name: sessionOptions?.name ?? "connect.sid",
|
|
34
|
-
resave: sessionOptions?.resave ?? true,
|
|
35
|
-
rolling: sessionOptions?.rolling ?? false,
|
|
36
|
-
saveUninitialized: sessionOptions?.saveUninitialized ?? true,
|
|
37
|
-
proxy: true,
|
|
38
|
-
secret: sessionOptions?.secret ?? http?.cookieSecret,
|
|
39
|
-
cookie: {
|
|
40
|
-
sameSite,
|
|
41
|
-
secure,
|
|
42
|
-
maxAge: sessionOptions?.ttl ?? 10 * 60 * 60 * 1000,
|
|
43
|
-
},
|
|
44
|
-
store: null,
|
|
45
|
-
};
|
|
46
|
-
let redisClient;
|
|
47
|
-
if (configModule?.projectConfig?.redisUrl) {
|
|
48
|
-
const RedisStore = (0, connect_redis_1.default)(express_session_1.default);
|
|
49
|
-
redisClient = new ioredis_1.default(configModule.projectConfig.redisUrl, configModule.projectConfig.redisOptions ?? {});
|
|
50
|
-
sessionOpts.store = new RedisStore({
|
|
51
|
-
client: redisClient,
|
|
52
|
-
prefix: `${configModule?.projectConfig?.redisPrefix ?? ""}sess:`,
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
app.set("trust proxy", 1);
|
|
56
|
-
/**
|
|
57
|
-
* Method to skip logging HTTP requests. We skip in test environment
|
|
58
|
-
* and also exclude files served by vite during development
|
|
59
|
-
*/
|
|
60
|
-
function shouldSkipHttpLog(req, res) {
|
|
61
|
-
return (isTest || NOISY_ENDPOINTS_CHUNKS.some((chunk) => req.url.includes(chunk)));
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* The middleware to use for logging. We write the log messages
|
|
65
|
-
* using winston, but rely on morgan to hook into HTTP requests
|
|
66
|
-
*/
|
|
67
|
-
const loggingMiddleware = (0, morgan_1.default)(IS_DEV
|
|
68
|
-
? ":method :url ← :referrer (:status) - :response-time ms"
|
|
69
|
-
: "combined", {
|
|
70
|
-
skip: shouldSkipHttpLog,
|
|
71
|
-
stream: {
|
|
72
|
-
write: (message) => logger_1.logger.http(message.trim()),
|
|
73
|
-
},
|
|
74
|
-
});
|
|
75
|
-
app.use(loggingMiddleware);
|
|
76
|
-
app.use((0, cookie_parser_1.default)());
|
|
77
|
-
app.use((0, express_session_1.default)(sessionOpts));
|
|
78
|
-
// Currently we don't allow configuration of static files, but this can be revisited as needed.
|
|
79
|
-
app.use("/static", express_1.default.static(path_1.default.join(baseDir, "static")));
|
|
80
|
-
const shutdown = async () => {
|
|
81
|
-
redisClient?.disconnect();
|
|
82
|
-
};
|
|
83
|
-
return { app, shutdown };
|
|
84
|
-
}
|
|
85
|
-
//# sourceMappingURL=express-loader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"express-loader.js","sourceRoot":"","sources":["../../src/http/express-loader.ts"],"names":[],"mappings":";;;;;AAaA,sCAyFC;AAtGD,kEAAuC;AACvC,kEAAwC;AACxC,sDAA0C;AAC1C,sEAAqC;AACrC,sDAA2B;AAC3B,oDAA2B;AAC3B,gDAAuB;AACvB,sCAAkC;AAClC,sCAAyC;AAGzC,MAAM,sBAAsB,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAA;AAEzE,KAAK,UAAU,aAAa,CAAC,EAAE,GAAG,EAAoB;IAI3D,MAAM,OAAO,GAAG,sBAAa,CAAC,OAAO,CAAA;IACrC,MAAM,YAAY,GAAG,sBAAa,CAAC,MAAM,CAAA;IACzC,MAAM,YAAY,GAAG,sBAAa,CAAC,YAAY,CAAA;IAC/C,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,aAAa,CAAA;IACtD,MAAM,MAAM,GAAG,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;IACzC,MAAM,SAAS,GAAG,QAAQ,KAAK,SAAS,CAAA;IACxC,MAAM,MAAM,GAAG,QAAQ,KAAK,MAAM,CAAA;IAElC,IAAI,QAAQ,GAAqB,KAAK,CAAA;IACtC,IAAI,MAAM,GAAG,KAAK,CAAA;IAClB,IAAI,YAAY,IAAI,SAAS,EAA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AAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAC1E,CAAA;IACH,CAAC;IAED;;;OAGG;IACH,MAAM,iBAAiB,GAAG,IAAA,gBAAM,EAC9B,MAAM;QACJ,CAAC,CAAC,wDAAwD;QAC1D,CAAC,CAAC,UAAU,EACd;QACE,IAAI,EAAE,iBAAiB;QACvB,MAAM,EAAE;YACN,KAAK,EAAE,CAAC,OAAe,EAAE,EAAE,CAAC,eAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;SACxD;KACF,CACF,CAAA;IAED,GAAG,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;IAC1B,GAAG,CAAC,GAAG,CAAC,IAAA,uBAAY,GAAE,CAAC,CAAA;IACvB,GAAG,CAAC,GAAG,CAAC,IAAA,yBAAO,EAAC,WAAW,CAAC,CAAC,CAAA;IAE7B,+FAA+F;IAC/F,GAAG,CAAC,GAAG,CAAC,SAAS,EAAE,iBAAO,CAAC,MAAM,CAAC,cAAI,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAA;IAEhE,MAAM,QAAQ,GAAG,KAAK,IAAI,EAAE;QAC1B,WAAW,EAAE,UAAU,EAAE,CAAA;IAC3B,CAAC,CAAA;IAED,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAA;AAC1B,CAAC"}
|
package/dist/http/router.d.ts
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { type Express, RequestHandler } from "express";
|
|
2
|
-
import { AuthType } from "./middlewares";
|
|
3
|
-
import { MiddlewareFunction, MiddlewaresConfig, RouteHandler, RouteVerb } from "./types";
|
|
4
|
-
export declare class ApiRoutesLoader {
|
|
5
|
-
#private;
|
|
6
|
-
/**
|
|
7
|
-
* Wrap the original route handler implementation for
|
|
8
|
-
* instrumentation.
|
|
9
|
-
*/
|
|
10
|
-
static traceRoute?: (handler: RouteHandler, route: {
|
|
11
|
-
route: string;
|
|
12
|
-
method: string;
|
|
13
|
-
}) => RouteHandler;
|
|
14
|
-
/**
|
|
15
|
-
* Wrap the original middleware handler implementation for
|
|
16
|
-
* instrumentation.
|
|
17
|
-
*/
|
|
18
|
-
static traceMiddleware?: (handler: RequestHandler | MiddlewareFunction, route: {
|
|
19
|
-
route: string;
|
|
20
|
-
method?: string;
|
|
21
|
-
}) => RequestHandler | MiddlewareFunction;
|
|
22
|
-
constructor({ app, activityId, sourceDir, }: {
|
|
23
|
-
app: Express;
|
|
24
|
-
activityId?: string;
|
|
25
|
-
sourceDir: string;
|
|
26
|
-
});
|
|
27
|
-
/**
|
|
28
|
-
* Validate the route config and display a log info if
|
|
29
|
-
* it should be ignored or skipped.
|
|
30
|
-
*
|
|
31
|
-
* @param {GlobalMiddlewareDescriptor} descriptor
|
|
32
|
-
* @param {MiddlewaresConfig} config
|
|
33
|
-
*
|
|
34
|
-
* @return {void}
|
|
35
|
-
*/
|
|
36
|
-
protected validateMiddlewaresConfig({ config, }: {
|
|
37
|
-
config?: MiddlewaresConfig;
|
|
38
|
-
}): void;
|
|
39
|
-
/**
|
|
40
|
-
* Take care of replacing the special path segments
|
|
41
|
-
* to an express specific path segment
|
|
42
|
-
*
|
|
43
|
-
* @param route - The route to parse
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* "/admin/orders/[id]/route.ts => "/admin/orders/:id/route.ts"
|
|
47
|
-
*/
|
|
48
|
-
protected parseRoute(route: string): string;
|
|
49
|
-
/**
|
|
50
|
-
* Load the file content from a descriptor and retrieve the verbs and handlers
|
|
51
|
-
* to be assigned to the descriptor
|
|
52
|
-
*
|
|
53
|
-
* @return {Promise<void>}
|
|
54
|
-
*/
|
|
55
|
-
protected createRoutesConfig(): Promise<void>;
|
|
56
|
-
protected createRoutesDescriptor(path: string): void;
|
|
57
|
-
protected createMiddlewaresDescriptor(): Promise<void>;
|
|
58
|
-
protected createRoutesMap(): Promise<void>;
|
|
59
|
-
/**
|
|
60
|
-
* Apply the most specific body parser middleware to the router
|
|
61
|
-
*/
|
|
62
|
-
applyBodyParserMiddleware(path: string, method: RouteVerb): void;
|
|
63
|
-
/**
|
|
64
|
-
* Applies middleware that checks if a valid publishable key is set on store request
|
|
65
|
-
*/
|
|
66
|
-
applyStorePublishableKeyMiddleware(route: string | RegExp): void;
|
|
67
|
-
/**
|
|
68
|
-
* Applies the route middleware on a route. Encapsulates the logic
|
|
69
|
-
* needed to pass the middleware via the trace calls
|
|
70
|
-
*/
|
|
71
|
-
applyAuthMiddleware(route: string | RegExp, actorType: string | string[], authType: AuthType | AuthType[], options?: {
|
|
72
|
-
allowUnauthenticated?: boolean;
|
|
73
|
-
allowUnregistered?: boolean;
|
|
74
|
-
}): void;
|
|
75
|
-
/**
|
|
76
|
-
* Apply the route specific middlewares to the router,
|
|
77
|
-
* this includes the cors, authentication and
|
|
78
|
-
* body parsing. These are applied first to ensure
|
|
79
|
-
* that they are applied before any other middleware.
|
|
80
|
-
*/
|
|
81
|
-
applyRouteSpecificMiddlewares(): void;
|
|
82
|
-
/**
|
|
83
|
-
* Apply the error handler middleware to the router
|
|
84
|
-
*/
|
|
85
|
-
applyErrorHandlerMiddleware(): void;
|
|
86
|
-
protected registerRoutes(): Promise<void>;
|
|
87
|
-
protected registerMiddlewares(): Promise<void>;
|
|
88
|
-
load(): Promise<void>;
|
|
89
|
-
}
|
|
90
|
-
export declare class RoutesLoader {
|
|
91
|
-
#private;
|
|
92
|
-
constructor({ app, activityId, sourceDir, baseRestrictedFields, }: {
|
|
93
|
-
app: Express;
|
|
94
|
-
activityId?: string;
|
|
95
|
-
sourceDir: string | string[];
|
|
96
|
-
baseRestrictedFields?: string[];
|
|
97
|
-
});
|
|
98
|
-
load(): Promise<void>;
|
|
99
|
-
}
|
|
100
|
-
//# sourceMappingURL=router.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.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