@adonisjs/http-server 8.0.0-next.0 → 8.0.0-next.2
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/build/{chunk-VYBTM3NC.js → chunk-Z5EN426L.js} +141 -192
- package/build/factories/http_context.d.ts +3 -3
- package/build/factories/main.d.ts +6 -6
- package/build/factories/main.js +1 -1
- package/build/factories/qs_parser_factory.d.ts +2 -2
- package/build/factories/request.d.ts +2 -2
- package/build/factories/response.d.ts +3 -3
- package/build/factories/router.d.ts +1 -1
- package/build/factories/server_factory.d.ts +2 -2
- package/build/factories/url_builder_factory.d.ts +3 -3
- package/build/index.d.ts +16 -16
- package/build/index.js +1 -1
- package/build/src/cookies/serializer.d.ts +1 -1
- package/build/src/define_config.d.ts +1 -1
- package/build/src/define_middleware.d.ts +1 -1
- package/build/src/errors.d.ts +7 -5
- package/build/src/exception_handler.d.ts +2 -2
- package/build/src/helpers.d.ts +3 -4
- package/build/src/http_context/local_storage.d.ts +1 -1
- package/build/src/http_context/main.d.ts +3 -3
- package/build/src/qs.d.ts +1 -1
- package/build/src/redirect.d.ts +4 -5
- package/build/src/request.d.ts +3 -3
- package/build/src/response.d.ts +5 -5
- package/build/src/router/brisk.d.ts +4 -4
- package/build/src/router/executor.d.ts +3 -3
- package/build/src/router/factories/use_return_value.d.ts +1 -1
- package/build/src/router/group.d.ts +5 -5
- package/build/src/router/legacy/url_builder.d.ts +1 -1
- package/build/src/router/main.d.ts +61 -17
- package/build/src/router/resource.d.ts +3 -4
- package/build/src/router/route.d.ts +2 -3
- package/build/src/router/signed_url_builder.d.ts +4 -3
- package/build/src/router/store.d.ts +1 -2
- package/build/src/{client → router}/url_builder.d.ts +4 -3
- package/build/src/server/factories/middleware_handler.d.ts +2 -2
- package/build/src/server/factories/route_finder.d.ts +3 -3
- package/build/src/server/factories/write_response.d.ts +1 -1
- package/build/src/server/main.d.ts +6 -6
- package/build/src/tracing_channels.d.ts +1 -1
- package/build/src/types/main.d.ts +1 -1
- package/build/src/types/middleware.d.ts +1 -1
- package/build/src/types/route.d.ts +19 -17
- package/build/src/types/server.d.ts +4 -4
- package/build/src/types/tracing_channels.d.ts +3 -3
- package/build/src/{client/types.d.ts → types/url_builder.d.ts} +16 -50
- package/build/src/utils.d.ts +5 -5
- package/package.json +9 -14
- package/build/client.cjs +0 -232
- package/build/client.d.cts +0 -258
- package/build/client.d.ts +0 -258
- package/build/client.js +0 -229
- package/build/src/client/main.d.ts +0 -3
- package/build/src/client/router.d.ts +0 -68
|
@@ -876,6 +876,8 @@ function safeDecodeURI(path, useSemicolonDelimiter) {
|
|
|
876
876
|
}
|
|
877
877
|
|
|
878
878
|
// src/router/route.ts
|
|
879
|
+
import StringBuilder from "@poppinss/utils/string_builder";
|
|
880
|
+
import string2 from "@poppinss/utils/string";
|
|
879
881
|
var Route = class extends Macroable4 {
|
|
880
882
|
/**
|
|
881
883
|
* Route pattern
|
|
@@ -938,8 +940,10 @@ var Route = class extends Macroable4 {
|
|
|
938
940
|
this.#routerMiddleware = routerMiddleware;
|
|
939
941
|
this.#pattern = options.pattern;
|
|
940
942
|
this.#methods = options.methods;
|
|
941
|
-
this.#handler = this.#resolveRouteHandle(options.handler);
|
|
942
943
|
this.#globalMatchers = options.globalMatchers;
|
|
944
|
+
const { handler, routeName } = this.#resolveRouteHandle(options.handler);
|
|
945
|
+
this.#handler = handler;
|
|
946
|
+
this.#name = routeName;
|
|
943
947
|
}
|
|
944
948
|
/**
|
|
945
949
|
* Resolves the route handler string expression to a
|
|
@@ -951,24 +955,35 @@ var Route = class extends Macroable4 {
|
|
|
951
955
|
const method = parts.length === 1 ? "handle" : parts.pop();
|
|
952
956
|
const moduleRefId = parts.join(".");
|
|
953
957
|
return {
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
958
|
+
handler: {
|
|
959
|
+
reference: handler,
|
|
960
|
+
...moduleImporter(() => this.#app.import(moduleRefId), method).toHandleMethod(),
|
|
961
|
+
name: handler
|
|
962
|
+
},
|
|
963
|
+
routeName: `${new StringBuilder(moduleRefId.split("/").pop()).removeSuffix("controller").snakeCase()}.${string2.snakeCase(method)}`
|
|
957
964
|
};
|
|
958
965
|
}
|
|
959
966
|
if (Array.isArray(handler)) {
|
|
960
|
-
|
|
967
|
+
const controller = handler[0];
|
|
968
|
+
const method = handler[1] ?? "handle";
|
|
969
|
+
if (is.class(controller)) {
|
|
961
970
|
return {
|
|
962
|
-
|
|
963
|
-
|
|
971
|
+
handler: {
|
|
972
|
+
reference: handler,
|
|
973
|
+
...moduleCaller(controller, method).toHandleMethod()
|
|
974
|
+
},
|
|
975
|
+
routeName: `${new StringBuilder(controller.name).removeSuffix("controller").snakeCase()}.${string2.snakeCase(method)}`
|
|
964
976
|
};
|
|
965
977
|
}
|
|
966
978
|
return {
|
|
967
|
-
|
|
968
|
-
|
|
979
|
+
handler: {
|
|
980
|
+
reference: handler,
|
|
981
|
+
...moduleImporter(controller, method).toHandleMethod()
|
|
982
|
+
},
|
|
983
|
+
routeName: `${new StringBuilder(controller.name).removeSuffix("controller").snakeCase()}.${string2.snakeCase(method)}`
|
|
969
984
|
};
|
|
970
985
|
}
|
|
971
|
-
return handler;
|
|
986
|
+
return { handler };
|
|
972
987
|
}
|
|
973
988
|
/**
|
|
974
989
|
* Returns an object of param matchers by merging global and local
|
|
@@ -3366,7 +3381,6 @@ var Response = class extends Macroable6 {
|
|
|
3366
3381
|
|
|
3367
3382
|
// src/router/main.ts
|
|
3368
3383
|
import is3 from "@sindresorhus/is";
|
|
3369
|
-
import lodash2 from "@poppinss/utils/lodash";
|
|
3370
3384
|
import { moduleImporter as moduleImporter3 } from "@adonisjs/fold";
|
|
3371
3385
|
import { RuntimeException as RuntimeException5 } from "@poppinss/utils/exception";
|
|
3372
3386
|
|
|
@@ -3506,113 +3520,6 @@ var RoutesStore = class {
|
|
|
3506
3520
|
}
|
|
3507
3521
|
};
|
|
3508
3522
|
|
|
3509
|
-
// src/client/router.ts
|
|
3510
|
-
var RouterClient = class {
|
|
3511
|
-
/**
|
|
3512
|
-
* List of route references kept for lookup.
|
|
3513
|
-
*/
|
|
3514
|
-
routes;
|
|
3515
|
-
/**
|
|
3516
|
-
* The lookup strategies to follow when generating URL builder
|
|
3517
|
-
* types and client
|
|
3518
|
-
*/
|
|
3519
|
-
lookupStrategies = ["name", "pattern"];
|
|
3520
|
-
constructor(routes) {
|
|
3521
|
-
this.routes = routes ?? {};
|
|
3522
|
-
}
|
|
3523
|
-
/**
|
|
3524
|
-
* Register route JSON payload
|
|
3525
|
-
*/
|
|
3526
|
-
register(route) {
|
|
3527
|
-
this.routes[route.domain] = this.routes[route.domain] || [];
|
|
3528
|
-
this.routes[route.domain].push(route);
|
|
3529
|
-
}
|
|
3530
|
-
/**
|
|
3531
|
-
* Define the lookup strategies to follow when generating URL builder
|
|
3532
|
-
* types and client.
|
|
3533
|
-
*/
|
|
3534
|
-
updateLookupStrategies(strategies) {
|
|
3535
|
-
this.lookupStrategies = strategies;
|
|
3536
|
-
return this;
|
|
3537
|
-
}
|
|
3538
|
-
/**
|
|
3539
|
-
* Finds a route by its identifier. The identifier can be the
|
|
3540
|
-
* route name, controller.method name or the route pattern
|
|
3541
|
-
* itself.
|
|
3542
|
-
*
|
|
3543
|
-
* When "followLookupStrategy" is enabled, the lookup will be performed
|
|
3544
|
-
* on the basis of the lookup strategy enabled via the "lookupStrategies"
|
|
3545
|
-
* method. The default lookupStrategy is "name" and "pattern".
|
|
3546
|
-
*/
|
|
3547
|
-
find(routeIdentifier, domain, method, followLookupStrategy) {
|
|
3548
|
-
if (!domain) {
|
|
3549
|
-
let route = null;
|
|
3550
|
-
for (const routeDomain of Object.keys(this.routes)) {
|
|
3551
|
-
route = this.find(routeIdentifier, routeDomain, method, followLookupStrategy);
|
|
3552
|
-
if (route) {
|
|
3553
|
-
break;
|
|
3554
|
-
}
|
|
3555
|
-
}
|
|
3556
|
-
return route;
|
|
3557
|
-
}
|
|
3558
|
-
const routes = this.routes[domain];
|
|
3559
|
-
if (!routes) {
|
|
3560
|
-
return null;
|
|
3561
|
-
}
|
|
3562
|
-
const lookupByName = !followLookupStrategy || this.lookupStrategies.includes("name");
|
|
3563
|
-
const lookupByPattern = !followLookupStrategy || this.lookupStrategies.includes("pattern");
|
|
3564
|
-
const lookupByController = !followLookupStrategy || this.lookupStrategies.includes("controller");
|
|
3565
|
-
return routes.find((route) => {
|
|
3566
|
-
if (method && !route.methods.includes(method)) {
|
|
3567
|
-
return false;
|
|
3568
|
-
}
|
|
3569
|
-
if (route.name === routeIdentifier && lookupByName || route.pattern === routeIdentifier && lookupByPattern) {
|
|
3570
|
-
return true;
|
|
3571
|
-
}
|
|
3572
|
-
if (typeof route.handler === "function" || !lookupByController) {
|
|
3573
|
-
return false;
|
|
3574
|
-
}
|
|
3575
|
-
return route.handler.reference === routeIdentifier;
|
|
3576
|
-
}) || null;
|
|
3577
|
-
}
|
|
3578
|
-
/**
|
|
3579
|
-
* Finds a route by its identifier. The identifier can be the
|
|
3580
|
-
* route name, controller.method name or the route pattern
|
|
3581
|
-
* itself.
|
|
3582
|
-
*
|
|
3583
|
-
* An error is raised when unable to find the route.
|
|
3584
|
-
*
|
|
3585
|
-
* When "followLookupStrategy" is enabled, the lookup will be performed
|
|
3586
|
-
* on the basis of the lookup strategy enabled via the "lookupStrategies"
|
|
3587
|
-
* method. The default lookupStrategy is "name" and "pattern".
|
|
3588
|
-
*/
|
|
3589
|
-
findOrFail(routeIdentifier, domain, method, followLookupStrategy) {
|
|
3590
|
-
const route = this.find(routeIdentifier, domain, method, followLookupStrategy);
|
|
3591
|
-
if (!route) {
|
|
3592
|
-
throw new Error(`Cannot lookup route "${routeIdentifier}"`);
|
|
3593
|
-
}
|
|
3594
|
-
return route;
|
|
3595
|
-
}
|
|
3596
|
-
/**
|
|
3597
|
-
* Check if a route exists. The identifier can be the
|
|
3598
|
-
* route name, controller.method name or the route pattern
|
|
3599
|
-
* itself.
|
|
3600
|
-
*
|
|
3601
|
-
* When "followLookupStrategy" is enabled, the lookup will be performed
|
|
3602
|
-
* on the basis of the lookup strategy enabled via the "lookupStrategies"
|
|
3603
|
-
* method. The default lookupStrategy is "name" and "pattern".
|
|
3604
|
-
*/
|
|
3605
|
-
has(routeIdentifier, domain, method, followLookupStrategy) {
|
|
3606
|
-
return !!this.find(routeIdentifier, domain, method, followLookupStrategy);
|
|
3607
|
-
}
|
|
3608
|
-
/**
|
|
3609
|
-
* Returns a list of routes grouped by their domain names
|
|
3610
|
-
*/
|
|
3611
|
-
toJSON() {
|
|
3612
|
-
return this.routes;
|
|
3613
|
-
}
|
|
3614
|
-
};
|
|
3615
|
-
|
|
3616
3523
|
// src/router/legacy/url_builder.ts
|
|
3617
3524
|
var UrlBuilder = class {
|
|
3618
3525
|
/**
|
|
@@ -3747,30 +3654,7 @@ var RouteMatchers = class extends Macroable7 {
|
|
|
3747
3654
|
}
|
|
3748
3655
|
};
|
|
3749
3656
|
|
|
3750
|
-
// src/
|
|
3751
|
-
import { moduleImporter as moduleImporter2 } from "@adonisjs/fold";
|
|
3752
|
-
function middlewareReferenceBuilder(name, middleware) {
|
|
3753
|
-
const handler = moduleImporter2(middleware, "handle").toHandleMethod();
|
|
3754
|
-
return function(...args) {
|
|
3755
|
-
return {
|
|
3756
|
-
...handler,
|
|
3757
|
-
name,
|
|
3758
|
-
reference: middleware,
|
|
3759
|
-
args: args[0]
|
|
3760
|
-
};
|
|
3761
|
-
};
|
|
3762
|
-
}
|
|
3763
|
-
function defineNamedMiddleware(collection) {
|
|
3764
|
-
return Object.keys(collection).reduce(
|
|
3765
|
-
(result, key) => {
|
|
3766
|
-
result[key] = middlewareReferenceBuilder(key, collection[key]);
|
|
3767
|
-
return result;
|
|
3768
|
-
},
|
|
3769
|
-
{}
|
|
3770
|
-
);
|
|
3771
|
-
}
|
|
3772
|
-
|
|
3773
|
-
// src/client/url_builder.ts
|
|
3657
|
+
// src/router/url_builder.ts
|
|
3774
3658
|
function createURL(identifier, tokens, searchParamsStringifier, params, options) {
|
|
3775
3659
|
const uriSegments = [];
|
|
3776
3660
|
const paramsArray = Array.isArray(params) ? params : null;
|
|
@@ -3891,6 +3775,29 @@ function createUrlBuilder(router, searchParamsStringifier) {
|
|
|
3891
3775
|
return urlFor;
|
|
3892
3776
|
}
|
|
3893
3777
|
|
|
3778
|
+
// src/define_middleware.ts
|
|
3779
|
+
import { moduleImporter as moduleImporter2 } from "@adonisjs/fold";
|
|
3780
|
+
function middlewareReferenceBuilder(name, middleware) {
|
|
3781
|
+
const handler = moduleImporter2(middleware, "handle").toHandleMethod();
|
|
3782
|
+
return function(...args) {
|
|
3783
|
+
return {
|
|
3784
|
+
...handler,
|
|
3785
|
+
name,
|
|
3786
|
+
reference: middleware,
|
|
3787
|
+
args: args[0]
|
|
3788
|
+
};
|
|
3789
|
+
};
|
|
3790
|
+
}
|
|
3791
|
+
function defineNamedMiddleware(collection) {
|
|
3792
|
+
return Object.keys(collection).reduce(
|
|
3793
|
+
(result, key) => {
|
|
3794
|
+
result[key] = middlewareReferenceBuilder(key, collection[key]);
|
|
3795
|
+
return result;
|
|
3796
|
+
},
|
|
3797
|
+
{}
|
|
3798
|
+
);
|
|
3799
|
+
}
|
|
3800
|
+
|
|
3894
3801
|
// src/router/signed_url_builder.ts
|
|
3895
3802
|
function createSignedURL(identifier, tokens, searchParamsStringifier, encryption, params, options) {
|
|
3896
3803
|
const signature = encryption.verifier.sign(
|
|
@@ -3985,7 +3892,7 @@ function createSignedUrlBuilder(router, encryption, searchParamsStringifier) {
|
|
|
3985
3892
|
}
|
|
3986
3893
|
|
|
3987
3894
|
// src/router/main.ts
|
|
3988
|
-
var Router = class
|
|
3895
|
+
var Router = class {
|
|
3989
3896
|
/**
|
|
3990
3897
|
* Flag to avoid re-comitting routes to the store
|
|
3991
3898
|
*/
|
|
@@ -4049,8 +3956,11 @@ var Router = class extends RouterClient {
|
|
|
4049
3956
|
* methods.
|
|
4050
3957
|
*/
|
|
4051
3958
|
urlBuilder;
|
|
3959
|
+
/**
|
|
3960
|
+
* List of route references kept for lookup.
|
|
3961
|
+
*/
|
|
3962
|
+
routes = {};
|
|
4052
3963
|
constructor(app, encryption, qsParser) {
|
|
4053
|
-
super();
|
|
4054
3964
|
this.#app = app;
|
|
4055
3965
|
this.#encryption = encryption;
|
|
4056
3966
|
this.qs = qsParser;
|
|
@@ -4059,6 +3969,13 @@ var Router = class extends RouterClient {
|
|
|
4059
3969
|
signedUrlFor: createSignedUrlBuilder(this, this.#encryption, this.qs.stringify)
|
|
4060
3970
|
};
|
|
4061
3971
|
}
|
|
3972
|
+
/**
|
|
3973
|
+
* Register route JSON payload
|
|
3974
|
+
*/
|
|
3975
|
+
register(route) {
|
|
3976
|
+
this.routes[route.domain] = this.routes[route.domain] || [];
|
|
3977
|
+
this.routes[route.domain].push(route);
|
|
3978
|
+
}
|
|
4062
3979
|
/**
|
|
4063
3980
|
* Push a give router entity to the list of routes or the
|
|
4064
3981
|
* recently opened group.
|
|
@@ -4232,7 +4149,7 @@ var Router = class extends RouterClient {
|
|
|
4232
4149
|
const routeNames = routeNamesByDomain.get(route.domain);
|
|
4233
4150
|
if (route.name && routeNames.has(route.name)) {
|
|
4234
4151
|
throw new RuntimeException5(
|
|
4235
|
-
`
|
|
4152
|
+
`A route with name "${route.name}" already exists. It may happen when two routes use the same controller, so make sure to give explicit names to these routes`
|
|
4236
4153
|
);
|
|
4237
4154
|
}
|
|
4238
4155
|
if (route.name) {
|
|
@@ -4249,6 +4166,80 @@ var Router = class extends RouterClient {
|
|
|
4249
4166
|
this.#openedGroups = [];
|
|
4250
4167
|
this.#commited = true;
|
|
4251
4168
|
}
|
|
4169
|
+
/**
|
|
4170
|
+
* Finds a route by its identifier. The identifier can be the
|
|
4171
|
+
* route name, controller.method name or the route pattern
|
|
4172
|
+
* itself.
|
|
4173
|
+
*
|
|
4174
|
+
* When "disableLegacyLookup" is set, the lookup will be performed
|
|
4175
|
+
* only using the route name
|
|
4176
|
+
*/
|
|
4177
|
+
find(routeIdentifier, domain, method, disableLegacyLookup) {
|
|
4178
|
+
if (!domain) {
|
|
4179
|
+
let route = null;
|
|
4180
|
+
for (const routeDomain of Object.keys(this.routes)) {
|
|
4181
|
+
route = this.find(routeIdentifier, routeDomain, method, disableLegacyLookup);
|
|
4182
|
+
if (route) {
|
|
4183
|
+
break;
|
|
4184
|
+
}
|
|
4185
|
+
}
|
|
4186
|
+
return route;
|
|
4187
|
+
}
|
|
4188
|
+
const routes = this.routes[domain];
|
|
4189
|
+
if (!routes) {
|
|
4190
|
+
return null;
|
|
4191
|
+
}
|
|
4192
|
+
const lookupByName = true;
|
|
4193
|
+
const lookupByPattern = !disableLegacyLookup;
|
|
4194
|
+
const lookupByController = !disableLegacyLookup;
|
|
4195
|
+
return routes.find((route) => {
|
|
4196
|
+
if (method && !route.methods.includes(method)) {
|
|
4197
|
+
return false;
|
|
4198
|
+
}
|
|
4199
|
+
if (route.name === routeIdentifier && lookupByName || route.pattern === routeIdentifier && lookupByPattern) {
|
|
4200
|
+
return true;
|
|
4201
|
+
}
|
|
4202
|
+
if (typeof route.handler === "function" || !lookupByController) {
|
|
4203
|
+
return false;
|
|
4204
|
+
}
|
|
4205
|
+
return route.handler.reference === routeIdentifier;
|
|
4206
|
+
}) || null;
|
|
4207
|
+
}
|
|
4208
|
+
/**
|
|
4209
|
+
* Finds a route by its identifier. The identifier can be the
|
|
4210
|
+
* route name, controller.method name or the route pattern
|
|
4211
|
+
* itself.
|
|
4212
|
+
*
|
|
4213
|
+
* An error is raised when unable to find the route.
|
|
4214
|
+
*
|
|
4215
|
+
* When "disableLegacyLookup" is set, the lookup will be performed
|
|
4216
|
+
* only using the route name
|
|
4217
|
+
*/
|
|
4218
|
+
findOrFail(routeIdentifier, domain, method, disableLegacyLookup) {
|
|
4219
|
+
const route = this.find(routeIdentifier, domain, method, disableLegacyLookup);
|
|
4220
|
+
if (!route) {
|
|
4221
|
+
throw new Error(`Cannot lookup route "${routeIdentifier}"`);
|
|
4222
|
+
}
|
|
4223
|
+
return route;
|
|
4224
|
+
}
|
|
4225
|
+
/**
|
|
4226
|
+
* Check if a route exists. The identifier can be the
|
|
4227
|
+
* route name, controller.method name or the route pattern
|
|
4228
|
+
* itself.
|
|
4229
|
+
*
|
|
4230
|
+
* When "followLookupStrategy" is enabled, the lookup will be performed
|
|
4231
|
+
* on the basis of the lookup strategy enabled via the "lookupStrategies"
|
|
4232
|
+
* method. The default lookupStrategy is "name" and "pattern".
|
|
4233
|
+
*/
|
|
4234
|
+
has(routeIdentifier, domain, method, followLookupStrategy) {
|
|
4235
|
+
return !!this.find(routeIdentifier, domain, method, followLookupStrategy);
|
|
4236
|
+
}
|
|
4237
|
+
/**
|
|
4238
|
+
* Returns a list of routes grouped by their domain names
|
|
4239
|
+
*/
|
|
4240
|
+
toJSON() {
|
|
4241
|
+
return this.routes;
|
|
4242
|
+
}
|
|
4252
4243
|
/**
|
|
4253
4244
|
* Generates types for the URL builder. These types must
|
|
4254
4245
|
* be written inside a file for the URL builder to
|
|
@@ -4279,21 +4270,11 @@ var Router = class extends RouterClient {
|
|
|
4279
4270
|
routesList["ALL"] = routesList["ALL"] ?? {};
|
|
4280
4271
|
routesList[method] = routesList[method] ?? {};
|
|
4281
4272
|
const identifiers = [];
|
|
4282
|
-
if (
|
|
4283
|
-
if (!routesList[method][route.pattern]) {
|
|
4284
|
-
identifiers.push(route.pattern);
|
|
4285
|
-
}
|
|
4286
|
-
}
|
|
4287
|
-
if (this.lookupStrategies.includes("name") && route.name) {
|
|
4273
|
+
if (route.name) {
|
|
4288
4274
|
identifiers.push(
|
|
4289
4275
|
domain && routesList[method][route.name] ? `${domain}@${route.name}` : route.name
|
|
4290
4276
|
);
|
|
4291
4277
|
}
|
|
4292
|
-
if (this.lookupStrategies.includes("controller") && "reference" in route.handler && typeof route.handler.reference === "string") {
|
|
4293
|
-
identifiers.push(
|
|
4294
|
-
domain && routesList[method][route.handler.reference] ? `${domain}@${route.handler.reference}` : route.handler.reference
|
|
4295
|
-
);
|
|
4296
|
-
}
|
|
4297
4278
|
identifiers.forEach((identifier) => {
|
|
4298
4279
|
routesList["ALL"][identifier] = {
|
|
4299
4280
|
params,
|
|
@@ -4329,38 +4310,6 @@ var Router = class extends RouterClient {
|
|
|
4329
4310
|
return result;
|
|
4330
4311
|
}, []).join("\n");
|
|
4331
4312
|
}
|
|
4332
|
-
generateClient() {
|
|
4333
|
-
const routesForClient = Object.keys(this.routes).reduce(
|
|
4334
|
-
(result, domain) => {
|
|
4335
|
-
const routes = this.routes[domain];
|
|
4336
|
-
result[domain] = routes.map((route) => {
|
|
4337
|
-
const controller = "reference" in route.handler && typeof route.handler.reference === "string" ? route.handler.reference : void 0;
|
|
4338
|
-
return {
|
|
4339
|
-
pattern: route.pattern,
|
|
4340
|
-
name: route.name,
|
|
4341
|
-
handler: {
|
|
4342
|
-
reference: controller
|
|
4343
|
-
},
|
|
4344
|
-
methods: route.methods,
|
|
4345
|
-
domain: route.domain,
|
|
4346
|
-
tokens: route.tokens.map((tokens) => {
|
|
4347
|
-
return lodash2.pick(tokens, ["val", "type", "end"]);
|
|
4348
|
-
})
|
|
4349
|
-
};
|
|
4350
|
-
});
|
|
4351
|
-
return result;
|
|
4352
|
-
},
|
|
4353
|
-
{}
|
|
4354
|
-
);
|
|
4355
|
-
return `import type { RoutesList } from '@adonisjs/core/types/http'
|
|
4356
|
-
import { RouterClient, createUrlBuilder, ClientRouteJSON } from 'adonisjs/core/http/client'
|
|
4357
|
-
|
|
4358
|
-
const routes = ${JSON.stringify(routesForClient)} satisfies { [domain: string]: ClientRouteJSON[] }
|
|
4359
|
-
const router = new RouterClient(routes)
|
|
4360
|
-
export const urlFor = createUrlBuilder<RoutesList>(router, (qs) => {
|
|
4361
|
-
return new URLSearchParams(qs).toString()
|
|
4362
|
-
})`;
|
|
4363
|
-
}
|
|
4364
4313
|
/**
|
|
4365
4314
|
* Find route for a given URL, method and optionally domain
|
|
4366
4315
|
*/
|
|
@@ -4912,8 +4861,8 @@ var Server = class {
|
|
|
4912
4861
|
|
|
4913
4862
|
// src/define_config.ts
|
|
4914
4863
|
import proxyAddr from "proxy-addr";
|
|
4915
|
-
import
|
|
4916
|
-
import
|
|
4864
|
+
import string3 from "@poppinss/utils/string";
|
|
4865
|
+
import lodash2 from "@poppinss/utils/lodash";
|
|
4917
4866
|
function defineConfig(config) {
|
|
4918
4867
|
const { trustProxy: trustProxy2, ...rest } = config;
|
|
4919
4868
|
const defaults = {
|
|
@@ -4950,9 +4899,9 @@ function defineConfig(config) {
|
|
|
4950
4899
|
}
|
|
4951
4900
|
}
|
|
4952
4901
|
};
|
|
4953
|
-
const normalizedConfig =
|
|
4902
|
+
const normalizedConfig = lodash2.merge({}, defaults, rest);
|
|
4954
4903
|
if (normalizedConfig.cookie.maxAge) {
|
|
4955
|
-
normalizedConfig.cookie.maxAge =
|
|
4904
|
+
normalizedConfig.cookie.maxAge = string3.seconds.parse(normalizedConfig.cookie.maxAge);
|
|
4956
4905
|
}
|
|
4957
4906
|
if (typeof trustProxy2 === "boolean") {
|
|
4958
4907
|
const tpValue = trustProxy2;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Logger } from '@adonisjs/logger';
|
|
2
|
-
import type { Request } from '../src/request.
|
|
3
|
-
import type { Response } from '../src/response.
|
|
4
|
-
import { HttpContext } from '../src/http_context/main.
|
|
2
|
+
import type { Request } from '../src/request.ts';
|
|
3
|
+
import type { Response } from '../src/response.ts';
|
|
4
|
+
import { HttpContext } from '../src/http_context/main.ts';
|
|
5
5
|
type FactoryParameters = {
|
|
6
6
|
request: Request;
|
|
7
7
|
response: Response;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { RouterFactory } from './router.
|
|
2
|
-
export { RequestFactory } from './request.
|
|
3
|
-
export { ResponseFactory } from './response.
|
|
4
|
-
export { ServerFactory } from './server_factory.
|
|
5
|
-
export { HttpContextFactory } from './http_context.
|
|
6
|
-
export { QsParserFactory } from './qs_parser_factory.
|
|
1
|
+
export { RouterFactory } from './router.ts';
|
|
2
|
+
export { RequestFactory } from './request.ts';
|
|
3
|
+
export { ResponseFactory } from './response.ts';
|
|
4
|
+
export { ServerFactory } from './server_factory.ts';
|
|
5
|
+
export { HttpContextFactory } from './http_context.ts';
|
|
6
|
+
export { QsParserFactory } from './qs_parser_factory.ts';
|
package/build/factories/main.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Qs } from '../src/qs.
|
|
2
|
-
import type { QSParserConfig } from '../src/types/qs.
|
|
1
|
+
import { Qs } from '../src/qs.ts';
|
|
2
|
+
import type { QSParserConfig } from '../src/types/qs.ts';
|
|
3
3
|
/**
|
|
4
4
|
* QS Parser factory is used to generate the query string
|
|
5
5
|
* parser for testing
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Encryption } from '@adonisjs/encryption';
|
|
2
2
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
3
|
-
import { Request } from '../src/request.
|
|
4
|
-
import { type RequestConfig } from '../src/types/request.
|
|
3
|
+
import { Request } from '../src/request.ts';
|
|
4
|
+
import { type RequestConfig } from '../src/types/request.ts';
|
|
5
5
|
type FactoryParameters = {
|
|
6
6
|
url: string;
|
|
7
7
|
method: string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Encryption } from '@adonisjs/encryption';
|
|
2
2
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
3
|
-
import { Response } from '../src/response.
|
|
4
|
-
import { type Router } from '../src/router/main.
|
|
5
|
-
import { type ResponseConfig } from '../src/types/response.
|
|
3
|
+
import { Response } from '../src/response.ts';
|
|
4
|
+
import { type Router } from '../src/router/main.ts';
|
|
5
|
+
import { type ResponseConfig } from '../src/types/response.ts';
|
|
6
6
|
type FactoryParameters = {
|
|
7
7
|
req: IncomingMessage;
|
|
8
8
|
res: ServerResponse;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Encryption } from '@adonisjs/encryption';
|
|
2
2
|
import type { Application } from '@adonisjs/application';
|
|
3
|
-
import { Router } from '../src/router/main.
|
|
3
|
+
import { Router } from '../src/router/main.ts';
|
|
4
4
|
type FactoryParameters = {
|
|
5
5
|
app: Application<any>;
|
|
6
6
|
encryption: Encryption;
|
|
@@ -2,8 +2,8 @@ import { Logger } from '@adonisjs/logger';
|
|
|
2
2
|
import { Emitter } from '@adonisjs/events';
|
|
3
3
|
import type { Encryption } from '@adonisjs/encryption';
|
|
4
4
|
import type { Application } from '@adonisjs/application';
|
|
5
|
-
import { Server } from '../src/server/main.
|
|
6
|
-
import type { ServerConfig } from '../src/types/server.
|
|
5
|
+
import { Server } from '../src/server/main.ts';
|
|
6
|
+
import type { ServerConfig } from '../src/types/server.ts';
|
|
7
7
|
type FactoryParameters = {
|
|
8
8
|
app: Application<any>;
|
|
9
9
|
logger: Logger;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Encryption } from '@adonisjs/encryption';
|
|
2
2
|
import type { Router } from '../src/router/main.ts';
|
|
3
|
-
import { type LookupList } from '../src/
|
|
3
|
+
import { type LookupList } from '../src/types/url_builder.ts';
|
|
4
4
|
type FactoryParameters = {
|
|
5
5
|
router: Router;
|
|
6
6
|
encryption: Encryption;
|
|
@@ -18,8 +18,8 @@ export declare class URLBuilderFactory<Routes extends LookupList> {
|
|
|
18
18
|
* Create URL builder helpers
|
|
19
19
|
*/
|
|
20
20
|
create(): {
|
|
21
|
-
urlFor: import("../src/
|
|
22
|
-
signedUrlFor: import("../src/
|
|
21
|
+
urlFor: import("../src/types/url_builder.ts").UrlFor<Routes>;
|
|
22
|
+
signedUrlFor: import("../src/types/url_builder.ts").UrlFor<Routes, import("../src/types/url_builder.ts").SignedURLOptions>;
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
export {};
|
package/build/index.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export * as errors from './src/errors.
|
|
2
|
-
export { Request } from './src/request.
|
|
3
|
-
export { Response } from './src/response.
|
|
4
|
-
export { Redirect } from './src/redirect.
|
|
5
|
-
export { Server } from './src/server/main.
|
|
6
|
-
export { Router } from './src/router/main.
|
|
7
|
-
export { Route } from './src/router/route.
|
|
8
|
-
export { BriskRoute } from './src/router/brisk.
|
|
9
|
-
export { RouteGroup } from './src/router/group.
|
|
10
|
-
export { defineConfig } from './src/define_config.
|
|
11
|
-
export { CookieClient } from './src/cookies/client.
|
|
12
|
-
export { HttpContext } from './src/http_context/main.
|
|
13
|
-
export { RouteResource } from './src/router/resource.
|
|
14
|
-
export { ResponseStatus } from './src/response_status.
|
|
15
|
-
export { ExceptionHandler } from './src/exception_handler.
|
|
16
|
-
export * as tracingChannels from './src/tracing_channels.
|
|
1
|
+
export * as errors from './src/errors.ts';
|
|
2
|
+
export { Request } from './src/request.ts';
|
|
3
|
+
export { Response } from './src/response.ts';
|
|
4
|
+
export { Redirect } from './src/redirect.ts';
|
|
5
|
+
export { Server } from './src/server/main.ts';
|
|
6
|
+
export { Router } from './src/router/main.ts';
|
|
7
|
+
export { Route } from './src/router/route.ts';
|
|
8
|
+
export { BriskRoute } from './src/router/brisk.ts';
|
|
9
|
+
export { RouteGroup } from './src/router/group.ts';
|
|
10
|
+
export { defineConfig } from './src/define_config.ts';
|
|
11
|
+
export { CookieClient } from './src/cookies/client.ts';
|
|
12
|
+
export { HttpContext } from './src/http_context/main.ts';
|
|
13
|
+
export { RouteResource } from './src/router/resource.ts';
|
|
14
|
+
export { ResponseStatus } from './src/response_status.ts';
|
|
15
|
+
export { ExceptionHandler } from './src/exception_handler.ts';
|
|
16
|
+
export * as tracingChannels from './src/tracing_channels.ts';
|
package/build/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Encryption } from '@adonisjs/encryption';
|
|
2
|
-
import type { CookieOptions } from '../types/response.
|
|
2
|
+
import type { CookieOptions } from '../types/response.ts';
|
|
3
3
|
/**
|
|
4
4
|
* Cookies serializer is used to serialize a value to be set on the `Set-Cookie`
|
|
5
5
|
* header. You can `encode`, `sign` on `encrypt` cookies using the serializer
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { LazyImport, UnWrapLazyImport } from '@poppinss/utils/types';
|
|
2
|
-
import type { GetMiddlewareArgs, MiddlewareAsClass, ParsedGlobalMiddleware } from './types/middleware.
|
|
2
|
+
import type { GetMiddlewareArgs, MiddlewareAsClass, ParsedGlobalMiddleware } from './types/middleware.ts';
|
|
3
3
|
/**
|
|
4
4
|
* Define an collection of named middleware. The collection gets converted
|
|
5
5
|
* into a collection of factory functions. Calling the function returns
|