@duplojs/http 0.7.4 → 0.8.5
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/client/getBody.cjs +3 -3
- package/dist/client/getBody.mjs +3 -3
- package/dist/client/hooks.cjs +45 -0
- package/dist/client/hooks.d.ts +6 -1
- package/dist/client/hooks.mjs +41 -1
- package/dist/client/httpClient.cjs +25 -1
- package/dist/client/httpClient.d.ts +8 -3
- package/dist/client/httpClient.mjs +25 -1
- package/dist/client/index.cjs +7 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.mjs +2 -1
- package/dist/client/insertParamsInPath.cjs +1 -1
- package/dist/client/insertParamsInPath.mjs +1 -1
- package/dist/client/promiseRequest.cjs +83 -26
- package/dist/client/promiseRequest.d.ts +46 -29
- package/dist/client/promiseRequest.mjs +83 -26
- package/dist/client/queryToString.cjs +1 -1
- package/dist/client/queryToString.mjs +1 -1
- package/dist/client/serverSentEvents.cjs +231 -0
- package/dist/client/serverSentEvents.d.ts +2 -0
- package/dist/client/serverSentEvents.mjs +208 -0
- package/dist/client/types/clientRequestParams.d.ts +2 -0
- package/dist/client/types/clientResponse.d.ts +34 -3
- package/dist/client/types/hooks.d.ts +17 -7
- package/dist/client/types/promiseRequestParams.d.ts +1 -0
- package/dist/client/types/serverRoute.d.ts +2 -0
- package/dist/core/builders/route/handler.d.ts +5 -2
- package/dist/core/defaultHooks/index.cjs +8 -0
- package/dist/core/defaultHooks/index.d.ts +1 -1
- package/dist/core/defaultHooks/index.mjs +8 -0
- package/dist/core/functionsBuilders/route/default.cjs +9 -13
- package/dist/core/functionsBuilders/route/default.mjs +2 -6
- package/dist/core/functionsBuilders/steps/create.d.ts +2 -2
- package/dist/core/functionsBuilders/steps/defaults/cutStep.cjs +1 -1
- package/dist/core/functionsBuilders/steps/defaults/cutStep.mjs +1 -1
- package/dist/core/functionsBuilders/steps/defaults/handlerStep.cjs +37 -17
- package/dist/core/functionsBuilders/steps/defaults/handlerStep.mjs +37 -17
- package/dist/core/functionsBuilders/steps/defaults/processStep.cjs +3 -3
- package/dist/core/functionsBuilders/steps/defaults/processStep.mjs +3 -3
- package/dist/core/hub/defaultEmptyReaderImplementation.cjs +9 -0
- package/dist/core/hub/defaultEmptyReaderImplementation.d.ts +1 -0
- package/dist/core/hub/defaultEmptyReaderImplementation.mjs +7 -0
- package/dist/core/hub/defaultMalformedUrlHandler.cjs +14 -0
- package/dist/core/hub/defaultMalformedUrlHandler.d.ts +10 -0
- package/dist/core/hub/defaultMalformedUrlHandler.mjs +12 -0
- package/dist/core/hub/defaultNotfoundHandler.d.ts +1 -1
- package/dist/core/hub/index.cjs +14 -1
- package/dist/core/hub/index.d.ts +4 -0
- package/dist/core/hub/index.mjs +13 -2
- package/dist/core/implementHttpServer.cjs +7 -2
- package/dist/core/implementHttpServer.d.ts +7 -1
- package/dist/core/implementHttpServer.mjs +5 -0
- package/dist/core/index.cjs +18 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.mjs +8 -2
- package/dist/core/request/bodyController/base.cjs +24 -6
- package/dist/core/request/bodyController/base.d.ts +9 -0
- package/dist/core/request/bodyController/base.mjs +25 -8
- package/dist/core/request/bodyController/empty.cjs +11 -0
- package/dist/core/request/bodyController/empty.d.ts +3 -0
- package/dist/core/request/bodyController/empty.mjs +8 -0
- package/dist/core/request/bodyController/formData.cjs +1 -0
- package/dist/core/request/bodyController/formData.d.ts +4 -2
- package/dist/core/request/bodyController/formData.mjs +1 -0
- package/dist/core/request/bodyController/index.cjs +4 -0
- package/dist/core/request/bodyController/index.d.ts +1 -0
- package/dist/core/request/bodyController/index.mjs +2 -1
- package/dist/core/request/index.cjs +5 -0
- package/dist/core/request/index.d.ts +1 -1
- package/dist/core/request/index.mjs +6 -1
- package/dist/core/response/contract.cjs +17 -4
- package/dist/core/response/contract.d.ts +19 -4
- package/dist/core/response/contract.mjs +17 -4
- package/dist/core/response/index.cjs +2 -0
- package/dist/core/response/index.d.ts +1 -0
- package/dist/core/response/index.mjs +1 -0
- package/dist/core/response/serverSentEventsPredicted.cjs +23 -0
- package/dist/core/response/serverSentEventsPredicted.d.ts +14 -0
- package/dist/core/response/serverSentEventsPredicted.mjs +21 -0
- package/dist/core/route/hooks.cjs +9 -0
- package/dist/core/route/hooks.d.ts +10 -9
- package/dist/core/route/hooks.mjs +9 -1
- package/dist/core/route/index.cjs +1 -0
- package/dist/core/route/index.mjs +1 -1
- package/dist/core/router/buildSystemRoute.cjs +33 -0
- package/dist/core/router/buildSystemRoute.d.ts +11 -0
- package/dist/core/router/buildSystemRoute.mjs +31 -0
- package/dist/core/router/decodeUrl.cjs +5 -4
- package/dist/core/router/decodeUrl.d.ts +1 -1
- package/dist/core/router/decodeUrl.mjs +5 -4
- package/dist/core/router/index.cjs +24 -23
- package/dist/core/router/index.d.ts +1 -0
- package/dist/core/router/index.mjs +25 -25
- package/dist/core/serverSentEvents.cjs +96 -0
- package/dist/core/serverSentEvents.d.ts +33 -0
- package/dist/core/serverSentEvents.mjs +96 -0
- package/dist/core/steps/cut.d.ts +2 -2
- package/dist/core/steps/handler.d.ts +10 -5
- package/dist/interfaces/node/bodyReaders/formData/index.cjs +34 -14
- package/dist/interfaces/node/bodyReaders/formData/index.mjs +35 -15
- package/dist/interfaces/node/bodyReaders/formData/readRequestFormData.cjs +18 -12
- package/dist/interfaces/node/bodyReaders/formData/readRequestFormData.d.ts +2 -1
- package/dist/interfaces/node/bodyReaders/formData/readRequestFormData.mjs +18 -12
- package/dist/interfaces/node/createHttpServer.cjs +2 -3
- package/dist/interfaces/node/createHttpServer.mjs +2 -3
- package/dist/interfaces/node/hooks/index.cjs +61 -38
- package/dist/interfaces/node/hooks/index.d.ts +6 -4
- package/dist/interfaces/node/hooks/index.mjs +61 -38
- package/dist/interfaces/node/index.cjs +1 -1
- package/dist/interfaces/node/index.mjs +1 -1
- package/dist/plugins/cacheController/createResponseHeader.cjs +43 -0
- package/dist/plugins/cacheController/createResponseHeader.d.ts +2 -0
- package/dist/plugins/cacheController/createResponseHeader.mjs +41 -0
- package/dist/plugins/cacheController/hooks.cjs +23 -0
- package/dist/plugins/cacheController/hooks.d.ts +4 -0
- package/dist/plugins/cacheController/hooks.mjs +21 -0
- package/dist/plugins/cacheController/index.cjs +10 -0
- package/dist/plugins/cacheController/index.d.ts +3 -0
- package/dist/plugins/cacheController/index.mjs +3 -0
- package/dist/plugins/cacheController/types/cacheControlDirectives.cjs +2 -0
- package/dist/plugins/cacheController/types/cacheControlDirectives.d.ts +16 -0
- package/dist/plugins/cacheController/types/cacheControlDirectives.mjs +1 -0
- package/dist/plugins/cacheController/types/index.cjs +4 -0
- package/dist/plugins/cacheController/types/index.d.ts +1 -0
- package/dist/plugins/cacheController/types/index.mjs +1 -0
- package/dist/plugins/codeGenerator/aggregateStepContract.cjs +9 -2
- package/dist/plugins/codeGenerator/aggregateStepContract.d.ts +1 -1
- package/dist/plugins/codeGenerator/aggregateStepContract.mjs +10 -3
- package/dist/plugins/codeGenerator/plugin.cjs +4 -4
- package/dist/plugins/codeGenerator/plugin.mjs +1 -1
- package/dist/plugins/openApiGenerator/aggregateStepContract.d.ts +2 -7
- package/dist/plugins/openApiGenerator/routeToOpenApi.cjs +46 -8
- package/dist/plugins/openApiGenerator/routeToOpenApi.d.ts +2 -2
- package/dist/plugins/openApiGenerator/routeToOpenApi.mjs +46 -8
- package/dist/plugins/openApiGenerator/types/endpointResponse.d.ts +7 -3
- package/dist/plugins/static/index.cjs +14 -0
- package/dist/plugins/static/index.d.ts +3 -0
- package/dist/plugins/static/index.mjs +3 -0
- package/dist/plugins/static/kind.cjs +9 -0
- package/dist/plugins/static/kind.d.ts +6 -0
- package/dist/plugins/static/kind.mjs +7 -0
- package/dist/plugins/static/makeRouteFile.cjs +62 -0
- package/dist/plugins/static/makeRouteFile.d.ts +48 -0
- package/dist/plugins/static/makeRouteFile.mjs +58 -0
- package/dist/plugins/static/makeRouteFolder.cjs +67 -0
- package/dist/plugins/static/makeRouteFolder.d.ts +39 -0
- package/dist/plugins/static/makeRouteFolder.mjs +65 -0
- package/dist/plugins/static/plugin.cjs +53 -0
- package/dist/plugins/static/plugin.d.ts +26 -0
- package/dist/plugins/static/plugin.mjs +50 -0
- package/package.json +18 -7
- /package/dist/plugins/codeGenerator/{typescriptTransfomer.cjs → typescriptTransformer.cjs} +0 -0
- /package/dist/plugins/codeGenerator/{typescriptTransfomer.d.ts → typescriptTransformer.d.ts} +0 -0
- /package/dist/plugins/codeGenerator/{typescriptTransfomer.mjs → typescriptTransformer.mjs} +0 -0
|
@@ -1,24 +1,41 @@
|
|
|
1
1
|
import { createCoreLibKind } from '../../kind.mjs';
|
|
2
|
-
import { E } from '@duplojs/utils';
|
|
2
|
+
import { kindHeritage, E, unwrap } from '@duplojs/utils';
|
|
3
3
|
|
|
4
4
|
const bodyReaderKind = createCoreLibKind("body-reader");
|
|
5
5
|
const bodyReaderImplementationKind = createCoreLibKind("body-reader-implementation");
|
|
6
6
|
const bodyControllerKind = createCoreLibKind("body-controller");
|
|
7
7
|
const bodyControllerHandlerKind = createCoreLibKind("body-controller-handler");
|
|
8
|
+
class WrongBodyReaderImplementationError extends kindHeritage("wrong-body-reader-implementation", createCoreLibKind("wrong-body-reader-implementation"), Error) {
|
|
9
|
+
controllerName;
|
|
10
|
+
bodyReaderImplementation;
|
|
11
|
+
constructor(controllerName, bodyReaderImplementation) {
|
|
12
|
+
super({}, ["Received wrong body reader implementation."]);
|
|
13
|
+
this.controllerName = controllerName;
|
|
14
|
+
this.bodyReaderImplementation = bodyReaderImplementation;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
8
17
|
function createBodyController(name) {
|
|
9
18
|
return bodyControllerHandlerKind.setTo({
|
|
10
19
|
name,
|
|
11
20
|
create(params) {
|
|
21
|
+
function tryToCreateReader(readerImplementation) {
|
|
22
|
+
if (bodyReaderImplementationKind.getValue(readerImplementation) !== name) {
|
|
23
|
+
return E.fail();
|
|
24
|
+
}
|
|
25
|
+
return E.success(bodyReaderKind.setTo({
|
|
26
|
+
read: (request) => readerImplementation.read(request, params),
|
|
27
|
+
}, name));
|
|
28
|
+
}
|
|
12
29
|
return bodyControllerKind.setTo({
|
|
13
30
|
name,
|
|
14
31
|
params,
|
|
15
|
-
tryToCreateReader
|
|
16
|
-
|
|
17
|
-
|
|
32
|
+
tryToCreateReader,
|
|
33
|
+
createReaderOrThrow(readerImplementation) {
|
|
34
|
+
const result = tryToCreateReader(readerImplementation);
|
|
35
|
+
if (E.isLeft(result)) {
|
|
36
|
+
throw new WrongBodyReaderImplementationError(name, readerImplementation);
|
|
18
37
|
}
|
|
19
|
-
return
|
|
20
|
-
read: (request) => readerImplementation.read(request, params),
|
|
21
|
-
}, name));
|
|
38
|
+
return unwrap(result);
|
|
22
39
|
},
|
|
23
40
|
}, name);
|
|
24
41
|
},
|
|
@@ -31,4 +48,4 @@ function createBodyController(name) {
|
|
|
31
48
|
});
|
|
32
49
|
}
|
|
33
50
|
|
|
34
|
-
export { createBodyController };
|
|
51
|
+
export { WrongBodyReaderImplementationError, createBodyController };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var base = require('./base.cjs');
|
|
4
|
+
|
|
5
|
+
const EmptyBodyController = base.createBodyController("empty");
|
|
6
|
+
function controlBodyAsEmpty() {
|
|
7
|
+
return EmptyBodyController.create({});
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
exports.EmptyBodyController = EmptyBodyController;
|
|
11
|
+
exports.controlBodyAsEmpty = controlBodyAsEmpty;
|
|
@@ -9,6 +9,7 @@ function controlBodyAsFormData(params) {
|
|
|
9
9
|
maxFileQuantity: params.maxFileQuantity,
|
|
10
10
|
bodyMaxSize: params.bodyMaxSize && utils.stringToBytes(params.bodyMaxSize),
|
|
11
11
|
fileMaxSize: params.fileMaxSize && utils.stringToBytes(params.fileMaxSize),
|
|
12
|
+
textFieldMaxSize: params.textFieldMaxSize && utils.stringToBytes(params.textFieldMaxSize),
|
|
12
13
|
mimeType: params.mimeType !== undefined
|
|
13
14
|
? utils.toRegExp(params.mimeType)
|
|
14
15
|
: undefined,
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { type BytesInString } from "@duplojs/utils";
|
|
1
|
+
import { type AnyTuple, type BytesInString } from "@duplojs/utils";
|
|
2
2
|
import { type BodyControllerParams } from "./base";
|
|
3
3
|
export interface FormDataBodyReaderParams extends BodyControllerParams {
|
|
4
4
|
maxFileQuantity: number;
|
|
5
5
|
mimeType?: RegExp;
|
|
6
6
|
fileMaxSize?: number;
|
|
7
|
+
textFieldMaxSize?: number;
|
|
7
8
|
maxBufferSize: number;
|
|
8
9
|
maxIndexArray: number;
|
|
9
10
|
maxKeyLength: number;
|
|
@@ -12,9 +13,10 @@ export declare const FormDataBodyController: import("./base").BodyControllerHand
|
|
|
12
13
|
export type FormDataBodyController = typeof FormDataBodyController;
|
|
13
14
|
export interface ControlBodyAsFormDataParams {
|
|
14
15
|
maxFileQuantity: number;
|
|
15
|
-
mimeType?: string | string
|
|
16
|
+
mimeType?: string | AnyTuple<string> | RegExp;
|
|
16
17
|
bodyMaxSize?: number | BytesInString;
|
|
17
18
|
fileMaxSize?: number | BytesInString;
|
|
19
|
+
textFieldMaxSize?: number | BytesInString;
|
|
18
20
|
maxBufferSize?: number | BytesInString;
|
|
19
21
|
maxIndexArray?: number;
|
|
20
22
|
maxKeyLength?: number;
|
|
@@ -7,6 +7,7 @@ function controlBodyAsFormData(params) {
|
|
|
7
7
|
maxFileQuantity: params.maxFileQuantity,
|
|
8
8
|
bodyMaxSize: params.bodyMaxSize && stringToBytes(params.bodyMaxSize),
|
|
9
9
|
fileMaxSize: params.fileMaxSize && stringToBytes(params.fileMaxSize),
|
|
10
|
+
textFieldMaxSize: params.textFieldMaxSize && stringToBytes(params.textFieldMaxSize),
|
|
10
11
|
mimeType: params.mimeType !== undefined
|
|
11
12
|
? toRegExp(params.mimeType)
|
|
12
13
|
: undefined,
|
|
@@ -3,11 +3,15 @@
|
|
|
3
3
|
var base = require('./base.cjs');
|
|
4
4
|
var formData = require('./formData.cjs');
|
|
5
5
|
var text = require('./text.cjs');
|
|
6
|
+
var empty = require('./empty.cjs');
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
|
|
10
|
+
exports.WrongBodyReaderImplementationError = base.WrongBodyReaderImplementationError;
|
|
9
11
|
exports.createBodyController = base.createBodyController;
|
|
10
12
|
exports.FormDataBodyController = formData.FormDataBodyController;
|
|
11
13
|
exports.controlBodyAsFormData = formData.controlBodyAsFormData;
|
|
12
14
|
exports.TextBodyController = text.TextBodyController;
|
|
13
15
|
exports.controlBodyAsText = text.controlBodyAsText;
|
|
16
|
+
exports.EmptyBodyController = empty.EmptyBodyController;
|
|
17
|
+
exports.controlBodyAsEmpty = empty.controlBodyAsEmpty;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export { createBodyController } from './base.mjs';
|
|
1
|
+
export { WrongBodyReaderImplementationError, createBodyController } from './base.mjs';
|
|
2
2
|
export { FormDataBodyController, controlBodyAsFormData } from './formData.mjs';
|
|
3
3
|
export { TextBodyController, controlBodyAsText } from './text.mjs';
|
|
4
|
+
export { EmptyBodyController, controlBodyAsEmpty } from './empty.mjs';
|
|
@@ -45,6 +45,11 @@ class Request extends utils.kindHeritage("request", kind.createCoreLibKind("requ
|
|
|
45
45
|
externalPromise.resolve(result);
|
|
46
46
|
this.bodyResult = result;
|
|
47
47
|
return result;
|
|
48
|
+
})
|
|
49
|
+
.catch((error) => {
|
|
50
|
+
const result = utils.E.error(error);
|
|
51
|
+
externalPromise.resolve(result);
|
|
52
|
+
return result;
|
|
48
53
|
});
|
|
49
54
|
}
|
|
50
55
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { E, type MaybePromise } from "@duplojs/utils";
|
|
2
2
|
import { type GetPropsWithValue } from "@duplojs/utils/object";
|
|
3
3
|
import { type BodyReader } from "./bodyController";
|
|
4
4
|
export * from "./bodyController";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { kindHeritage, createExternalPromise } from '@duplojs/utils';
|
|
1
|
+
import { kindHeritage, createExternalPromise, E } from '@duplojs/utils';
|
|
2
2
|
import { createCoreLibKind } from '../kind.mjs';
|
|
3
3
|
import './bodyController/index.mjs';
|
|
4
4
|
|
|
@@ -43,6 +43,11 @@ class Request extends kindHeritage("request", createCoreLibKind("request")) {
|
|
|
43
43
|
externalPromise.resolve(result);
|
|
44
44
|
this.bodyResult = result;
|
|
45
45
|
return result;
|
|
46
|
+
})
|
|
47
|
+
.catch((error) => {
|
|
48
|
+
const result = E.error(error);
|
|
49
|
+
externalPromise.resolve(result);
|
|
50
|
+
return result;
|
|
46
51
|
});
|
|
47
52
|
}
|
|
48
53
|
}
|
|
@@ -78,13 +78,26 @@ exports.ResponseContract = void 0;
|
|
|
78
78
|
ResponseContract.loopDetected = createContractBuilder("508", { defaultSchema });
|
|
79
79
|
ResponseContract.notExtended = createContractBuilder("510", { defaultSchema });
|
|
80
80
|
ResponseContract.networkAuthenticationRequired = createContractBuilder("511", { defaultSchema });
|
|
81
|
+
ResponseContract.serverSentEventsContractKind = kind.createCoreLibKind("server-sent-events-response-contract");
|
|
82
|
+
function serverSentEvents(information, mainEventSchema, events = {}) {
|
|
83
|
+
return ResponseContract.serverSentEventsContractKind.setTo({
|
|
84
|
+
code: "200",
|
|
85
|
+
information,
|
|
86
|
+
events: {
|
|
87
|
+
...events,
|
|
88
|
+
message: mainEventSchema,
|
|
89
|
+
},
|
|
90
|
+
body: defaultSchema,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
ResponseContract.serverSentEvents = serverSentEvents;
|
|
81
94
|
class Error extends utils.kindHeritage("contract-error", kind.createCoreLibKind("contract-error"), ErrorClass) {
|
|
82
95
|
information;
|
|
83
|
-
|
|
84
|
-
constructor(information,
|
|
85
|
-
super({}, [`Error executing the response contract with the information: "${information}"
|
|
96
|
+
detail;
|
|
97
|
+
constructor(information, detail) {
|
|
98
|
+
super({}, [`Error executing the response contract with the information: "${information}"`]);
|
|
86
99
|
this.information = information;
|
|
87
|
-
this.
|
|
100
|
+
this.detail = detail;
|
|
88
101
|
}
|
|
89
102
|
}
|
|
90
103
|
ResponseContract.Error = Error;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DP, type Kind, type NeverCoalescing } from "@duplojs/utils";
|
|
2
|
-
import { type ResponseCode, type PredictedResponse } from ".";
|
|
2
|
+
import { type ResponseCode, type PredictedResponse, type ServerSentEventsPredictedResponse, type SuccessResponseCode } from ".";
|
|
3
3
|
import { type ForbiddenBigintDataParser } from "../types";
|
|
4
4
|
export declare namespace ResponseContract {
|
|
5
5
|
type SupportedDataParser = DP.DataParser;
|
|
@@ -9,7 +9,6 @@ export declare namespace ResponseContract {
|
|
|
9
9
|
information: GenericInformation;
|
|
10
10
|
body: GenericSchema;
|
|
11
11
|
}
|
|
12
|
-
export type Convert<GenericContract extends Contract> = GenericContract extends Contract ? PredictedResponse<GenericContract["code"], GenericContract["information"], DP.Input<GenericContract["body"]>> : never;
|
|
13
12
|
export const http100Continue: <GenericInformation extends string, GenericSchema extends SupportedDataParser = DP.DataParserEmpty<{
|
|
14
13
|
readonly errorMessage?: string | undefined;
|
|
15
14
|
readonly coerce: boolean;
|
|
@@ -281,13 +280,29 @@ export declare namespace ResponseContract {
|
|
|
281
280
|
readonly coerce: boolean;
|
|
282
281
|
readonly checkers: readonly [];
|
|
283
282
|
}>>(information: GenericInformation, schema?: (GenericSchema & ForbiddenBigintDataParser<GenericSchema>) | undefined) => NoInfer<Contract<"511", GenericInformation, NeverCoalescing<GenericSchema, DP.DataParserEmpty<DP.DataParserDefinitionEmpty>>>>;
|
|
283
|
+
export const serverSentEventsContractKind: import("@duplojs/utils").KindHandler<import("@duplojs/utils").KindDefinition<"@DuplojsHttpCore/server-sent-events-response-contract", unknown>>;
|
|
284
|
+
export interface ServerSentEventsContract<GenericCode extends SuccessResponseCode = SuccessResponseCode, GenericInformation extends string = string, GenericEvents extends Record<string, SupportedDataParser> = Record<string, SupportedDataParser>, GenericSchema extends SupportedDataParser = SupportedDataParser> extends Kind<typeof serverSentEventsContractKind.definition> {
|
|
285
|
+
code: GenericCode;
|
|
286
|
+
information: GenericInformation;
|
|
287
|
+
events: GenericEvents;
|
|
288
|
+
body: GenericSchema;
|
|
289
|
+
}
|
|
290
|
+
export function serverSentEvents<GenericInformation extends string, GenericMainEventSchema extends SupportedDataParser, GenericEvents extends Record<string, SupportedDataParser> = {}>(information: GenericInformation, mainEventSchema: GenericMainEventSchema, events?: GenericEvents): ServerSentEventsContract<"200", GenericInformation, GenericEvents & {
|
|
291
|
+
message: GenericMainEventSchema;
|
|
292
|
+
}>;
|
|
293
|
+
export type Convert<GenericContract extends Contract | ServerSentEventsContract> = GenericContract extends Contract ? PredictedResponse<GenericContract["code"], GenericContract["information"], DP.Input<GenericContract["body"]>> : GenericContract extends ServerSentEventsContract ? ServerSentEventsPredictedResponse<GenericContract["code"], GenericContract["information"], {
|
|
294
|
+
[Prop in keyof GenericContract["events"]]: [
|
|
295
|
+
Extract<Prop, string>,
|
|
296
|
+
DP.Output<GenericContract["events"][Prop]>
|
|
297
|
+
];
|
|
298
|
+
}[keyof GenericContract["events"]]> : never;
|
|
284
299
|
const Error_base: new (params: {
|
|
285
300
|
"@DuplojsHttpCore/contract-error"?: unknown;
|
|
286
301
|
}, parentParams: readonly [message?: string | undefined, options?: ErrorOptions | undefined]) => globalThis.Error & Kind<import("@duplojs/utils").KindDefinition<"@DuplojsHttpCore/contract-error", unknown>, unknown> & Kind<import("@duplojs/utils").KindDefinition<"contract-error", unknown>, unknown>;
|
|
287
302
|
export class Error extends Error_base {
|
|
288
303
|
information: string;
|
|
289
|
-
|
|
290
|
-
constructor(information: string,
|
|
304
|
+
detail: DP.DataParserError | string;
|
|
305
|
+
constructor(information: string, detail: DP.DataParserError | string);
|
|
291
306
|
}
|
|
292
307
|
export {};
|
|
293
308
|
}
|
|
@@ -76,13 +76,26 @@ var ResponseContract;
|
|
|
76
76
|
ResponseContract.loopDetected = createContractBuilder("508", { defaultSchema });
|
|
77
77
|
ResponseContract.notExtended = createContractBuilder("510", { defaultSchema });
|
|
78
78
|
ResponseContract.networkAuthenticationRequired = createContractBuilder("511", { defaultSchema });
|
|
79
|
+
ResponseContract.serverSentEventsContractKind = createCoreLibKind("server-sent-events-response-contract");
|
|
80
|
+
function serverSentEvents(information, mainEventSchema, events = {}) {
|
|
81
|
+
return ResponseContract.serverSentEventsContractKind.setTo({
|
|
82
|
+
code: "200",
|
|
83
|
+
information,
|
|
84
|
+
events: {
|
|
85
|
+
...events,
|
|
86
|
+
message: mainEventSchema,
|
|
87
|
+
},
|
|
88
|
+
body: defaultSchema,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
ResponseContract.serverSentEvents = serverSentEvents;
|
|
79
92
|
class Error extends kindHeritage("contract-error", createCoreLibKind("contract-error"), ErrorClass) {
|
|
80
93
|
information;
|
|
81
|
-
|
|
82
|
-
constructor(information,
|
|
83
|
-
super({}, [`Error executing the response contract with the information: "${information}"
|
|
94
|
+
detail;
|
|
95
|
+
constructor(information, detail) {
|
|
96
|
+
super({}, [`Error executing the response contract with the information: "${information}"`]);
|
|
84
97
|
this.information = information;
|
|
85
|
-
this.
|
|
98
|
+
this.detail = detail;
|
|
86
99
|
}
|
|
87
100
|
}
|
|
88
101
|
ResponseContract.Error = Error;
|
|
@@ -4,6 +4,7 @@ var base = require('./base.cjs');
|
|
|
4
4
|
var contract = require('./contract.cjs');
|
|
5
5
|
var hook = require('./hook.cjs');
|
|
6
6
|
var predicted = require('./predicted.cjs');
|
|
7
|
+
var serverSentEventsPredicted = require('./serverSentEventsPredicted.cjs');
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
|
|
@@ -14,3 +15,4 @@ Object.defineProperty(exports, "ResponseContract", {
|
|
|
14
15
|
});
|
|
15
16
|
exports.HookResponse = hook.HookResponse;
|
|
16
17
|
exports.PredictedResponse = predicted.PredictedResponse;
|
|
18
|
+
exports.ServerSentEventsPredictedResponse = serverSentEventsPredicted.ServerSentEventsPredictedResponse;
|
|
@@ -2,3 +2,4 @@ export { Response } from './base.mjs';
|
|
|
2
2
|
export { ResponseContract } from './contract.mjs';
|
|
3
3
|
export { HookResponse } from './hook.mjs';
|
|
4
4
|
export { PredictedResponse } from './predicted.mjs';
|
|
5
|
+
export { ServerSentEventsPredictedResponse } from './serverSentEventsPredicted.mjs';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var kind = require('../kind.cjs');
|
|
4
|
+
require('./index.cjs');
|
|
5
|
+
var utils = require('@duplojs/utils');
|
|
6
|
+
var base = require('./base.cjs');
|
|
7
|
+
|
|
8
|
+
const defaultParamsParent = [undefined, undefined, undefined];
|
|
9
|
+
const defaultParams = {};
|
|
10
|
+
class ServerSentEventsPredictedResponse extends utils.kindHeritage("server-sent-events-predicted-response", kind.createCoreLibKind("server-sent-events-predicted-response"), base.Response) {
|
|
11
|
+
startSendingEvents;
|
|
12
|
+
code;
|
|
13
|
+
information;
|
|
14
|
+
body = undefined;
|
|
15
|
+
constructor(code, information, startSendingEvents) {
|
|
16
|
+
super(defaultParams, defaultParamsParent);
|
|
17
|
+
this.startSendingEvents = startSendingEvents;
|
|
18
|
+
this.code = code;
|
|
19
|
+
this.information = information;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
exports.ServerSentEventsPredictedResponse = ServerSentEventsPredictedResponse;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Response, type SuccessResponseCode } from "../response";
|
|
2
|
+
import { type ServerSentEvents } from "../serverSentEvents";
|
|
3
|
+
import { type MaybePromise } from "@duplojs/utils";
|
|
4
|
+
declare const ServerSentEventsPredictedResponse_base: new (params: {
|
|
5
|
+
"@DuplojsHttpCore/server-sent-events-predicted-response"?: unknown;
|
|
6
|
+
}, parentParams: readonly [code: any, information: any, body: any]) => Response<any, any, any> & import("@duplojs/utils").Kind<import("@duplojs/utils").KindDefinition<"@DuplojsHttpCore/server-sent-events-predicted-response", unknown>, unknown> & import("@duplojs/utils").Kind<import("@duplojs/utils").KindDefinition<"server-sent-events-predicted-response", unknown>, unknown>;
|
|
7
|
+
export declare class ServerSentEventsPredictedResponse<GenericCode extends SuccessResponseCode = SuccessResponseCode, GenericInformation extends string = string, GenericEvents extends ServerSentEvents.DefinitionShape = ServerSentEvents.DefinitionShape> extends ServerSentEventsPredictedResponse_base {
|
|
8
|
+
startSendingEvents: (params: ServerSentEvents.StartSendingParams<GenericEvents>) => MaybePromise<void>;
|
|
9
|
+
code: GenericCode;
|
|
10
|
+
information: GenericInformation;
|
|
11
|
+
body: undefined;
|
|
12
|
+
constructor(code: GenericCode, information: GenericInformation, startSendingEvents: (params: ServerSentEvents.StartSendingParams<GenericEvents>) => MaybePromise<void>);
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createCoreLibKind } from '../kind.mjs';
|
|
2
|
+
import './index.mjs';
|
|
3
|
+
import { kindHeritage } from '@duplojs/utils';
|
|
4
|
+
import { Response } from './base.mjs';
|
|
5
|
+
|
|
6
|
+
const defaultParamsParent = [undefined, undefined, undefined];
|
|
7
|
+
const defaultParams = {};
|
|
8
|
+
class ServerSentEventsPredictedResponse extends kindHeritage("server-sent-events-predicted-response", createCoreLibKind("server-sent-events-predicted-response"), Response) {
|
|
9
|
+
startSendingEvents;
|
|
10
|
+
code;
|
|
11
|
+
information;
|
|
12
|
+
body = undefined;
|
|
13
|
+
constructor(code, information, startSendingEvents) {
|
|
14
|
+
super(defaultParams, defaultParamsParent);
|
|
15
|
+
this.startSendingEvents = startSendingEvents;
|
|
16
|
+
this.code = code;
|
|
17
|
+
this.information = information;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { ServerSentEventsPredictedResponse };
|
|
@@ -13,7 +13,16 @@ function createHookRouteLifeCycle(...args) {
|
|
|
13
13
|
onConstructRequest: args[0],
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
|
+
function hookRouteLifeCycleAddRequestProperties(request) {
|
|
17
|
+
return (newProperties) => {
|
|
18
|
+
for (const key in newProperties) {
|
|
19
|
+
request[key] = newProperties[key];
|
|
20
|
+
}
|
|
21
|
+
return request;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
16
24
|
|
|
17
25
|
exports.createHookRouteLifeCycle = createHookRouteLifeCycle;
|
|
18
26
|
exports.hookRouteExitKind = hookRouteExitKind;
|
|
27
|
+
exports.hookRouteLifeCycleAddRequestProperties = hookRouteLifeCycleAddRequestProperties;
|
|
19
28
|
exports.hookRouteNextKind = hookRouteNextKind;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Request } from "../request";
|
|
2
|
-
import { type UnionToIntersection, type AnyFunction, type Kind, type MaybePromise, type SimplifyTopLevel, type IsEqual } from "@duplojs/utils";
|
|
2
|
+
import { type UnionToIntersection, type AnyFunction, type Kind, type MaybePromise, type SimplifyTopLevel, type IsEqual, type BivariantFunction } from "@duplojs/utils";
|
|
3
3
|
import { type HookResponse } from "../response";
|
|
4
4
|
import { type ResponseCode, type Response } from "../response";
|
|
5
5
|
export interface HookParamsOnConstructRequest {
|
|
@@ -38,17 +38,18 @@ export type HookBeforeSendResponse<GenericRequest extends Request = Request> = (
|
|
|
38
38
|
export type HookSendResponse<GenericRequest extends Request = Request> = (params: RouteHookParamsAfter<GenericRequest>) => MaybePromise<RouteHookExit | RouteHookNext>;
|
|
39
39
|
export type HookAfterSendResponse<GenericRequest extends Request = Request> = (params: RouteHookParamsAfter<GenericRequest>) => MaybePromise<RouteHookExit | RouteHookNext>;
|
|
40
40
|
export interface HookRouteLifeCycle<GenericRequest extends Request = Request> {
|
|
41
|
-
onConstructRequest?: HookOnConstructRequest<GenericRequest
|
|
42
|
-
beforeRouteExecution?: HookBeforeRouteExecution<GenericRequest
|
|
41
|
+
onConstructRequest?: BivariantFunction<HookOnConstructRequest<GenericRequest>>;
|
|
42
|
+
beforeRouteExecution?: BivariantFunction<HookBeforeRouteExecution<GenericRequest>>;
|
|
43
43
|
error?: HookError;
|
|
44
|
-
beforeSendResponse?: HookBeforeSendResponse<GenericRequest
|
|
45
|
-
sendResponse?: HookSendResponse<GenericRequest
|
|
46
|
-
afterSendResponse?: HookAfterSendResponse<GenericRequest
|
|
44
|
+
beforeSendResponse?: BivariantFunction<HookBeforeSendResponse<GenericRequest>>;
|
|
45
|
+
sendResponse?: BivariantFunction<HookSendResponse<GenericRequest>>;
|
|
46
|
+
afterSendResponse?: BivariantFunction<HookAfterSendResponse<GenericRequest>>;
|
|
47
47
|
}
|
|
48
|
-
export declare function createHookRouteLifeCycle<GenericHookLiveCycle extends Omit<HookRouteLifeCycle, "onConstructRequest">>(hookRouteLifeCycle: GenericHookLiveCycle): GenericHookLiveCycle;
|
|
49
|
-
export declare function createHookRouteLifeCycle<GenericOnConstructRequest extends HookOnConstructRequest, GenericHookLiveCycle extends Omit<HookRouteLifeCycle<Awaited<ReturnType<GenericOnConstructRequest>>>, "onConstructRequest">>(onConstructRequest: GenericOnConstructRequest, hookRouteLifeCycle: GenericHookLiveCycle): SimplifyTopLevel<{
|
|
50
|
-
onConstructRequest: GenericOnConstructRequest;
|
|
48
|
+
export declare function createHookRouteLifeCycle<const GenericHookLiveCycle extends Omit<HookRouteLifeCycle, "onConstructRequest">>(hookRouteLifeCycle: GenericHookLiveCycle): GenericHookLiveCycle;
|
|
49
|
+
export declare function createHookRouteLifeCycle<GenericOnConstructRequest extends HookOnConstructRequest, const GenericHookLiveCycle extends Omit<HookRouteLifeCycle<Awaited<ReturnType<GenericOnConstructRequest>>>, "onConstructRequest">>(onConstructRequest: GenericOnConstructRequest, hookRouteLifeCycle: GenericHookLiveCycle): SimplifyTopLevel<{
|
|
50
|
+
readonly onConstructRequest: GenericOnConstructRequest;
|
|
51
51
|
} & GenericHookLiveCycle>;
|
|
52
|
+
export declare function hookRouteLifeCycleAddRequestProperties<GenericRequest extends Request = Request>(request: GenericRequest): <GenericNewProperties extends Record<string, unknown> = Record<string, unknown>>(newProperties: GenericNewProperties) => never;
|
|
52
53
|
export type ExtractRequestFromHooks<GenericHooks extends readonly HookRouteLifeCycle[]> = GenericHooks extends readonly [
|
|
53
54
|
infer InferredFirst,
|
|
54
55
|
...infer InferredRest extends HookRouteLifeCycle[]
|
|
@@ -11,5 +11,13 @@ function createHookRouteLifeCycle(...args) {
|
|
|
11
11
|
onConstructRequest: args[0],
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
+
function hookRouteLifeCycleAddRequestProperties(request) {
|
|
15
|
+
return (newProperties) => {
|
|
16
|
+
for (const key in newProperties) {
|
|
17
|
+
request[key] = newProperties[key];
|
|
18
|
+
}
|
|
19
|
+
return request;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
14
22
|
|
|
15
|
-
export { createHookRouteLifeCycle, hookRouteExitKind, hookRouteNextKind };
|
|
23
|
+
export { createHookRouteLifeCycle, hookRouteExitKind, hookRouteLifeCycleAddRequestProperties, hookRouteNextKind };
|
|
@@ -12,6 +12,7 @@ function createRoute(definition) {
|
|
|
12
12
|
|
|
13
13
|
exports.createHookRouteLifeCycle = hooks.createHookRouteLifeCycle;
|
|
14
14
|
exports.hookRouteExitKind = hooks.hookRouteExitKind;
|
|
15
|
+
exports.hookRouteLifeCycleAddRequestProperties = hooks.hookRouteLifeCycleAddRequestProperties;
|
|
15
16
|
exports.hookRouteNextKind = hooks.hookRouteNextKind;
|
|
16
17
|
exports.createRoute = createRoute;
|
|
17
18
|
exports.routeKind = routeKind;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { pipe } from '@duplojs/utils';
|
|
2
2
|
import { createCoreLibKind } from '../kind.mjs';
|
|
3
3
|
import './types/index.mjs';
|
|
4
|
-
export { createHookRouteLifeCycle, hookRouteExitKind, hookRouteNextKind } from './hooks.mjs';
|
|
4
|
+
export { createHookRouteLifeCycle, hookRouteExitKind, hookRouteLifeCycleAddRequestProperties, hookRouteNextKind } from './hooks.mjs';
|
|
5
5
|
|
|
6
6
|
const routeKind = createCoreLibKind("route");
|
|
7
7
|
function createRoute(definition) {
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var utils = require('@duplojs/utils');
|
|
4
|
+
require('../functionsBuilders/index.cjs');
|
|
5
|
+
require('../request/index.cjs');
|
|
6
|
+
var index = require('../route/index.cjs');
|
|
7
|
+
var buildError = require('./buildError.cjs');
|
|
8
|
+
var defaultEmptyReaderImplementation = require('../hub/defaultEmptyReaderImplementation.cjs');
|
|
9
|
+
var empty = require('../request/bodyController/empty.cjs');
|
|
10
|
+
var build = require('../functionsBuilders/route/build.cjs');
|
|
11
|
+
|
|
12
|
+
async function buildSystemRoute(params) {
|
|
13
|
+
const bodyController = empty.controlBodyAsEmpty();
|
|
14
|
+
const bodyReader = bodyController.createReaderOrThrow(defaultEmptyReaderImplementation.defaultEmptyReaderImplementation);
|
|
15
|
+
const route = index.createRoute({
|
|
16
|
+
method: "GET",
|
|
17
|
+
paths: ["/"],
|
|
18
|
+
hooks: [],
|
|
19
|
+
preflightSteps: [],
|
|
20
|
+
steps: [params.handlerStep],
|
|
21
|
+
metadata: [],
|
|
22
|
+
bodyController,
|
|
23
|
+
});
|
|
24
|
+
const buildedRoute = await utils.asyncPipe(build.buildRouteFunction(route, params.buildParams), utils.E.whenIsLeft((element) => {
|
|
25
|
+
throw new buildError.RouterBuildError(route, element);
|
|
26
|
+
}), utils.unwrap);
|
|
27
|
+
return {
|
|
28
|
+
bodyReader,
|
|
29
|
+
buildedRoute,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
exports.buildSystemRoute = buildSystemRoute;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type BuildRouteFunctionParams } from "../functionsBuilders";
|
|
2
|
+
import { type HandlerStep } from "../steps";
|
|
3
|
+
interface BuildSystemRouteParams {
|
|
4
|
+
handlerStep: HandlerStep;
|
|
5
|
+
buildParams: BuildRouteFunctionParams;
|
|
6
|
+
}
|
|
7
|
+
export declare function buildSystemRoute(params: BuildSystemRouteParams): Promise<{
|
|
8
|
+
bodyReader: import("../request").BodyReader<"empty">;
|
|
9
|
+
buildedRoute: import("../functionsBuilders").BuildedRouteFunction;
|
|
10
|
+
}>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { asyncPipe, E, unwrap } from '@duplojs/utils';
|
|
2
|
+
import '../functionsBuilders/index.mjs';
|
|
3
|
+
import '../request/index.mjs';
|
|
4
|
+
import { createRoute } from '../route/index.mjs';
|
|
5
|
+
import { RouterBuildError } from './buildError.mjs';
|
|
6
|
+
import { defaultEmptyReaderImplementation } from '../hub/defaultEmptyReaderImplementation.mjs';
|
|
7
|
+
import { controlBodyAsEmpty } from '../request/bodyController/empty.mjs';
|
|
8
|
+
import { buildRouteFunction } from '../functionsBuilders/route/build.mjs';
|
|
9
|
+
|
|
10
|
+
async function buildSystemRoute(params) {
|
|
11
|
+
const bodyController = controlBodyAsEmpty();
|
|
12
|
+
const bodyReader = bodyController.createReaderOrThrow(defaultEmptyReaderImplementation);
|
|
13
|
+
const route = createRoute({
|
|
14
|
+
method: "GET",
|
|
15
|
+
paths: ["/"],
|
|
16
|
+
hooks: [],
|
|
17
|
+
preflightSteps: [],
|
|
18
|
+
steps: [params.handlerStep],
|
|
19
|
+
metadata: [],
|
|
20
|
+
bodyController,
|
|
21
|
+
});
|
|
22
|
+
const buildedRoute = await asyncPipe(buildRouteFunction(route, params.buildParams), E.whenIsLeft((element) => {
|
|
23
|
+
throw new RouterBuildError(route, element);
|
|
24
|
+
}), unwrap);
|
|
25
|
+
return {
|
|
26
|
+
bodyReader,
|
|
27
|
+
buildedRoute,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { buildSystemRoute };
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const regexUrlAnalyser = /^(?<path>[^?]*)(?:\?(?<query>[^#]*))?(?:#(?<fragment>[^]*))?$/;
|
|
4
4
|
const regexQueryAnalyser = /(?<key>[^=&]+)=(?<value>[^&]*)/g;
|
|
5
|
+
const invalidEntryRegex = /__proto__|constructor|prototype/;
|
|
5
6
|
function decodeUrl(url) {
|
|
6
7
|
try {
|
|
7
8
|
const groups = regexUrlAnalyser.exec(url).groups;
|
|
@@ -17,6 +18,9 @@ function decodeUrl(url) {
|
|
|
17
18
|
for (const result of queryString.matchAll(regexQueryAnalyser)) {
|
|
18
19
|
const groups = result.groups;
|
|
19
20
|
const key = decodeURIComponent(groups.key);
|
|
21
|
+
if (invalidEntryRegex.test(key)) {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
20
24
|
const value = decodeURIComponent(groups.value);
|
|
21
25
|
const currentValue = query[key];
|
|
22
26
|
if (typeof currentValue === "undefined") {
|
|
@@ -35,10 +39,7 @@ function decodeUrl(url) {
|
|
|
35
39
|
};
|
|
36
40
|
}
|
|
37
41
|
catch {
|
|
38
|
-
return
|
|
39
|
-
path: "/",
|
|
40
|
-
query: {},
|
|
41
|
-
};
|
|
42
|
+
return null;
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const regexUrlAnalyser = /^(?<path>[^?]*)(?:\?(?<query>[^#]*))?(?:#(?<fragment>[^]*))?$/;
|
|
2
2
|
const regexQueryAnalyser = /(?<key>[^=&]+)=(?<value>[^&]*)/g;
|
|
3
|
+
const invalidEntryRegex = /__proto__|constructor|prototype/;
|
|
3
4
|
function decodeUrl(url) {
|
|
4
5
|
try {
|
|
5
6
|
const groups = regexUrlAnalyser.exec(url).groups;
|
|
@@ -15,6 +16,9 @@ function decodeUrl(url) {
|
|
|
15
16
|
for (const result of queryString.matchAll(regexQueryAnalyser)) {
|
|
16
17
|
const groups = result.groups;
|
|
17
18
|
const key = decodeURIComponent(groups.key);
|
|
19
|
+
if (invalidEntryRegex.test(key)) {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
18
22
|
const value = decodeURIComponent(groups.value);
|
|
19
23
|
const currentValue = query[key];
|
|
20
24
|
if (typeof currentValue === "undefined") {
|
|
@@ -33,10 +37,7 @@ function decodeUrl(url) {
|
|
|
33
37
|
};
|
|
34
38
|
}
|
|
35
39
|
catch {
|
|
36
|
-
return
|
|
37
|
-
path: "/",
|
|
38
|
-
query: {},
|
|
39
|
-
};
|
|
40
|
+
return null;
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
43
|
|