sst-http 0.7.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +19 -9
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +18 -9
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -26,6 +26,7 @@ __export(index_exports, {
|
|
|
26
26
|
FirebaseAuth: () => FirebaseAuth,
|
|
27
27
|
Get: () => Get,
|
|
28
28
|
Head: () => Head,
|
|
29
|
+
Header: () => Header,
|
|
29
30
|
Headers: () => Headers,
|
|
30
31
|
HttpError: () => HttpError,
|
|
31
32
|
Options: () => Options,
|
|
@@ -301,17 +302,21 @@ function buildHandlerArguments(entry, ctx, getBody) {
|
|
|
301
302
|
break;
|
|
302
303
|
}
|
|
303
304
|
case "query": {
|
|
304
|
-
args[meta.index] = ctx.query;
|
|
305
|
+
args[meta.index] = meta.name ? ctx.query[meta.name] : ctx.query;
|
|
305
306
|
break;
|
|
306
307
|
}
|
|
307
308
|
case "param": {
|
|
308
|
-
args[meta.index] = ctx.params;
|
|
309
|
+
args[meta.index] = meta.name ? ctx.params[meta.name] : ctx.params;
|
|
309
310
|
break;
|
|
310
311
|
}
|
|
311
312
|
case "headers": {
|
|
312
313
|
args[meta.index] = ctx.headers;
|
|
313
314
|
break;
|
|
314
315
|
}
|
|
316
|
+
case "header": {
|
|
317
|
+
args[meta.index] = meta.name ? ctx.headers[meta.name.toLowerCase()] : ctx.headers;
|
|
318
|
+
break;
|
|
319
|
+
}
|
|
315
320
|
case "req": {
|
|
316
321
|
args[meta.index] = ctx.event;
|
|
317
322
|
break;
|
|
@@ -509,13 +514,14 @@ function createRouteDecorator(method) {
|
|
|
509
514
|
registerRoute(handler, method, path);
|
|
510
515
|
};
|
|
511
516
|
}
|
|
512
|
-
function createParameterDecorator(type,
|
|
517
|
+
function createParameterDecorator(type, options2) {
|
|
513
518
|
return (target, propertyKey, parameterIndex) => {
|
|
514
519
|
const handler = resolveHandler(target, propertyKey);
|
|
515
520
|
registerParameter(handler, {
|
|
516
521
|
index: parameterIndex,
|
|
517
522
|
type,
|
|
518
|
-
schema
|
|
523
|
+
schema: options2?.schema,
|
|
524
|
+
name: options2?.name
|
|
519
525
|
});
|
|
520
526
|
};
|
|
521
527
|
}
|
|
@@ -536,17 +542,20 @@ function Auth() {
|
|
|
536
542
|
return createParameterDecorator("auth");
|
|
537
543
|
}
|
|
538
544
|
function Body(schema) {
|
|
539
|
-
return createParameterDecorator("body", schema);
|
|
545
|
+
return createParameterDecorator("body", { schema });
|
|
540
546
|
}
|
|
541
|
-
function Query() {
|
|
542
|
-
return createParameterDecorator("query");
|
|
547
|
+
function Query(name) {
|
|
548
|
+
return createParameterDecorator("query", { name });
|
|
543
549
|
}
|
|
544
|
-
function Param() {
|
|
545
|
-
return createParameterDecorator("param");
|
|
550
|
+
function Param(name) {
|
|
551
|
+
return createParameterDecorator("param", { name });
|
|
546
552
|
}
|
|
547
553
|
function Headers() {
|
|
548
554
|
return createParameterDecorator("headers");
|
|
549
555
|
}
|
|
556
|
+
function Header(name) {
|
|
557
|
+
return createParameterDecorator("header", { name });
|
|
558
|
+
}
|
|
550
559
|
function Req() {
|
|
551
560
|
return createParameterDecorator("req");
|
|
552
561
|
}
|
|
@@ -561,6 +570,7 @@ function Res() {
|
|
|
561
570
|
FirebaseAuth,
|
|
562
571
|
Get,
|
|
563
572
|
Head,
|
|
573
|
+
Header,
|
|
564
574
|
Headers,
|
|
565
575
|
HttpError,
|
|
566
576
|
Options,
|
package/dist/index.d.cts
CHANGED
|
@@ -33,12 +33,13 @@ declare const Options: (path?: string) => LegacyDecorator;
|
|
|
33
33
|
declare function FirebaseAuth(options?: FirebaseAuthOptions): LegacyDecorator;
|
|
34
34
|
declare function Auth(): LegacyParameterDecorator;
|
|
35
35
|
declare function Body(schema?: ZodTypeAny): LegacyParameterDecorator;
|
|
36
|
-
declare function Query(): LegacyParameterDecorator;
|
|
37
|
-
declare function Param(): LegacyParameterDecorator;
|
|
36
|
+
declare function Query(name?: string): LegacyParameterDecorator;
|
|
37
|
+
declare function Param(name?: string): LegacyParameterDecorator;
|
|
38
38
|
declare function Headers(): LegacyParameterDecorator;
|
|
39
|
+
declare function Header(name: string): LegacyParameterDecorator;
|
|
39
40
|
declare function Req(): LegacyParameterDecorator;
|
|
40
41
|
declare function Res(): LegacyParameterDecorator;
|
|
41
42
|
|
|
42
43
|
declare function configureRoutes(next?: RouteOptions): void;
|
|
43
44
|
|
|
44
|
-
export { Auth, Body, Delete, FirebaseAuth, FirebaseAuthOptions, Get, Head, Headers, HttpError, Options, Param, Patch, Post, Put, Query, Req, Res, ResponseLike, RouteOptions, configureRoutes, createHandler, handleError, json, noContent, text };
|
|
45
|
+
export { Auth, Body, Delete, FirebaseAuth, FirebaseAuthOptions, Get, Head, Header, Headers, HttpError, Options, Param, Patch, Post, Put, Query, Req, Res, ResponseLike, RouteOptions, configureRoutes, createHandler, handleError, json, noContent, text };
|
package/dist/index.d.ts
CHANGED
|
@@ -33,12 +33,13 @@ declare const Options: (path?: string) => LegacyDecorator;
|
|
|
33
33
|
declare function FirebaseAuth(options?: FirebaseAuthOptions): LegacyDecorator;
|
|
34
34
|
declare function Auth(): LegacyParameterDecorator;
|
|
35
35
|
declare function Body(schema?: ZodTypeAny): LegacyParameterDecorator;
|
|
36
|
-
declare function Query(): LegacyParameterDecorator;
|
|
37
|
-
declare function Param(): LegacyParameterDecorator;
|
|
36
|
+
declare function Query(name?: string): LegacyParameterDecorator;
|
|
37
|
+
declare function Param(name?: string): LegacyParameterDecorator;
|
|
38
38
|
declare function Headers(): LegacyParameterDecorator;
|
|
39
|
+
declare function Header(name: string): LegacyParameterDecorator;
|
|
39
40
|
declare function Req(): LegacyParameterDecorator;
|
|
40
41
|
declare function Res(): LegacyParameterDecorator;
|
|
41
42
|
|
|
42
43
|
declare function configureRoutes(next?: RouteOptions): void;
|
|
43
44
|
|
|
44
|
-
export { Auth, Body, Delete, FirebaseAuth, FirebaseAuthOptions, Get, Head, Headers, HttpError, Options, Param, Patch, Post, Put, Query, Req, Res, ResponseLike, RouteOptions, configureRoutes, createHandler, handleError, json, noContent, text };
|
|
45
|
+
export { Auth, Body, Delete, FirebaseAuth, FirebaseAuthOptions, Get, Head, Header, Headers, HttpError, Options, Param, Patch, Post, Put, Query, Req, Res, ResponseLike, RouteOptions, configureRoutes, createHandler, handleError, json, noContent, text };
|
package/dist/index.js
CHANGED
|
@@ -254,17 +254,21 @@ function buildHandlerArguments(entry, ctx, getBody) {
|
|
|
254
254
|
break;
|
|
255
255
|
}
|
|
256
256
|
case "query": {
|
|
257
|
-
args[meta.index] = ctx.query;
|
|
257
|
+
args[meta.index] = meta.name ? ctx.query[meta.name] : ctx.query;
|
|
258
258
|
break;
|
|
259
259
|
}
|
|
260
260
|
case "param": {
|
|
261
|
-
args[meta.index] = ctx.params;
|
|
261
|
+
args[meta.index] = meta.name ? ctx.params[meta.name] : ctx.params;
|
|
262
262
|
break;
|
|
263
263
|
}
|
|
264
264
|
case "headers": {
|
|
265
265
|
args[meta.index] = ctx.headers;
|
|
266
266
|
break;
|
|
267
267
|
}
|
|
268
|
+
case "header": {
|
|
269
|
+
args[meta.index] = meta.name ? ctx.headers[meta.name.toLowerCase()] : ctx.headers;
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
268
272
|
case "req": {
|
|
269
273
|
args[meta.index] = ctx.event;
|
|
270
274
|
break;
|
|
@@ -462,13 +466,14 @@ function createRouteDecorator(method) {
|
|
|
462
466
|
registerRoute(handler, method, path);
|
|
463
467
|
};
|
|
464
468
|
}
|
|
465
|
-
function createParameterDecorator(type,
|
|
469
|
+
function createParameterDecorator(type, options2) {
|
|
466
470
|
return (target, propertyKey, parameterIndex) => {
|
|
467
471
|
const handler = resolveHandler(target, propertyKey);
|
|
468
472
|
registerParameter(handler, {
|
|
469
473
|
index: parameterIndex,
|
|
470
474
|
type,
|
|
471
|
-
schema
|
|
475
|
+
schema: options2?.schema,
|
|
476
|
+
name: options2?.name
|
|
472
477
|
});
|
|
473
478
|
};
|
|
474
479
|
}
|
|
@@ -489,17 +494,20 @@ function Auth() {
|
|
|
489
494
|
return createParameterDecorator("auth");
|
|
490
495
|
}
|
|
491
496
|
function Body(schema) {
|
|
492
|
-
return createParameterDecorator("body", schema);
|
|
497
|
+
return createParameterDecorator("body", { schema });
|
|
493
498
|
}
|
|
494
|
-
function Query() {
|
|
495
|
-
return createParameterDecorator("query");
|
|
499
|
+
function Query(name) {
|
|
500
|
+
return createParameterDecorator("query", { name });
|
|
496
501
|
}
|
|
497
|
-
function Param() {
|
|
498
|
-
return createParameterDecorator("param");
|
|
502
|
+
function Param(name) {
|
|
503
|
+
return createParameterDecorator("param", { name });
|
|
499
504
|
}
|
|
500
505
|
function Headers() {
|
|
501
506
|
return createParameterDecorator("headers");
|
|
502
507
|
}
|
|
508
|
+
function Header(name) {
|
|
509
|
+
return createParameterDecorator("header", { name });
|
|
510
|
+
}
|
|
503
511
|
function Req() {
|
|
504
512
|
return createParameterDecorator("req");
|
|
505
513
|
}
|
|
@@ -513,6 +521,7 @@ export {
|
|
|
513
521
|
FirebaseAuth,
|
|
514
522
|
Get,
|
|
515
523
|
Head,
|
|
524
|
+
Header,
|
|
516
525
|
Headers,
|
|
517
526
|
HttpError,
|
|
518
527
|
Options,
|