apitally 0.1.2 → 0.1.3
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/lib/cjs/common/client.js +395 -0
- package/lib/cjs/common/client.js.map +1 -0
- package/lib/cjs/common/index.js +13 -0
- package/lib/cjs/common/index.js.map +1 -0
- package/lib/cjs/common/keyRegistry.js +162 -0
- package/lib/cjs/common/keyRegistry.js.map +1 -0
- package/lib/cjs/common/logging.js +17 -0
- package/lib/cjs/common/logging.js.map +1 -0
- package/lib/cjs/common/requestLogger.js +69 -0
- package/lib/cjs/common/requestLogger.js.map +1 -0
- package/lib/cjs/common/types.js +6 -0
- package/lib/cjs/common/types.js.map +1 -0
- package/lib/cjs/common/utils.js +24 -0
- package/lib/cjs/common/utils.js.map +1 -0
- package/lib/cjs/common/validationErrorLogger.js +58 -0
- package/lib/cjs/common/validationErrorLogger.js.map +1 -0
- package/lib/cjs/express/auth.js +105 -0
- package/lib/cjs/express/auth.js.map +1 -0
- package/lib/cjs/express/index.js +27 -0
- package/lib/cjs/express/index.js.map +1 -0
- package/lib/cjs/express/listEndpoints.js +175 -0
- package/lib/cjs/express/listEndpoints.js.map +1 -0
- package/lib/cjs/express/middleware.js +167 -0
- package/lib/cjs/express/middleware.js.map +1 -0
- package/lib/cjs/fastify/auth.js +105 -0
- package/lib/cjs/fastify/auth.js.map +1 -0
- package/lib/cjs/fastify/index.js +28 -0
- package/lib/cjs/fastify/index.js.map +1 -0
- package/lib/cjs/fastify/plugin.js +147 -0
- package/lib/cjs/fastify/plugin.js.map +1 -0
- package/lib/cjs/index.js +6 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/koa/auth.js +113 -0
- package/lib/cjs/koa/auth.js.map +1 -0
- package/lib/cjs/koa/index.js +27 -0
- package/lib/cjs/koa/index.js.map +1 -0
- package/lib/cjs/koa/middleware.js +122 -0
- package/lib/cjs/koa/middleware.js.map +1 -0
- package/lib/cjs/nestjs/auth.js +132 -0
- package/lib/cjs/nestjs/auth.js.map +1 -0
- package/lib/cjs/nestjs/index.js +39 -0
- package/lib/cjs/nestjs/index.js.map +1 -0
- package/lib/esm/common/client.js +385 -0
- package/lib/esm/common/client.js.map +1 -0
- package/lib/esm/common/index.js +1 -0
- package/lib/esm/common/index.js.map +1 -0
- package/lib/esm/common/keyRegistry.js +155 -0
- package/lib/esm/common/keyRegistry.js.map +1 -0
- package/lib/esm/common/logging.js +11 -0
- package/lib/esm/common/logging.js.map +1 -0
- package/lib/esm/common/requestLogger.js +63 -0
- package/lib/esm/common/requestLogger.js.map +1 -0
- package/lib/esm/common/types.js +1 -0
- package/lib/esm/common/types.js.map +1 -0
- package/lib/esm/common/utils.js +16 -0
- package/lib/esm/common/utils.js.map +1 -0
- package/lib/esm/common/validationErrorLogger.js +52 -0
- package/lib/esm/common/validationErrorLogger.js.map +1 -0
- package/lib/esm/express/auth.js +98 -0
- package/lib/esm/express/auth.js.map +1 -0
- package/lib/esm/express/index.js +4 -0
- package/lib/esm/express/index.js.map +1 -0
- package/lib/esm/express/listEndpoints.js +168 -0
- package/lib/esm/express/listEndpoints.js.map +1 -0
- package/lib/esm/express/middleware.js +160 -0
- package/lib/esm/express/middleware.js.map +1 -0
- package/lib/esm/fastify/auth.js +98 -0
- package/lib/esm/fastify/auth.js.map +1 -0
- package/lib/esm/fastify/index.js +4 -0
- package/lib/esm/fastify/index.js.map +1 -0
- package/lib/esm/fastify/plugin.js +140 -0
- package/lib/esm/fastify/plugin.js.map +1 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/koa/auth.js +106 -0
- package/lib/esm/koa/auth.js.map +1 -0
- package/lib/esm/koa/index.js +4 -0
- package/lib/esm/koa/index.js.map +1 -0
- package/lib/esm/koa/middleware.js +115 -0
- package/lib/esm/koa/middleware.js.map +1 -0
- package/lib/esm/nestjs/auth.js +126 -0
- package/lib/esm/nestjs/auth.js.map +1 -0
- package/lib/esm/nestjs/index.js +4 -0
- package/lib/esm/nestjs/index.js.map +1 -0
- package/{dist/src → lib/types}/common/client.d.ts +7 -6
- package/lib/types/common/client.d.ts.map +1 -0
- package/lib/types/common/index.d.ts +2 -0
- package/{dist/src → lib/types}/common/index.d.ts.map +1 -1
- package/{dist/src → lib/types}/common/requestLogger.d.ts +1 -1
- package/{dist/src → lib/types}/common/requestLogger.d.ts.map +1 -1
- package/{dist/src → lib/types}/common/types.d.ts +2 -2
- package/lib/types/common/types.d.ts.map +1 -0
- package/{dist/src → lib/types}/common/validationErrorLogger.d.ts +1 -1
- package/{dist/src → lib/types}/common/validationErrorLogger.d.ts.map +1 -1
- package/{dist/src → lib/types}/express/auth.d.ts +1 -1
- package/lib/types/express/auth.d.ts.map +1 -0
- package/lib/types/express/index.d.ts +4 -0
- package/{dist/src → lib/types}/express/index.d.ts.map +1 -1
- package/lib/types/express/listEndpoints.d.ts +3 -0
- package/{dist/src → lib/types}/express/middleware.d.ts +3 -3
- package/lib/types/express/middleware.d.ts.map +1 -0
- package/{dist/src → lib/types}/fastify/auth.d.ts +1 -1
- package/lib/types/fastify/auth.d.ts.map +1 -0
- package/lib/types/fastify/index.d.ts +4 -0
- package/{dist/src → lib/types}/fastify/index.d.ts.map +1 -1
- package/lib/types/fastify/plugin.d.ts +15 -0
- package/lib/types/fastify/plugin.d.ts.map +1 -0
- package/lib/types/koa/index.d.ts +4 -0
- package/{dist/src → lib/types}/koa/index.d.ts.map +1 -1
- package/{dist/src → lib/types}/koa/middleware.d.ts +1 -1
- package/{dist/src → lib/types}/koa/middleware.d.ts.map +1 -1
- package/{dist/src → lib/types}/nestjs/auth.d.ts +1 -1
- package/{dist/src → lib/types}/nestjs/auth.d.ts.map +1 -1
- package/lib/types/nestjs/index.d.ts +4 -0
- package/lib/types/nestjs/index.d.ts.map +1 -0
- package/package.json +96 -7
- package/dist/src/common/client.d.ts.map +0 -1
- package/dist/src/common/client.js +0 -244
- package/dist/src/common/client.js.map +0 -1
- package/dist/src/common/index.d.ts +0 -2
- package/dist/src/common/index.js +0 -6
- package/dist/src/common/index.js.map +0 -1
- package/dist/src/common/keyRegistry.js +0 -90
- package/dist/src/common/keyRegistry.js.map +0 -1
- package/dist/src/common/logging.js +0 -13
- package/dist/src/common/logging.js.map +0 -1
- package/dist/src/common/requestLogger.js +0 -49
- package/dist/src/common/requestLogger.js.map +0 -1
- package/dist/src/common/types.d.ts.map +0 -1
- package/dist/src/common/types.js +0 -3
- package/dist/src/common/types.js.map +0 -1
- package/dist/src/common/utils.js +0 -23
- package/dist/src/common/utils.js.map +0 -1
- package/dist/src/common/validationErrorLogger.js +0 -40
- package/dist/src/common/validationErrorLogger.js.map +0 -1
- package/dist/src/express/auth.d.ts.map +0 -1
- package/dist/src/express/auth.js +0 -66
- package/dist/src/express/auth.js.map +0 -1
- package/dist/src/express/index.d.ts +0 -4
- package/dist/src/express/index.js +0 -10
- package/dist/src/express/index.js.map +0 -1
- package/dist/src/express/listEndpoints.d.ts +0 -3
- package/dist/src/express/listEndpoints.js +0 -166
- package/dist/src/express/listEndpoints.js.map +0 -1
- package/dist/src/express/middleware.d.ts.map +0 -1
- package/dist/src/express/middleware.js +0 -164
- package/dist/src/express/middleware.js.map +0 -1
- package/dist/src/fastify/auth.d.ts.map +0 -1
- package/dist/src/fastify/auth.js +0 -66
- package/dist/src/fastify/auth.js.map +0 -1
- package/dist/src/fastify/index.d.ts +0 -4
- package/dist/src/fastify/index.js +0 -13
- package/dist/src/fastify/index.js.map +0 -1
- package/dist/src/fastify/plugin.d.ts +0 -16
- package/dist/src/fastify/plugin.d.ts.map +0 -1
- package/dist/src/fastify/plugin.js +0 -124
- package/dist/src/fastify/plugin.js.map +0 -1
- package/dist/src/index.js +0 -3
- package/dist/src/index.js.map +0 -1
- package/dist/src/koa/auth.js +0 -67
- package/dist/src/koa/auth.js.map +0 -1
- package/dist/src/koa/index.d.ts +0 -4
- package/dist/src/koa/index.js +0 -10
- package/dist/src/koa/index.js.map +0 -1
- package/dist/src/koa/middleware.js +0 -108
- package/dist/src/koa/middleware.js.map +0 -1
- package/dist/src/nestjs/auth.js +0 -88
- package/dist/src/nestjs/auth.js.map +0 -1
- package/dist/src/nestjs/index.d.ts +0 -4
- package/dist/src/nestjs/index.d.ts.map +0 -1
- package/dist/src/nestjs/index.js +0 -12
- package/dist/src/nestjs/index.js.map +0 -1
- /package/{dist/src → lib/types}/common/keyRegistry.d.ts +0 -0
- /package/{dist/src → lib/types}/common/keyRegistry.d.ts.map +0 -0
- /package/{dist/src → lib/types}/common/logging.d.ts +0 -0
- /package/{dist/src → lib/types}/common/logging.d.ts.map +0 -0
- /package/{dist/src → lib/types}/common/utils.d.ts +0 -0
- /package/{dist/src → lib/types}/common/utils.d.ts.map +0 -0
- /package/{dist/src → lib/types}/express/listEndpoints.d.ts.map +0 -0
- /package/{dist/src → lib/types}/index.d.ts +0 -0
- /package/{dist/src → lib/types}/index.d.ts.map +0 -0
- /package/{dist/src → lib/types}/koa/auth.d.ts +0 -0
- /package/{dist/src → lib/types}/koa/auth.d.ts.map +0 -0
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Adapted from https://github.com/AlbertoFdzM/express-list-endpoints/blob/ed926dd5186761e7b721ad20938ce6eb52d104d3/src/index.js
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const regExpToParseExpressPathRegExp = /^\/\^\\\/(?:(:?[\w\\.-]*(?:\\\/:?[\w\\.-]*)*)|(\(\?:\(\[\^\\\/]\+\?\)\)))\\\/.*/;
|
|
5
|
-
const regExpToReplaceExpressPathRegExpParams = /\(\?:\(\[\^\\\/]\+\?\)\)/;
|
|
6
|
-
const regexpExpressParamRegexp = /\(\?:\(\[\^\\\/]\+\?\)\)/g;
|
|
7
|
-
const EXPRESS_ROOT_PATH_REGEXP_VALUE = "/^\\/?(?=\\/|$)/i";
|
|
8
|
-
const STACK_ITEM_VALID_NAMES = ["router", "bound dispatch", "mounted_app"];
|
|
9
|
-
/**
|
|
10
|
-
* Returns all the verbs detected for the passed route
|
|
11
|
-
*/
|
|
12
|
-
const getRouteMethods = function (route) {
|
|
13
|
-
let methods = Object.keys(route.methods);
|
|
14
|
-
methods = methods.filter((method) => method !== "_all");
|
|
15
|
-
methods = methods.map((method) => method.toUpperCase());
|
|
16
|
-
return methods;
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Returns the names (or anonymous) of all the middlewares attached to the
|
|
20
|
-
* passed route
|
|
21
|
-
* @param {Object} route
|
|
22
|
-
* @returns {string[]}
|
|
23
|
-
*/
|
|
24
|
-
const getRouteMiddlewares = function (route) {
|
|
25
|
-
return route.stack.map((item) => {
|
|
26
|
-
return item.handle.name || "anonymous";
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Returns true if found regexp related with express params
|
|
31
|
-
* @param {string} expressPathRegExp
|
|
32
|
-
* @returns {boolean}
|
|
33
|
-
*/
|
|
34
|
-
const hasParams = function (expressPathRegExp) {
|
|
35
|
-
return regexpExpressParamRegexp.test(expressPathRegExp);
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* @param {Object} route Express route object to be parsed
|
|
39
|
-
* @param {string} basePath The basePath the route is on
|
|
40
|
-
* @return {Object[]} Endpoints info
|
|
41
|
-
*/
|
|
42
|
-
const parseExpressRoute = function (route, basePath) {
|
|
43
|
-
const paths = [];
|
|
44
|
-
if (Array.isArray(route.path)) {
|
|
45
|
-
paths.push(...route.path);
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
paths.push(route.path);
|
|
49
|
-
}
|
|
50
|
-
const endpoints = paths.map((path) => {
|
|
51
|
-
const completePath = basePath && path === "/" ? basePath : `${basePath}${path}`;
|
|
52
|
-
const endpoint = {
|
|
53
|
-
path: completePath,
|
|
54
|
-
methods: getRouteMethods(route),
|
|
55
|
-
middlewares: getRouteMiddlewares(route),
|
|
56
|
-
};
|
|
57
|
-
return endpoint;
|
|
58
|
-
});
|
|
59
|
-
return endpoints;
|
|
60
|
-
};
|
|
61
|
-
/**
|
|
62
|
-
* @param {RegExp} expressPathRegExp
|
|
63
|
-
* @param {Object[]} params
|
|
64
|
-
* @returns {string}
|
|
65
|
-
*/
|
|
66
|
-
const parseExpressPath = function (expressPathRegExp, params) {
|
|
67
|
-
let expressPathRegExpExec = regExpToParseExpressPathRegExp.exec(expressPathRegExp);
|
|
68
|
-
let parsedRegExp = expressPathRegExp.toString();
|
|
69
|
-
let paramIndex = 0;
|
|
70
|
-
while (hasParams(parsedRegExp)) {
|
|
71
|
-
const paramName = params[paramIndex].name;
|
|
72
|
-
const paramId = `:${paramName}`;
|
|
73
|
-
parsedRegExp = parsedRegExp.replace(regExpToReplaceExpressPathRegExpParams, paramId);
|
|
74
|
-
paramIndex++;
|
|
75
|
-
}
|
|
76
|
-
if (parsedRegExp !== expressPathRegExp.toString()) {
|
|
77
|
-
expressPathRegExpExec = regExpToParseExpressPathRegExp.exec(parsedRegExp);
|
|
78
|
-
}
|
|
79
|
-
const parsedPath = expressPathRegExpExec[1].replace(/\\\//g, "/");
|
|
80
|
-
return parsedPath;
|
|
81
|
-
};
|
|
82
|
-
/**
|
|
83
|
-
* @param {Object} app
|
|
84
|
-
* @param {string} [basePath]
|
|
85
|
-
* @param {Object[]} [endpoints]
|
|
86
|
-
* @returns {Object[]}
|
|
87
|
-
*/
|
|
88
|
-
const parseEndpoints = function (app, basePath, endpoints) {
|
|
89
|
-
const stack = app.stack || (app._router && app._router.stack);
|
|
90
|
-
endpoints = endpoints || [];
|
|
91
|
-
basePath = basePath || "";
|
|
92
|
-
if (!stack) {
|
|
93
|
-
endpoints = addEndpoints(endpoints, [
|
|
94
|
-
{
|
|
95
|
-
path: basePath,
|
|
96
|
-
methods: [],
|
|
97
|
-
middlewares: [],
|
|
98
|
-
},
|
|
99
|
-
]);
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
endpoints = parseStack(stack, basePath, endpoints);
|
|
103
|
-
}
|
|
104
|
-
return endpoints;
|
|
105
|
-
};
|
|
106
|
-
/**
|
|
107
|
-
* Ensures the path of the new endpoints isn't yet in the array.
|
|
108
|
-
* If the path is already in the array merges the endpoints with the existing
|
|
109
|
-
* one, if not, it adds them to the array.
|
|
110
|
-
*
|
|
111
|
-
* @param {Object[]} currentEndpoints Array of current endpoints
|
|
112
|
-
* @param {Object[]} endpointsToAdd New endpoints to be added to the array
|
|
113
|
-
* @returns {Object[]} Updated endpoints array
|
|
114
|
-
*/
|
|
115
|
-
const addEndpoints = function (currentEndpoints, endpointsToAdd) {
|
|
116
|
-
endpointsToAdd.forEach((newEndpoint) => {
|
|
117
|
-
const existingEndpoint = currentEndpoints.find((item) => item.path === newEndpoint.path);
|
|
118
|
-
if (existingEndpoint !== undefined) {
|
|
119
|
-
const newMethods = newEndpoint.methods.filter((method) => !existingEndpoint.methods.includes(method));
|
|
120
|
-
existingEndpoint.methods = existingEndpoint.methods.concat(newMethods);
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
currentEndpoints.push(newEndpoint);
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
return currentEndpoints;
|
|
127
|
-
};
|
|
128
|
-
/**
|
|
129
|
-
* @param {Object} stack
|
|
130
|
-
* @param {string} basePath
|
|
131
|
-
* @param {Object[]} endpoints
|
|
132
|
-
* @returns {Object[]}
|
|
133
|
-
*/
|
|
134
|
-
const parseStack = function (stack, basePath, endpoints) {
|
|
135
|
-
stack.forEach((stackItem) => {
|
|
136
|
-
if (stackItem.route) {
|
|
137
|
-
const newEndpoints = parseExpressRoute(stackItem.route, basePath);
|
|
138
|
-
endpoints = addEndpoints(endpoints, newEndpoints);
|
|
139
|
-
}
|
|
140
|
-
else if (STACK_ITEM_VALID_NAMES.includes(stackItem.name)) {
|
|
141
|
-
const isExpressPathRegexp = regExpToParseExpressPathRegExp.test(stackItem.regexp);
|
|
142
|
-
let newBasePath = basePath;
|
|
143
|
-
if (isExpressPathRegexp) {
|
|
144
|
-
const parsedPath = parseExpressPath(stackItem.regexp, stackItem.keys);
|
|
145
|
-
newBasePath += `/${parsedPath}`;
|
|
146
|
-
}
|
|
147
|
-
else if (!stackItem.path &&
|
|
148
|
-
stackItem.regexp &&
|
|
149
|
-
stackItem.regexp.toString() !== EXPRESS_ROOT_PATH_REGEXP_VALUE) {
|
|
150
|
-
const regExpPath = ` RegExp(${stackItem.regexp}) `;
|
|
151
|
-
newBasePath += `/${regExpPath}`;
|
|
152
|
-
}
|
|
153
|
-
endpoints = parseEndpoints(stackItem.handle, newBasePath, endpoints);
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
return endpoints;
|
|
157
|
-
};
|
|
158
|
-
const getEndpoints = function (app) {
|
|
159
|
-
const endpoints = parseEndpoints(app);
|
|
160
|
-
return endpoints.flatMap((route) => route.methods.map((method) => ({
|
|
161
|
-
method,
|
|
162
|
-
path: route.path,
|
|
163
|
-
})));
|
|
164
|
-
};
|
|
165
|
-
module.exports = getEndpoints;
|
|
166
|
-
//# sourceMappingURL=listEndpoints.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"listEndpoints.js","sourceRoot":"","sources":["../../../src/express/listEndpoints.js"],"names":[],"mappings":";AAAA,gIAAgI;;AAEhI,MAAM,8BAA8B,GAClC,iFAAiF,CAAC;AACpF,MAAM,sCAAsC,GAAG,0BAA0B,CAAC;AAC1E,MAAM,wBAAwB,GAAG,2BAA2B,CAAC;AAE7D,MAAM,8BAA8B,GAAG,mBAAmB,CAAC;AAC3D,MAAM,sBAAsB,GAAG,CAAC,QAAQ,EAAE,gBAAgB,EAAE,aAAa,CAAC,CAAC;AAE3E;;GAEG;AACH,MAAM,eAAe,GAAG,UAAU,KAAK;IACrC,IAAI,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAEzC,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CA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AAmC,MAAM,SAAS,CAAC;AAInE,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,cAAc,EAA4B,MAAM,iBAAiB,CAAC;AAI3E,OAAO,QAAQ,SAAS,CAAC;IACvB,UAAU,OAAO;QACf,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB;CACF;AAED,eAAO,MAAM,WAAW,QAAS,OAAO,UAAU,cAAc,SAO/D,CAAC"}
|
|
@@ -1,164 +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.useApitally = void 0;
|
|
7
|
-
const perf_hooks_1 = require("perf_hooks");
|
|
8
|
-
const client_1 = require("../common/client");
|
|
9
|
-
const keyRegistry_1 = require("../common/keyRegistry");
|
|
10
|
-
const utils_1 = require("../common/utils");
|
|
11
|
-
const listEndpoints_1 = __importDefault(require("./listEndpoints"));
|
|
12
|
-
const useApitally = (app, config) => {
|
|
13
|
-
const client = new client_1.ApitallyClient(config);
|
|
14
|
-
const middleware = getMiddleware(client);
|
|
15
|
-
app.use(middleware);
|
|
16
|
-
setTimeout(() => {
|
|
17
|
-
client.setAppInfo(getAppInfo(app, config.appVersion));
|
|
18
|
-
}, 100);
|
|
19
|
-
};
|
|
20
|
-
exports.useApitally = useApitally;
|
|
21
|
-
const getMiddleware = (client) => {
|
|
22
|
-
const validatorInstalled = (0, utils_1.getPackageVersion)("express-validator") !== null;
|
|
23
|
-
const celebrateInstalled = (0, utils_1.getPackageVersion)("celebrate") !== null;
|
|
24
|
-
const nestInstalled = (0, utils_1.getPackageVersion)("@nestjs/core") !== null;
|
|
25
|
-
const classValidatorInstalled = (0, utils_1.getPackageVersion)("class-validator") !== null;
|
|
26
|
-
return (req, res, next) => {
|
|
27
|
-
try {
|
|
28
|
-
const startTime = perf_hooks_1.performance.now();
|
|
29
|
-
const originalJson = res.json;
|
|
30
|
-
res.json = (body) => {
|
|
31
|
-
res.locals.body = body;
|
|
32
|
-
return originalJson.call(res, body);
|
|
33
|
-
};
|
|
34
|
-
res.on("finish", () => {
|
|
35
|
-
try {
|
|
36
|
-
if (req.route) {
|
|
37
|
-
const responseTime = perf_hooks_1.performance.now() - startTime;
|
|
38
|
-
client.requestLogger.logRequest({
|
|
39
|
-
consumer: getConsumer(req),
|
|
40
|
-
method: req.method,
|
|
41
|
-
path: req.route.path,
|
|
42
|
-
statusCode: res.statusCode,
|
|
43
|
-
responseTime: responseTime,
|
|
44
|
-
});
|
|
45
|
-
if ((res.statusCode === 400 || res.statusCode === 422) &&
|
|
46
|
-
res.locals.body) {
|
|
47
|
-
const validationErrors = [];
|
|
48
|
-
if (validatorInstalled) {
|
|
49
|
-
validationErrors.push(...extractExpressValidatorErrors(res.locals.body));
|
|
50
|
-
}
|
|
51
|
-
if (celebrateInstalled) {
|
|
52
|
-
validationErrors.push(...extractCelebrateErrors(res.locals.body));
|
|
53
|
-
}
|
|
54
|
-
if (nestInstalled && classValidatorInstalled) {
|
|
55
|
-
validationErrors.push(...extractNestValidationErrors(res.locals.body));
|
|
56
|
-
}
|
|
57
|
-
validationErrors.forEach((error) => {
|
|
58
|
-
client.validationErrorLogger.logValidationError(Object.assign({ consumer: getConsumer(req), method: req.method, path: req.route.path }, error));
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
catch (error) {
|
|
64
|
-
client.logger.error("Error while logging request in Apitally middleware.", { request: req, response: res, error });
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
catch (error) {
|
|
69
|
-
client.logger.error("Error in Apitally middleware.", {
|
|
70
|
-
request: req,
|
|
71
|
-
response: res,
|
|
72
|
-
error,
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
finally {
|
|
76
|
-
next();
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
const getConsumer = (req) => {
|
|
81
|
-
if (req.consumerIdentifier) {
|
|
82
|
-
return String(req.consumerIdentifier);
|
|
83
|
-
}
|
|
84
|
-
if (req.keyInfo && req.keyInfo instanceof keyRegistry_1.KeyInfo) {
|
|
85
|
-
return `key:${req.keyInfo.keyId}`;
|
|
86
|
-
}
|
|
87
|
-
return null;
|
|
88
|
-
};
|
|
89
|
-
const extractExpressValidatorErrors = (responseBody) => {
|
|
90
|
-
const errors = [];
|
|
91
|
-
if (responseBody &&
|
|
92
|
-
responseBody.errors &&
|
|
93
|
-
Array.isArray(responseBody.errors)) {
|
|
94
|
-
responseBody.errors.forEach((error) => {
|
|
95
|
-
if (error.location && error.path && error.msg && error.type) {
|
|
96
|
-
errors.push({
|
|
97
|
-
loc: `${error.location}.${error.path}`,
|
|
98
|
-
msg: error.msg,
|
|
99
|
-
type: error.type,
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
return errors;
|
|
105
|
-
};
|
|
106
|
-
const extractCelebrateErrors = (responseBody) => {
|
|
107
|
-
const errors = [];
|
|
108
|
-
if (responseBody && responseBody.validation) {
|
|
109
|
-
Object.values(responseBody.validation).forEach((error) => {
|
|
110
|
-
if (error.source &&
|
|
111
|
-
error.keys &&
|
|
112
|
-
Array.isArray(error.keys) &&
|
|
113
|
-
error.message) {
|
|
114
|
-
error.keys.forEach((key) => {
|
|
115
|
-
errors.push({
|
|
116
|
-
loc: `${error.source}.${key}`,
|
|
117
|
-
msg: subsetJoiMessage(error.message, key),
|
|
118
|
-
type: "",
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
return errors;
|
|
125
|
-
};
|
|
126
|
-
const extractNestValidationErrors = (responseBody) => {
|
|
127
|
-
const errors = [];
|
|
128
|
-
if (responseBody && Array.isArray(responseBody.message)) {
|
|
129
|
-
responseBody.message.forEach((message) => {
|
|
130
|
-
errors.push({
|
|
131
|
-
loc: "",
|
|
132
|
-
msg: message,
|
|
133
|
-
type: "",
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
return errors;
|
|
138
|
-
};
|
|
139
|
-
const subsetJoiMessage = (message, key) => {
|
|
140
|
-
const messageWithKey = message
|
|
141
|
-
.split(". ")
|
|
142
|
-
.find((message) => message.includes(`"${key}"`));
|
|
143
|
-
return messageWithKey ? messageWithKey : message;
|
|
144
|
-
};
|
|
145
|
-
const getAppInfo = (app, appVersion) => {
|
|
146
|
-
const versions = [["nodejs", process.version]];
|
|
147
|
-
const expressVersion = (0, utils_1.getPackageVersion)("express");
|
|
148
|
-
const apitallyVersion = (0, utils_1.getPackageVersion)("../..");
|
|
149
|
-
if (expressVersion) {
|
|
150
|
-
versions.push(["express", expressVersion]);
|
|
151
|
-
}
|
|
152
|
-
if (apitallyVersion) {
|
|
153
|
-
versions.push(["apitally", apitallyVersion]);
|
|
154
|
-
}
|
|
155
|
-
if (appVersion) {
|
|
156
|
-
versions.push(["app", appVersion]);
|
|
157
|
-
}
|
|
158
|
-
return {
|
|
159
|
-
paths: (0, listEndpoints_1.default)(app),
|
|
160
|
-
versions: new Map(versions),
|
|
161
|
-
client: "js:express",
|
|
162
|
-
};
|
|
163
|
-
};
|
|
164
|
-
//# sourceMappingURL=middleware.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../../src/express/middleware.ts"],"names":[],"mappings":";;;;;;AACA,2CAAyC;AAEzC,6CAAkD;AAClD,uDAAgD;AAEhD,2CAAoD;AACpD,oEAA4C;AASrC,MAAM,WAAW,GAAG,CAAC,GAAY,EAAE,MAAsB,EAAE,EAAE;IAClE,MAAM,MAAM,GAAG,IAAI,uBAAc,CAAC,MA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EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAG7E,eAAO,MAAM,aAAa;;;gBAQb,cAAc,SAChB,YAAY,QACb,oBAAoB,kBAqD7B,CAAC"}
|
package/dist/src/fastify/auth.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.requireApiKey = void 0;
|
|
13
|
-
const client_1 = require("../common/client");
|
|
14
|
-
const requireApiKey = ({ scopes, customHeader, } = {}) => {
|
|
15
|
-
return (request, reply, done) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
-
let apiKey;
|
|
17
|
-
if (!customHeader) {
|
|
18
|
-
if (!request.headers.authorization) {
|
|
19
|
-
reply
|
|
20
|
-
.code(401)
|
|
21
|
-
.header("WWW-Authenticate", "ApiKey")
|
|
22
|
-
.send({ error: "Missing authorization header" });
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const authorizationParts = request.headers.authorization.split(" ");
|
|
26
|
-
if (authorizationParts.length === 2 &&
|
|
27
|
-
authorizationParts[0].toLowerCase() === "apikey") {
|
|
28
|
-
apiKey = authorizationParts[1];
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
reply
|
|
32
|
-
.code(401)
|
|
33
|
-
.header("WWW-Authenticate", "ApiKey")
|
|
34
|
-
.send({ error: "Invalid authorization scheme" });
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
else if (customHeader) {
|
|
39
|
-
const customHeaderValue = request.headers[customHeader.toLowerCase()];
|
|
40
|
-
if (typeof customHeaderValue === "string") {
|
|
41
|
-
apiKey = customHeaderValue;
|
|
42
|
-
}
|
|
43
|
-
else if (Array.isArray(customHeaderValue)) {
|
|
44
|
-
apiKey = customHeaderValue[0];
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
if (!apiKey) {
|
|
48
|
-
reply.code(403).send({ error: "Missing API key" });
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
const client = client_1.ApitallyClient.getInstance();
|
|
52
|
-
const keyInfo = yield client.keyRegistry.get(apiKey);
|
|
53
|
-
if (!keyInfo) {
|
|
54
|
-
reply.code(403).send({ error: "Invalid API key" });
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
if (scopes && !keyInfo.hasScopes(scopes)) {
|
|
58
|
-
reply.code(403).send({ error: "Permission denied" });
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
request.keyInfo = keyInfo;
|
|
62
|
-
done();
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
|
-
exports.requireApiKey = requireApiKey;
|
|
66
|
-
//# sourceMappingURL=auth.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/fastify/auth.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,6CAAkD;AAE3C,MAAM,aAAa,GAAG,CAAC,EAC5B,MAAM,EACN,YAAY,MAIV,EAAE,EAAE,EAAE;IACR,OAAO,CACL,OAAuB,EACvB,KAAmB,EACnB,IAA0B,EAC1B,EAAE;QACF,IAAI,MAA0B,CAAC;QAE/B,IAAI,CAAC,YAAY,EAAE;YACjB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,aAA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;QACrD,IAAI,CAAC,OAAO,EAAE;YACZ,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,iBAAiB,EAAE,CAAC,CAAC;YACnD,OAAO;SACR;QACD,IAAI,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE;YACxC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,mBAAmB,EAAE,CAAC,CAAC;YACrD,OAAO;SACR;QAED,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC;QAC1B,IAAI,EAAE,CAAC;IACT,CAAC,CAAA,CAAC;AACJ,CAAC,CAAC;AA/DW,QAAA,aAAa,iBA+DxB"}
|
|
@@ -1,13 +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.apitallyPlugin = exports.requireApiKey = exports.KeyInfo = void 0;
|
|
7
|
-
var keyRegistry_1 = require("../common/keyRegistry");
|
|
8
|
-
Object.defineProperty(exports, "KeyInfo", { enumerable: true, get: function () { return keyRegistry_1.KeyInfo; } });
|
|
9
|
-
var auth_1 = require("./auth");
|
|
10
|
-
Object.defineProperty(exports, "requireApiKey", { enumerable: true, get: function () { return auth_1.requireApiKey; } });
|
|
11
|
-
var plugin_1 = require("./plugin");
|
|
12
|
-
Object.defineProperty(exports, "apitallyPlugin", { enumerable: true, get: function () { return __importDefault(plugin_1).default; } });
|
|
13
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/fastify/index.ts"],"names":[],"mappings":";;;;;;AAAA,qDAAgD;AAAvC,sGAAA,OAAO,OAAA;AAChB,+BAAuC;AAA9B,qGAAA,aAAa,OAAA;AACtB,mCAAqD;AAA5C,yHAAA,OAAO,OAAkB"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { FastifyInstance } from "fastify";
|
|
3
|
-
import { KeyInfo } from "../common/keyRegistry";
|
|
4
|
-
import { ApitallyConfig } from "../common/types";
|
|
5
|
-
declare module "fastify" {
|
|
6
|
-
interface FastifyReply {
|
|
7
|
-
payload: any;
|
|
8
|
-
}
|
|
9
|
-
interface FastifyRequest {
|
|
10
|
-
consumerIdentifier?: string;
|
|
11
|
-
keyInfo?: KeyInfo;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
declare const _default: (fastify: FastifyInstance<import("fastify").RawServerDefault, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, import("fastify").FastifyBaseLogger, import("fastify").FastifyTypeProviderDefault>, config: ApitallyConfig) => Promise<void>;
|
|
15
|
-
export default _default;
|
|
16
|
-
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/fastify/plugin.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAkB,MAAM,SAAS,CAAC;AAI1D,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,cAAc,EAA6B,MAAM,iBAAiB,CAAC;AAG5E,OAAO,QAAQ,SAAS,CAAC;IACvB,UAAU,YAAY;QACpB,OAAO,EAAE,GAAG,CAAC;KACd;IAED,UAAU,cAAc;QACtB,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB;CACF;;AA8HD,wBAEG"}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const fastify_plugin_1 = __importDefault(require("fastify-plugin"));
|
|
16
|
-
const client_1 = require("../common/client");
|
|
17
|
-
const keyRegistry_1 = require("../common/keyRegistry");
|
|
18
|
-
const utils_1 = require("../common/utils");
|
|
19
|
-
const apitallyPlugin = (fastify, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
-
const client = new client_1.ApitallyClient(config);
|
|
21
|
-
const routes = [];
|
|
22
|
-
fastify.decorateRequest("consumerIdentifier", null);
|
|
23
|
-
fastify.decorateRequest("keyInfo", null);
|
|
24
|
-
fastify.decorateReply("payload", null);
|
|
25
|
-
fastify.addHook("onRoute", (routeOptions) => {
|
|
26
|
-
const methods = Array.isArray(routeOptions.method)
|
|
27
|
-
? routeOptions.method
|
|
28
|
-
: [routeOptions.method];
|
|
29
|
-
methods.forEach((method) => {
|
|
30
|
-
routeOptions.onSend;
|
|
31
|
-
if (method !== "HEAD") {
|
|
32
|
-
routes.push({
|
|
33
|
-
method: method,
|
|
34
|
-
path: routeOptions.url,
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
fastify.addHook("onReady", () => {
|
|
40
|
-
client.setAppInfo(getAppInfo(routes, config.appVersion));
|
|
41
|
-
});
|
|
42
|
-
fastify.addHook("onSend", (request, reply, payload, done) => {
|
|
43
|
-
try {
|
|
44
|
-
reply.payload = JSON.parse(payload);
|
|
45
|
-
}
|
|
46
|
-
catch (error) { } // eslint-disable-line no-empty
|
|
47
|
-
done();
|
|
48
|
-
});
|
|
49
|
-
fastify.addHook("onResponse", (request, reply, done) => {
|
|
50
|
-
// Get path from routeOptions if available (from v4), otherwise fallback to deprecated routerPath
|
|
51
|
-
const path = "routeOptions" in request
|
|
52
|
-
? request.routeOptions.url
|
|
53
|
-
: request.routerPath;
|
|
54
|
-
client.requestLogger.logRequest({
|
|
55
|
-
consumer: getConsumer(request),
|
|
56
|
-
method: request.method,
|
|
57
|
-
path: path,
|
|
58
|
-
statusCode: reply.statusCode,
|
|
59
|
-
responseTime: reply.getResponseTime(),
|
|
60
|
-
});
|
|
61
|
-
if ((reply.statusCode === 400 || reply.statusCode === 422) &&
|
|
62
|
-
reply.payload &&
|
|
63
|
-
(!reply.payload.code || reply.payload.code === "FST_ERR_VALIDATION") &&
|
|
64
|
-
typeof reply.payload.message === "string") {
|
|
65
|
-
const validationErrors = extractAjvErrors(reply.payload.message);
|
|
66
|
-
validationErrors.forEach((error) => {
|
|
67
|
-
client.validationErrorLogger.logValidationError(Object.assign({ consumer: getConsumer(request), method: request.method, path: path }, error));
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
done();
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
const getAppInfo = (routes, appVersion) => {
|
|
74
|
-
const versions = [["nodejs", process.version]];
|
|
75
|
-
const fastifyVersion = (0, utils_1.getPackageVersion)("fastify");
|
|
76
|
-
const apitallyVersion = (0, utils_1.getPackageVersion)("../..");
|
|
77
|
-
if (fastifyVersion) {
|
|
78
|
-
versions.push(["fastify", fastifyVersion]);
|
|
79
|
-
}
|
|
80
|
-
if (apitallyVersion) {
|
|
81
|
-
versions.push(["apitally", apitallyVersion]);
|
|
82
|
-
}
|
|
83
|
-
if (appVersion) {
|
|
84
|
-
versions.push(["app", appVersion]);
|
|
85
|
-
}
|
|
86
|
-
return {
|
|
87
|
-
paths: routes,
|
|
88
|
-
versions: new Map(versions),
|
|
89
|
-
client: "js:fastify",
|
|
90
|
-
};
|
|
91
|
-
};
|
|
92
|
-
const getConsumer = (request) => {
|
|
93
|
-
if (request.consumerIdentifier) {
|
|
94
|
-
return String(request.consumerIdentifier);
|
|
95
|
-
}
|
|
96
|
-
if (request.keyInfo && request.keyInfo instanceof keyRegistry_1.KeyInfo) {
|
|
97
|
-
return `key:${request.keyInfo.keyId}`;
|
|
98
|
-
}
|
|
99
|
-
return null;
|
|
100
|
-
};
|
|
101
|
-
const extractAjvErrors = (message) => {
|
|
102
|
-
const regex = /(?<=^|, )((?:headers|params|query|querystring|body)[/.][^ ]+)(?= )/g;
|
|
103
|
-
const matches = [];
|
|
104
|
-
let match;
|
|
105
|
-
while ((match = regex.exec(message)) !== null) {
|
|
106
|
-
matches.push({ match: match[0], index: match.index });
|
|
107
|
-
}
|
|
108
|
-
return matches.map((m, i) => {
|
|
109
|
-
const endIndex = i + 1 < matches.length ? matches[i + 1].index - 2 : message.length;
|
|
110
|
-
const matchSplit = m.match.split(/[/.]/);
|
|
111
|
-
if (matchSplit[0] === "querystring") {
|
|
112
|
-
matchSplit[0] = "query";
|
|
113
|
-
}
|
|
114
|
-
return {
|
|
115
|
-
loc: matchSplit.join("."),
|
|
116
|
-
msg: message.substring(m.index, endIndex),
|
|
117
|
-
type: "",
|
|
118
|
-
};
|
|
119
|
-
});
|
|
120
|
-
};
|
|
121
|
-
exports.default = (0, fastify_plugin_1.default)(apitallyPlugin, {
|
|
122
|
-
name: "apitally",
|
|
123
|
-
});
|
|
124
|
-
//# sourceMappingURL=plugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../src/fastify/plugin.ts"],"names":[],"mappings":";;;;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IACxE,MAAM,OAAO,GAAuC,EAAE,CAAC;IACvD,IAAI,KAA6B,CAAC;IAClC,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,IAAI,EAAE;QAC7C,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;KACvD;IAED,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QAC1B,MAAM,QAAQ,GACZ,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;QACrE,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACzC,IAAI,UAAU,CAAC,CAAC,CAAC,KAAK,aAAa,EAAE;YACnC,UAAU,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;SACzB;QACD,OAAO;YACL,GAAG,EAAE,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC;YACzB,GAAG,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,EAAE,QAAQ,CAAC;YACzC,IAAI,EAAE,EAAE;SACT,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,kBAAe,IAAA,wBAAE,EAAC,cAAc,EAAE;IAChC,IAAI,EAAE,UAAU;CACjB,CAAC,CAAC"}
|
package/dist/src/index.js
DELETED
package/dist/src/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":""}
|