express-zod-api 9.2.0 → 10.0.0-beta1
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/CHANGELOG.md +26 -0
- package/README.md +28 -20
- package/dist/esm/index.js +58 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/index.d.ts +776 -21
- package/dist/index.js +55 -69
- package/dist/index.js.map +1 -1
- package/package.json +31 -25
- package/dist/api-response.d.ts +0 -16
- package/dist/api-response.js +0 -3
- package/dist/api-response.js.map +0 -1
- package/dist/client-helpers.d.ts +0 -23
- package/dist/client-helpers.js +0 -71
- package/dist/client-helpers.js.map +0 -1
- package/dist/client.d.ts +0 -15
- package/dist/client.js +0 -120
- package/dist/client.js.map +0 -1
- package/dist/common-helpers.d.ts +0 -46
- package/dist/common-helpers.js +0 -207
- package/dist/common-helpers.js.map +0 -1
- package/dist/config-type.d.ts +0 -59
- package/dist/config-type.js +0 -11
- package/dist/config-type.js.map +0 -1
- package/dist/date-in-schema.d.ts +0 -11
- package/dist/date-in-schema.js +0 -46
- package/dist/date-in-schema.js.map +0 -1
- package/dist/date-out-schema.d.ts +0 -10
- package/dist/date-out-schema.js +0 -31
- package/dist/date-out-schema.js.map +0 -1
- package/dist/depends-on-method.d.ts +0 -10
- package/dist/depends-on-method.js +0 -32
- package/dist/depends-on-method.js.map +0 -1
- package/dist/endpoint.d.ts +0 -98
- package/dist/endpoint.js +0 -261
- package/dist/endpoint.js.map +0 -1
- package/dist/endpoints-factory.d.ts +0 -161
- package/dist/endpoints-factory.js +0 -68
- package/dist/endpoints-factory.js.map +0 -1
- package/dist/errors.d.ts +0 -35
- package/dist/errors.js +0 -64
- package/dist/errors.js.map +0 -1
- package/dist/extend-zod.d.ts +0 -22
- package/dist/extend-zod.js +0 -33
- package/dist/extend-zod.js.map +0 -1
- package/dist/file-schema.d.ts +0 -23
- package/dist/file-schema.js +0 -55
- package/dist/file-schema.js.map +0 -1
- package/dist/io-schema.d.ts +0 -16
- package/dist/io-schema.js +0 -21
- package/dist/io-schema.js.map +0 -1
- package/dist/logger.d.ts +0 -3
- package/dist/logger.js +0 -54
- package/dist/logger.js.map +0 -1
- package/dist/logical-container.d.ts +0 -16
- package/dist/logical-container.js +0 -85
- package/dist/logical-container.js.map +0 -1
- package/dist/metadata.d.ts +0 -27
- package/dist/metadata.js +0 -58
- package/dist/metadata.js.map +0 -1
- package/dist/method.d.ts +0 -8
- package/dist/method.js +0 -5
- package/dist/method.js.map +0 -1
- package/dist/middleware.d.ts +0 -32
- package/dist/middleware.js +0 -16
- package/dist/middleware.js.map +0 -1
- package/dist/mime.d.ts +0 -2
- package/dist/mime.js +0 -10
- package/dist/mime.js.map +0 -1
- package/dist/mock.d.ts +0 -38
- package/dist/mock.js +0 -66
- package/dist/mock.js.map +0 -1
- package/dist/open-api-helpers.d.ts +0 -83
- package/dist/open-api-helpers.js +0 -621
- package/dist/open-api-helpers.js.map +0 -1
- package/dist/open-api.d.ts +0 -25
- package/dist/open-api.js +0 -98
- package/dist/open-api.js.map +0 -1
- package/dist/result-handler.d.ts +0 -151
- package/dist/result-handler.js +0 -71
- package/dist/result-handler.js.map +0 -1
- package/dist/routing-walker.d.ts +0 -12
- package/dist/routing-walker.js +0 -55
- package/dist/routing-walker.js.map +0 -1
- package/dist/routing.d.ts +0 -15
- package/dist/routing.js +0 -25
- package/dist/routing.js.map +0 -1
- package/dist/schema-walker.d.ts +0 -23
- package/dist/schema-walker.js +0 -26
- package/dist/schema-walker.js.map +0 -1
- package/dist/security.d.ts +0 -72
- package/dist/security.js +0 -3
- package/dist/security.js.map +0 -1
- package/dist/serve-static.d.ts +0 -9
- package/dist/serve-static.js +0 -17
- package/dist/serve-static.js.map +0 -1
- package/dist/server.d.ts +0 -20
- package/dist/server.js +0 -131
- package/dist/server.js.map +0 -1
- package/dist/startup-logo.d.ts +0 -1
- package/dist/startup-logo.js +0 -27
- package/dist/startup-logo.js.map +0 -1
- package/dist/upload-schema.d.ts +0 -11
- package/dist/upload-schema.js +0 -42
- package/dist/upload-schema.js.map +0 -1
- package/dist/zts-helpers.d.ts +0 -37
- package/dist/zts-helpers.js +0 -60
- package/dist/zts-helpers.js.map +0 -1
- package/dist/zts.d.ts +0 -31
- package/dist/zts.js +0 -147
- package/dist/zts.js.map +0 -1
- package/dist-esm/api-response.js +0 -2
- package/dist-esm/api-response.js.map +0 -1
- package/dist-esm/client-helpers.js +0 -48
- package/dist-esm/client-helpers.js.map +0 -1
- package/dist-esm/client.js +0 -113
- package/dist-esm/client.js.map +0 -1
- package/dist-esm/common-helpers.js +0 -188
- package/dist-esm/common-helpers.js.map +0 -1
- package/dist-esm/config-type.js +0 -7
- package/dist-esm/config-type.js.map +0 -1
- package/dist-esm/date-in-schema.js +0 -42
- package/dist-esm/date-in-schema.js.map +0 -1
- package/dist-esm/date-out-schema.js +0 -27
- package/dist-esm/date-out-schema.js.map +0 -1
- package/dist-esm/depends-on-method.js +0 -28
- package/dist-esm/depends-on-method.js.map +0 -1
- package/dist-esm/endpoint.js +0 -256
- package/dist-esm/endpoint.js.map +0 -1
- package/dist-esm/endpoints-factory.js +0 -64
- package/dist-esm/endpoints-factory.js.map +0 -1
- package/dist-esm/errors.js +0 -54
- package/dist-esm/errors.js.map +0 -1
- package/dist-esm/extend-zod.js +0 -16
- package/dist-esm/extend-zod.js.map +0 -1
- package/dist-esm/file-schema.js +0 -51
- package/dist-esm/file-schema.js.map +0 -1
- package/dist-esm/index.js +0 -19
- package/dist-esm/index.js.map +0 -1
- package/dist-esm/io-schema.js +0 -17
- package/dist-esm/io-schema.js.map +0 -1
- package/dist-esm/logger.js +0 -47
- package/dist-esm/logger.js.map +0 -1
- package/dist-esm/logical-container.js +0 -78
- package/dist-esm/logical-container.js.map +0 -1
- package/dist-esm/metadata.js +0 -51
- package/dist-esm/metadata.js.map +0 -1
- package/dist-esm/method.js +0 -2
- package/dist-esm/method.js.map +0 -1
- package/dist-esm/middleware.js +0 -12
- package/dist-esm/middleware.js.map +0 -1
- package/dist-esm/mime.js +0 -4
- package/dist-esm/mime.js.map +0 -1
- package/dist-esm/mock.js +0 -57
- package/dist-esm/mock.js.map +0 -1
- package/dist-esm/open-api-helpers.js +0 -575
- package/dist-esm/open-api-helpers.js.map +0 -1
- package/dist-esm/open-api.js +0 -94
- package/dist-esm/open-api.js.map +0 -1
- package/dist-esm/package.json +0 -1
- package/dist-esm/result-handler.js +0 -66
- package/dist-esm/result-handler.js.map +0 -1
- package/dist-esm/routing-walker.js +0 -51
- package/dist-esm/routing-walker.js.map +0 -1
- package/dist-esm/routing.js +0 -21
- package/dist-esm/routing.js.map +0 -1
- package/dist-esm/schema-walker.js +0 -22
- package/dist-esm/schema-walker.js.map +0 -1
- package/dist-esm/security.js +0 -2
- package/dist-esm/security.js.map +0 -1
- package/dist-esm/serve-static.js +0 -10
- package/dist-esm/serve-static.js.map +0 -1
- package/dist-esm/server.js +0 -98
- package/dist-esm/server.js.map +0 -1
- package/dist-esm/startup-logo.js +0 -23
- package/dist-esm/startup-logo.js.map +0 -1
- package/dist-esm/upload-schema.js +0 -38
- package/dist-esm/upload-schema.js.map +0 -1
- package/dist-esm/zts-helpers.js +0 -50
- package/dist-esm/zts-helpers.js.map +0 -1
- package/dist-esm/zts.js +0 -140
- package/dist-esm/zts.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,33 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## Version 10
|
|
4
|
+
|
|
5
|
+
### v10.0.0-beta1
|
|
6
|
+
|
|
7
|
+
- **BREAKING** changes to the concept of dependencies.
|
|
8
|
+
- `zod` becomes a peer dependency, fixes issue #822.
|
|
9
|
+
- You need to install it manually and adjust your imports accordingly.
|
|
10
|
+
- `express` becomes a peer dependency as well.
|
|
11
|
+
- You need to install it manually.
|
|
12
|
+
- `typescript` becomes an optional peer dependency.
|
|
13
|
+
- When using a client generator, you need to install it manually.
|
|
14
|
+
- The minimal supported version is 4.9.3.
|
|
15
|
+
- Proprietary schemas are now exported under the namespace `ez`.
|
|
16
|
+
- Imports and utilization should be adjusted accordingly.
|
|
17
|
+
- Affected schemas: `file`, `dateIn`, `dateOut`, `upload`.
|
|
18
|
+
- **BREAKING** changes to the engines.
|
|
19
|
+
- The minimal Node version is now 14.18.0.
|
|
20
|
+
- Due to switching to `tsup` builder, the file structure has changed:
|
|
21
|
+
- `/dist/index.js` — CommonJS bundle;
|
|
22
|
+
- `/dist/esm/index.js` — ESM bundle;
|
|
23
|
+
- `/dist/index.d.ts` — types declaration bundle.
|
|
24
|
+
|
|
3
25
|
## Version 9
|
|
4
26
|
|
|
27
|
+
### v9.2.1
|
|
28
|
+
|
|
29
|
+
- `zod` version is 3.21.4.
|
|
30
|
+
|
|
5
31
|
### v9.2.0
|
|
6
32
|
|
|
7
33
|
- `zod` version is 3.21.2.
|
package/README.md
CHANGED
|
@@ -101,10 +101,14 @@ Much can be customized to fit your needs.
|
|
|
101
101
|
|
|
102
102
|
## Installation
|
|
103
103
|
|
|
104
|
+
Run one of the following commands to install the library and its peer dependencies.
|
|
105
|
+
Typescript is an optional dependency, however, it's required if you're going to
|
|
106
|
+
[generate a frontend client](#generating-a-frontend-client) for your API.
|
|
107
|
+
|
|
104
108
|
```shell
|
|
105
|
-
yarn add express-zod-api
|
|
109
|
+
yarn add express-zod-api express zod typescript
|
|
106
110
|
# or
|
|
107
|
-
npm install express-zod-api
|
|
111
|
+
npm install express-zod-api express zod typescript
|
|
108
112
|
```
|
|
109
113
|
|
|
110
114
|
Add the following option to your `tsconfig.json` file in order to make it work as expected:
|
|
@@ -150,7 +154,7 @@ _In case you need to customize the response, see [Response customization](#respo
|
|
|
150
154
|
## Create your first endpoint
|
|
151
155
|
|
|
152
156
|
```typescript
|
|
153
|
-
import { z } from "
|
|
157
|
+
import { z } from "zod";
|
|
154
158
|
|
|
155
159
|
const helloWorldEndpoint = defaultEndpointsFactory.build({
|
|
156
160
|
method: "get",
|
|
@@ -270,7 +274,8 @@ const yourEndpoint = defaultEndpointsFactory
|
|
|
270
274
|
Here is an example of the authentication middleware, that checks a `key` from input and `token` from headers:
|
|
271
275
|
|
|
272
276
|
```typescript
|
|
273
|
-
import {
|
|
277
|
+
import { z } from "zod";
|
|
278
|
+
import { createMiddleware, createHttpError } from "express-zod-api";
|
|
274
279
|
|
|
275
280
|
const authMiddleware = createMiddleware({
|
|
276
281
|
security: {
|
|
@@ -327,7 +332,8 @@ You can implement additional validations within schemas using refinements.
|
|
|
327
332
|
Validation errors are reported in a response with a status code `400`.
|
|
328
333
|
|
|
329
334
|
```typescript
|
|
330
|
-
import {
|
|
335
|
+
import { z } from "zod";
|
|
336
|
+
import { createMiddleware } from "express-zod-api";
|
|
331
337
|
|
|
332
338
|
const nicknameConstraintMiddleware = createMiddleware({
|
|
333
339
|
input: z.object({
|
|
@@ -367,7 +373,7 @@ Since parameters of GET requests come in the form of strings, there is often a n
|
|
|
367
373
|
arrays of numbers.
|
|
368
374
|
|
|
369
375
|
```typescript
|
|
370
|
-
import { z } from "
|
|
376
|
+
import { z } from "zod";
|
|
371
377
|
|
|
372
378
|
const getUserEndpoint = endpointsFactory.build({
|
|
373
379
|
method: "get",
|
|
@@ -398,10 +404,10 @@ which in turn calls
|
|
|
398
404
|
It is also impossible to transmit the `Date` in its original form to your endpoints within JSON. Therefore, there is
|
|
399
405
|
confusion with original method ~~z.date()~~ that should not be used within IO schemas of your API.
|
|
400
406
|
|
|
401
|
-
In order to solve this problem, the library provides two custom methods for dealing with dates: `
|
|
402
|
-
`
|
|
407
|
+
In order to solve this problem, the library provides two custom methods for dealing with dates: `ez.dateIn()` and
|
|
408
|
+
`ez.dateOut()` for using within input and output schemas accordingly.
|
|
403
409
|
|
|
404
|
-
`
|
|
410
|
+
`ez.dateIn()` is a transforming schema that accepts an ISO `string` representation of a `Date`, validates it, and
|
|
405
411
|
provides your endpoint handler or middleware with a `Date`. It supports the following formats:
|
|
406
412
|
|
|
407
413
|
```text
|
|
@@ -411,20 +417,21 @@ provides your endpoint handler or middleware with a `Date`. It supports the foll
|
|
|
411
417
|
2021-12-31
|
|
412
418
|
```
|
|
413
419
|
|
|
414
|
-
`
|
|
420
|
+
`ez.dateOut()`, on the contrary, accepts a `Date` and provides `ResultHanlder` with a `string` representation in ISO
|
|
415
421
|
format for the response transmission. Consider the following simplified example for better understanding:
|
|
416
422
|
|
|
417
423
|
```typescript
|
|
418
|
-
import { z
|
|
424
|
+
import { z } from "zod";
|
|
425
|
+
import { ez, defaultEndpointsFactory } from "express-zod-api";
|
|
419
426
|
|
|
420
427
|
const updateUserEndpoint = defaultEndpointsFactory.build({
|
|
421
428
|
method: "post",
|
|
422
429
|
input: z.object({
|
|
423
430
|
userId: z.string(),
|
|
424
|
-
birthday:
|
|
431
|
+
birthday: ez.dateIn(), // string -> Date
|
|
425
432
|
}),
|
|
426
433
|
output: z.object({
|
|
427
|
-
createdAt:
|
|
434
|
+
createdAt: ez.dateOut(), // Date -> string
|
|
428
435
|
}),
|
|
429
436
|
handler: async ({ input }) => {
|
|
430
437
|
// input.birthday is Date
|
|
@@ -499,10 +506,10 @@ type DefaultResponse<OUT> =
|
|
|
499
506
|
You can create your own result handler by using this example as a template:
|
|
500
507
|
|
|
501
508
|
```typescript
|
|
509
|
+
import { z } from "zod";
|
|
502
510
|
import {
|
|
503
511
|
createResultHandler,
|
|
504
512
|
IOSchema,
|
|
505
|
-
z,
|
|
506
513
|
getStatusCodeFromError,
|
|
507
514
|
getMessageFromError,
|
|
508
515
|
} from "express-zod-api";
|
|
@@ -545,7 +552,7 @@ Thus, you can configure non-object responses too, for example, to send an image
|
|
|
545
552
|
You can find two approaches to `EndpointsFactory` and `ResultHandler` implementation
|
|
546
553
|
[in this example](https://github.com/RobinTail/express-zod-api/blob/master/example/factories.ts).
|
|
547
554
|
One of them implements file streaming, in this case the endpoint just has to provide the filename.
|
|
548
|
-
The response schema generally may be just `z.string()`, but I made more specific `
|
|
555
|
+
The response schema generally may be just `z.string()`, but I made more specific `ez.file()` that also supports
|
|
549
556
|
`.binary()` and `.base64()` refinements which are reflected in the
|
|
550
557
|
[generated documentation](#creating-a-documentation).
|
|
551
558
|
|
|
@@ -553,7 +560,7 @@ The response schema generally may be just `z.string()`, but I made more specific
|
|
|
553
560
|
const fileStreamingEndpointsFactory = new EndpointsFactory(
|
|
554
561
|
createResultHandler({
|
|
555
562
|
getPositiveResponse: () => ({
|
|
556
|
-
schema:
|
|
563
|
+
schema: ez.file().binary(),
|
|
557
564
|
mimeType: "image/*",
|
|
558
565
|
}),
|
|
559
566
|
getNegativeResponse: () => ({ schema: z.string(), mimeType: "text/plain" }),
|
|
@@ -599,11 +606,12 @@ const advancedUsage = defaultEndpointsFactory.use(auth(), {
|
|
|
599
606
|
## File uploads
|
|
600
607
|
|
|
601
608
|
You can switch the `Endpoint` to handle requests with the `multipart/form-data` content type instead of JSON by using
|
|
602
|
-
`
|
|
609
|
+
`ez.upload()` schema. Together with a corresponding configuration option, this makes it possible to handle file uploads.
|
|
603
610
|
Here is a simplified example:
|
|
604
611
|
|
|
605
612
|
```typescript
|
|
606
|
-
import {
|
|
613
|
+
import { z } from "zod";
|
|
614
|
+
import { createConfig, ez, defaultEndpointsFactory } from "express-zod-api";
|
|
607
615
|
|
|
608
616
|
const config = createConfig({
|
|
609
617
|
server: {
|
|
@@ -615,7 +623,7 @@ const config = createConfig({
|
|
|
615
623
|
const fileUploadEndpoint = defaultEndpointsFactory.build({
|
|
616
624
|
method: "post",
|
|
617
625
|
input: z.object({
|
|
618
|
-
avatar:
|
|
626
|
+
avatar: ez.upload(), // <--
|
|
619
627
|
}),
|
|
620
628
|
output: z.object({
|
|
621
629
|
/* ... */
|
|
@@ -942,7 +950,7 @@ in this case during development. You can achieve this verification by assigning
|
|
|
942
950
|
reusing it in forced type of the output:
|
|
943
951
|
|
|
944
952
|
```typescript
|
|
945
|
-
import { z } from "
|
|
953
|
+
import { z } from "zod";
|
|
946
954
|
|
|
947
955
|
const output = z.object({
|
|
948
956
|
anything: z.number(),
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
var br=(e,r,t)=>{if(!r.has(e))throw TypeError("Cannot "+t)};var A=(e,r,t)=>{if(r.has(e))throw TypeError("Cannot add the same private member more than once");r instanceof WeakSet?r.add(e):r.set(e,t)};var E=(e,r,t)=>(br(e,r,"access private method"),t);var Rt={silent:!0,warn:!0,debug:!0},Pr=e=>e;import{z as N}from"zod";import{HttpError as Dr}from"http-errors";import{z as S}from"zod";import{mergeDeepRight as At}from"ramda";var x="expressZodApiMeta",ee=e=>{let r=e._def;return r[x]=r[x]||{examples:[]},"example"in e||Object.defineProperties(e,{example:{get:()=>t=>(r[x].examples.push(t),e)}}),e},It=e=>x in e._def?typeof e._def[x]=="object"&&e._def[x]!==null:!1;function Oe(e,r){if(!It(e))return;let t=e._def;return r in t[x]?t[x][r]:void 0}var te=(e,r)=>{if(!It(e))return r;r=ee(r);let t=r._def,o=re(t[x].examples,e._def[x].examples);if(t[x]=At({...t[x],examples:[]},{...e._def[x],examples:[]}),o.type==="single")t[x].examples=o.value;else for(let[n,i]of o.value)t[x].examples.push(At({...n},{...i}));return r};import Er from"mime";var j=Er.getType("json")||"application/json",oe="multipart/form-data";import{INVALID as Zr,OK as Rr,ZodIssueCode as Ar,ZodParsedType as Ir,ZodType as Cr,addIssueToContext as Mr}from"zod";var Nr="ZodUpload",wr=e=>typeof e=="object"&&e!==null&&"name"in e&&"encoding"in e&&"mimetype"in e&&"data"in e&&"tempFilePath"in e&&"truncated"in e&&"size"in e&&"md5"in e&&"mv"in e&&typeof e.name=="string"&&typeof e.mimetype=="string"&&typeof e.data=="object"&&typeof e.tempFilePath=="string"&&typeof e.truncated=="boolean"&&typeof e.size=="number"&&typeof e.md5=="string"&&typeof e.mv=="function",Ge=class extends Cr{_parse(r){let{ctx:t}=this._processInputParams(r);return t.parsedType!==Ir.object||!wr(t.data)?(Mr(t,{code:Ar.custom,message:`Expected file upload, received ${t.parsedType}`}),Zr):Rr(t.data)}},L=Ge;L.create=()=>new Ge({typeName:Nr});var qe=/:([A-Za-z0-9_]+)/g;function vr(e){let t=(e.header("content-type")||"").slice(0,oe.length).toLowerCase()===oe;return"files"in e&&t}var be={get:["query","params"],post:["body","params","files"],put:["body","params"],patch:["body","params"],delete:["query","params"]},zr=["body","query","params"],Ve=e=>e.method.toLowerCase();function Ct(e,r){let t=Ve(e);if(t==="options")return{};let o=zr;return t in be&&(o=be[t]),r&&t in r&&(o=r[t]||o),o.filter(n=>n==="files"?vr(e):!0).reduce((n,i)=>({...n,...e[i]}),{})}function Be(e){return typeof e=="object"&&"level"in e&&"color"in e&&Object.keys(Rt).includes(e.level)&&typeof e.color=="boolean"}function Pe(e){return!isNaN(e.getTime())}function ie(e){return e instanceof Error?e:new Error(typeof e=="symbol"?e.toString():`${e}`)}function k(e){return e instanceof S.ZodError?e.issues.map(({path:r,message:t})=>(r.length?[r.join("/")]:[]).concat(t).join(": ")).join("; "):e instanceof U?`output${e.originalError.issues[0]?.path.length>0?"/":": "}${e.message}`:e.message}function Ye(e){return e instanceof Dr?e.statusCode:e instanceof C?400:500}var Ee=(e,r)=>{let t=Oe(e,"examples");return t===void 0?[]:t.reduce((o,n)=>{let i=e.safeParse(n);return o.concat(i.success?r?i.data:n:[])},[])},re=(e,r)=>{if(e.length===0)return{type:"single",value:r};if(r.length===0)return{type:"single",value:e};let t=[];for(let o of e)for(let n of r)t.push([o,n]);return{type:"tuple",value:t}};function Je(e){let r=e.match(qe);return r?r.map(t=>t.slice(1)):[]}var ne=e=>e.reduce((r,t)=>r||t,!1);function I(e){return e instanceof S.ZodEffects&&e._def.effect.type!=="refinement"?!0:e instanceof S.ZodUnion?ne(e.options.map(I)):e instanceof S.ZodIntersection?ne([e._def.left,e._def.right].map(I)):!1}function Z(e){return e instanceof L?!0:e instanceof S.ZodObject?ne(Object.values(e.shape).map(Z)):e instanceof S.ZodUnion?ne(e.options.map(Z)):e instanceof S.ZodIntersection?ne([e._def.left,e._def.right].map(Z)):e instanceof S.ZodOptional||e instanceof S.ZodNullable?Z(e.unwrap()):e instanceof S.ZodEffects||e instanceof S.ZodTransformer?Z(e._def.schema):e instanceof S.ZodRecord?Z(e._def.valueType):e instanceof S.ZodArray?Z(e._def.type):e instanceof S.ZodDefault?Z(e._def.innerType):!1}var se=e=>"coerce"in e._def&&typeof e._def.coerce=="boolean"?e._def.coerce:!1,ae=(e,r,t)=>[r].concat(e.split("/")).concat(t||[]).flatMap(o=>o.split(/[^A-Z0-9]/gi)).map(o=>o.slice(0,1).toUpperCase()+o.slice(1).toLowerCase()).join(""),Ze=({effect:e,sample:r})=>{try{return typeof e.transform(r,{addIssue:()=>{},path:[]})}catch{return}},We=e=>typeof e=="string"?{message:e}:e||{};var $=class extends Error{constructor(){super(...arguments);this.name="RoutingError"}},pe=class extends ${constructor(){super(...arguments);this.name="DependsOnMethodError"}},b=class extends Error{constructor(){super(...arguments);this.name="OpenAPIError"}},M=class extends Error{constructor(){super(...arguments);this.name="IOSchemaError"}},U=class extends M{constructor(t){super(k(t));this.name="OutputValidationError";this.originalError=t}},C=class extends M{constructor(t){super(k(t));this.name="InputValidationError";this.originalError=t}},G=class extends Error{constructor(t,o){super(t);this.name="ResultHandlerError";this.originalError=o||void 0}};var R=e=>typeof e=="object"&&e!==null,Re=e=>({and:e.reduce((r,t)=>r.concat(R(t)&&"and"in t?t.and:t),[])}),Ae=(e,r)=>{if(R(e)){if("and"in e)return{and:e.and.map(t=>R(t)&&"or"in t?{or:t.or.map(r)}:r(t))};if("or"in e)return{or:e.or.map(t=>R(t)&&"and"in t?{and:t.and.map(r)}:r(t))}}return r(e)},Qe=e=>e.and.reduce((r,t)=>{let o=re(r.or,R(t)&&"or"in t?t.or:[t]);return o.type==="single"?r.or.push(...o.value):r.or=o.value.map(Re),r},{or:[]}),q=(e,r)=>{if(R(e)){if("and"in e){if(R(r)){if("and"in r)return Re([e,r]);if("or"in r)return q(Qe(e),r)}return Re([e,r])}if("or"in e){if(R(r)){if("and"in r)return q(r,e);if("or"in r){let t=re(e.or,r.or);return{or:t.type==="single"?t.value:t.value.map(Re)}}}return q(e,{and:[r]})}}return R(r)&&("and"in r||"or"in r)?q(r,e):{and:[e,r]}};import{z as V}from"zod";var B={positive:200,negative:400},Mt=e=>e,Y=Mt({getPositiveResponse:e=>{let r=Oe(e,"examples")||[],t=ee(V.object({status:V.literal("success"),data:e}));for(let o of r)t.example({status:"success",data:o});return t},getNegativeResponse:()=>ee(V.object({status:V.literal("error"),error:V.object({message:V.string()})})).example({status:"error",error:{message:k(new Error("Sample error message"))}}),handler:({error:e,input:r,output:t,request:o,response:n,logger:i})=>{if(!e){n.status(B.positive).json({status:"success",data:t});return}let a=Ye(e);a===500&&i.error(`Internal server error
|
|
2
|
+
${e.stack}
|
|
3
|
+
`,{url:o.url,payload:r}),n.status(a).json({status:"error",error:{message:k(e)}})}}),Ie=({error:e,logger:r,response:t})=>{r.error(`Result handler failure: ${e.message}.`),t.status(500).end(`An error occurred while serving the result: ${e.message}.`+(e.originalError?`
|
|
4
|
+
Original error: ${e.originalError.message}.`:""))};var Nt=(e,r=[j])=>{if(e instanceof N.ZodType)return r;let{mimeTypes:t,mimeType:o}=e;return o?[o]:t||r},J=class{},Me,wt,Ne,Dt,we,vt,De,zt,ve,jt,Ce=class extends J{constructor({middlewares:t,inputSchema:o,outputSchema:n,handler:i,resultHandler:a,description:p,shortDescription:l,...c}){super();A(this,Me);A(this,Ne);A(this,we);A(this,De);A(this,ve);this.methods=[];this.siblingMethods=[];this.middlewares=[];this.scopes=[];this.tags=[];[{name:"input schema",schema:o},{name:"output schema",schema:n}].forEach(({name:u,schema:g})=>{if(I(g))throw new M(`Using transformations on the top level of endpoint ${u} is not allowed.`)}),this.middlewares=t;let d={positive:a.getPositiveResponse(n),negative:a.getNegativeResponse()};this.mimeTypes={input:Z(o)?[oe]:[j],positive:Nt(d.positive),negative:Nt(d.negative)},this.schemas={input:o,output:n,positive:d.positive instanceof N.ZodType?d.positive:d.positive.schema,negative:d.negative instanceof N.ZodType?d.negative:d.negative.schema},this.statusCodes={positive:d.positive instanceof N.ZodType?B.positive:d.positive.statusCode||B.positive,negative:d.negative instanceof N.ZodType?B.negative:d.negative.statusCode||B.negative},this.handler=i,this.resultHandler=a,this.descriptions={long:p,short:l},"scopes"in c&&c.scopes&&this.scopes.push(...c.scopes),"scope"in c&&c.scope&&this.scopes.push(c.scope),"tags"in c&&c.tags&&this.tags.push(...c.tags),"tag"in c&&c.tag&&this.tags.push(c.tag),"methods"in c?this.methods=c.methods:this.methods=[c.method]}_setSiblingMethods(t){this.siblingMethods=t}getDescription(t){return this.descriptions[t]}getMethods(){return this.methods}getSchema(t){return this.schemas[t]}getMimeTypes(t){return this.mimeTypes[t]}getStatusCode(t){return this.statusCodes[t]}getSecurity(){return this.middlewares.reduce((t,o)=>o.security?q(t,o.security):t,{and:[]})}getScopes(){return this.scopes}getTags(){return this.tags}async execute({request:t,response:o,logger:n,config:i}){let a=Ve(t),p,l=null;if(i.cors){let d=E(this,Me,wt).call(this);typeof i.cors=="function"&&(d=await i.cors({request:t,logger:n,endpoint:this,defaultHeaders:d}));for(let u in d)o.set(u,d[u])}let c=Ct(t,i.inputSources);try{let{options:d,isStreamClosed:u}=await E(this,we,vt).call(this,{method:a,input:c,request:t,response:o,logger:n});if(u)return;if(a==="options"){o.status(200).end();return}p=await E(this,Ne,Dt).call(this,await E(this,De,zt).call(this,{input:c,options:d,logger:n}))}catch(d){l=ie(d)}await E(this,ve,jt).call(this,{input:c,output:p,request:t,response:o,error:l,logger:n})}};Me=new WeakSet,wt=function(){return{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":this.methods.concat(this.siblingMethods).concat("options").join(", ").toUpperCase(),"Access-Control-Allow-Headers":"content-type"}},Ne=new WeakSet,Dt=async function(t){try{return await this.schemas.output.parseAsync(t)}catch(o){throw o instanceof N.ZodError?new U(o):o}},we=new WeakSet,vt=async function({method:t,input:o,request:n,response:i,logger:a}){let p={},l=!1;for(let c of this.middlewares){if(t==="options"&&c.type==="proprietary")continue;let d;try{d=await c.input.parseAsync(o)}catch(u){throw u instanceof N.ZodError?new C(u):u}if(Object.assign(p,await c.middleware({input:d,options:p,request:n,response:i,logger:a})),l="writableEnded"in i&&i.writableEnded,l){a.warn(`The middleware ${c.middleware.name} has closed the stream. Accumulated options:`,p);break}}return{options:p,isStreamClosed:l}},De=new WeakSet,zt=async function({input:t,options:o,logger:n}){let i;try{i=await this.schemas.input.parseAsync(t)}catch(a){throw a instanceof N.ZodError?new C(a):a}return this.handler({input:i,options:o,logger:n})},ve=new WeakSet,jt=async function({error:t,request:o,response:n,logger:i,input:a,output:p}){try{await this.resultHandler.handler({error:t,output:p,request:o,response:n,logger:i,input:a})}catch(l){Ie({logger:i,response:n,error:new G(ie(l).message,t)})}};var Lt=["get","post","put","delete","patch"];import{z as Ut}from"zod";var kt=(e,r)=>{let t=e.map(({input:o})=>o).concat(r).reduce((o,n)=>o.and(n));for(let o of e)te(o.input,t);return te(r,t),t};var Xe=e=>{if(I(e.input))throw new M("Using transformations on the top level of middleware input schema is not allowed.");return{...e,type:"proprietary"}};var Q,ze,W=class{constructor(r){this.middlewares=[];this.use=this.addExpressMiddleware;this.resultHandler="resultHandler"in r?r.resultHandler:r}addMiddleware(r){var t;return E(t=W,Q,ze).call(t,this.middlewares.concat(r),this.resultHandler)}addExpressMiddleware(r,t){var a;let o=t?.transformer||(p=>p),n=t?.provider||(()=>({})),i={type:"express",input:Ut.object({}),middleware:async({request:p,response:l})=>new Promise((c,d)=>{r(p,l,g=>{if(g&&g instanceof Error)return d(o(g));c(n(p,l))})})};return E(a=W,Q,ze).call(a,this.middlewares.concat(i),this.resultHandler)}addOptions(r){var t;return E(t=W,Q,ze).call(t,this.middlewares.concat(Xe({input:Ut.object({}),middleware:async()=>r})),this.resultHandler)}build({input:r,handler:t,output:o,...n}){let{middlewares:i,resultHandler:a}=this;return new Ce({handler:t,middlewares:i,outputSchema:o,resultHandler:a,inputSchema:kt(i,r),...n})}},de=W;Q=new WeakSet,ze=function(r,t){let o=new W(t);return o.middlewares=r,o},A(de,Q);var jr=new de(Y);import{inspect as Lr}from"util";import{LEVEL as kr,MESSAGE as Ur,SPLAT as Hr}from"triple-beam";import je from"winston";var{combine:Kr,colorize:Fr,timestamp:_r,printf:$r}=je.format;function Le(e){let r=i=>{let{[kr]:a,[Ur]:p,[Hr]:l,...c}=i;return Lr(c,!1,1,e.color)},t=i=>$r(({timestamp:a,message:p,level:l,durationMs:c,...d})=>(typeof p=="object"&&(d={...d,...p},p="[No message]"),`${a} ${l}: ${p}`+(c===void 0?"":` duration: ${c}ms`)+(Object.keys(d).length===0?"":" "+(i?r(d):JSON.stringify(d))))),o=[_r()],n={handleExceptions:!0};switch(e.color&&o.push(Fr()),e.level){case"debug":n.level="debug",o.push(t(!0));break;case"silent":case"warn":default:n.level="warn",o.push(t())}return n.format=Kr(...o),je.createLogger({silent:e.level==="silent",levels:je.config.npm.levels,transports:[new je.transports.Console(n)],exitOnError:!1})}var ce=class{constructor(r){this.methods=r;Object.keys(r).forEach(t=>{if(t in r&&!(r[t]?.getMethods()||[]).includes(t))throw new pe(`The endpoint assigned to the '${t}' parameter must have at least this method in its specification.
|
|
5
|
+
This error should prevent mistakes during the development process.
|
|
6
|
+
Example:
|
|
7
|
+
|
|
8
|
+
new ${this.constructor.name}({
|
|
9
|
+
${t}: endpointsFactory.build({
|
|
10
|
+
methods: ['${t}', `+((r[t]?.getMethods()||[]).map(n=>`'${n}'`).join(", ")||"...")+`]
|
|
11
|
+
// or method: '${t}'
|
|
12
|
+
...
|
|
13
|
+
})
|
|
14
|
+
});
|
|
15
|
+
`)})}};import Gr from"express";var le=class{constructor(...r){this.params=r}apply(r,t){return t(r,Gr.static(...this.params))}};var H=({routing:e,onEndpoint:r,onStatic:t,parentPath:o,hasCors:n})=>{Object.entries(e).forEach(([i,a])=>{if(i=i.trim(),i.match(/\//))throw new $(`Routing elements should not contain '/' character.
|
|
16
|
+
The error caused by ${o?`'${o}' route that has a '${i}'`:`'${i}'`} entry.`);let p=`${o||""}${i?`/${i}`:""}`;if(a instanceof J){let l=a.getMethods().slice();n&&l.push("options"),l.forEach(c=>{r(a,p,c)})}else if(a instanceof le)t&&a.apply(p,t);else if(a instanceof ce){if(Object.entries(a.methods).forEach(([l,c])=>{r(c,p,l)}),n&&Object.keys(a.methods).length>0){let[l,...c]=Object.keys(a.methods),d=a.methods[l];d._setSiblingMethods(c),r(d,p,"options")}}else H({onEndpoint:r,onStatic:t,hasCors:n,routing:a,parentPath:p})})};var Ht=()=>`
|
|
17
|
+
\x1B[94m\x1B[39m
|
|
18
|
+
\x1B[94m\x1B[39m
|
|
19
|
+
\x1B[94m8888888888 8888888888P 888 d8888 8888888b. 8888888 \x1B[39m
|
|
20
|
+
\x1B[94m888 d88P 888 d88888 888 Y88b 888\x1B[39m\x1B[95m\x1B[39m
|
|
21
|
+
\x1B[95m888 d88P 888 d88P888 888 888 888\x1B[39m
|
|
22
|
+
\x1B[95m8888888 888 888 88888b. 888d888 .d88b. .d8888b .d8888b d88P .d88b. .d88888 d88P 888 888 d88P 888\x1B[39m\x1B[97m\x1B[39m
|
|
23
|
+
\x1B[97m888 \`Y8bd8P' 888 "88b 888P" d8P Y8b 88K 88K d88P d88""88b d88" 888 d88P 888 8888888P" 888 \x1B[39m
|
|
24
|
+
\x1B[97m888 X88K 888 888 888 88888888 "Y8888b. "Y8888b. d88P 888 888 888 888 d88P 888 888 888\x1B[39m\x1B[95m\x1B[39m
|
|
25
|
+
\x1B[95m888 .d8""8b. 888 d88P 888 Y8b. X88 X88 d88P Y88..88P Y88b 888 d8888888888 888 888 \x1B[39m
|
|
26
|
+
\x1B[95m8888888888 888 888 88888P" 888 "Y8888 88888P' 88888P' d8888888888 "Y88P" "Y88888 d88P 888 888 8888888\x1B[39m\x1B[94m\x1B[39m
|
|
27
|
+
\x1B[94m 888\x1B[39m
|
|
28
|
+
\x1B[94m 888\x1B[3m Proudly supports transgender community.\x1B[23m\x1B[39m
|
|
29
|
+
\x1B[94m\x1B[3mfor Brianna \x1B[23m 888\x1B[3m Start your API server with I/O schema validation and custom middlewares in minutes.\x1B[23m\x1B[39m\x1B[90m\x1B[39m
|
|
30
|
+
\x1B[90m\x1B[3m Thank you for choosing Express Zod API for your project.\x1B[23m\x1B[39m\x1B[0m\x1B[0m
|
|
31
|
+
\x1B[0m\x1B[0m
|
|
32
|
+
\x1B[0m\x1B[0m
|
|
33
|
+
`.trim();var et=({app:e,logger:r,config:t,routing:o})=>{t.startupLogo!==!1&&console.log(Ht()),H({routing:o,hasCors:!!t.cors,onEndpoint:(n,i,a)=>{e[a](i,async(p,l)=>{r.info(`${p.method}: ${i}`),await n.execute({request:p,response:l,logger:r,config:t})})},onStatic:(n,i)=>{e.use(n,i)}})};import qr,{json as Vr}from"express";import Br from"compression";import Yr from"express-fileupload";import Jr from"https";import Wr from"http-errors";var Qr=(e,r)=>(t,o,n,i)=>{if(!t)return i();e.handler({error:t,request:o,response:n,logger:r,input:o.body,output:null})},Kt=(e,r)=>(t,o)=>{let n=Wr(404,`Can not ${t.method} ${t.path}`);try{e.handler({request:t,response:o,logger:r,error:n,input:null,output:null})}catch(i){Ie({response:o,logger:r,error:new G(ie(i).message,n)})}};function Xr(e,r){let t=Be(e.logger)?Le(e.logger):e.logger;et({app:e.app,routing:r,logger:t,config:e});let o=e.errorHandler||Y;return{notFoundHandler:Kt(o,t),logger:t}}function eo(e,r){let t=Be(e.logger)?Le(e.logger):e.logger,o=qr();o.disable("x-powered-by");let n=e.errorHandler||Y,i=e.server.compression?Br({...typeof e.server.compression=="object"?e.server.compression:{}}):void 0,a=e.server.jsonParser||Vr(),p=e.server.upload?Yr({...typeof e.server.upload=="object"?e.server.upload:{},abortOnLimit:!1,parseNested:!0}):void 0,l=[].concat(i||[]).concat(a).concat(p||[]);o.use(l),o.use(Qr(n,t)),et({app:o,routing:r,logger:t,config:e}),o.use(Kt(n,t));let c=o.listen(e.server.listen,()=>{t.info(`Listening ${e.server.listen}`)}),d;return e.https&&(d=Jr.createServer(e.https.options,o).listen(e.https.listen,()=>{t.info(`Listening ${e.https.listen}`)})),{app:o,httpServer:c,httpsServer:d,logger:t}}import{OpenApiBuilder as Ho}from"openapi3-ts";import{omit as fe}from"ramda";import{z as h}from"zod";import{INVALID as Ft,ZodIssueCode as tt,ZodParsedType as _t,ZodType as to,addIssueToContext as rt}from"zod";var ot=/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d+)?)?Z?$/,ro="ZodDateIn",nt=class extends to{_parse(r){let{status:t,ctx:o}=this._processInputParams(r);if(o.parsedType!==_t.string)return rt(o,{code:tt.invalid_type,expected:_t.string,received:o.parsedType}),Ft;ot.test(o.data)||(rt(o,{code:tt.invalid_string,validation:"regex"}),t.dirty());let n=new Date(o.data);return Pe(n)?{status:t.value,value:n}:(rt(o,{code:tt.invalid_date}),Ft)}},me=nt;me.create=()=>new nt({typeName:ro});var K=({schema:e,onEach:r,rules:t,onMissing:o,...n})=>{let i=r&&r({schema:e,...n}),a="typeName"in e._def?t[e._def.typeName]:void 0,l=a?a({schema:e,...n,next:c=>K({...c,...n,onEach:r,rules:t,onMissing:o})}):o(e);return i?{...l,...i}:l};var $t=50,qt="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString",oo={integer:0,number:0,string:"",boolean:!1,object:{},null:null,array:[]},Vt=e=>e.replace(qe,r=>`{${r.slice(1)}}`),no=({schema:{_def:{innerType:e,defaultValue:r}},next:t})=>({...t({schema:e}),default:r()}),io=({schema:{_def:{innerType:e}},next:r})=>r({schema:e}),so=()=>({format:"any"}),ao=({isResponse:e})=>{if(e)throw new b("Please use z.upload() only for input.");return{type:"string",format:"binary"}},po=({schema:{isBinary:e,isBase64:r},isResponse:t})=>{if(!t)throw new b("Please use z.file() only within ResultHandler.");return{type:"string",format:e?"binary":r?"byte":"file"}},co=({schema:{options:e},next:r})=>({oneOf:e.map(t=>r({schema:t}))}),lo=({schema:{options:e,discriminator:r},next:t})=>({discriminator:{propertyName:r},oneOf:Array.from(e.values()).map(o=>t({schema:o}))}),mo=({schema:{_def:{left:e,right:r}},next:t})=>({allOf:[e,r].map(o=>t({schema:o}))}),uo=({schema:e,next:r})=>r({schema:e.unwrap()}),fo=({schema:e,next:r})=>({nullable:!0,...r({schema:e.unwrap()})}),Gt=({schema:e})=>({type:typeof Object.values(e.enum)[0],enum:Object.values(e.enum)}),yo=({schema:{value:e}})=>({type:typeof e,enum:[e]}),go=({schema:e,isResponse:r,next:t})=>{let o=Object.keys(e.shape).filter(n=>{let i=e.shape[n];return!(r&&se(i)?i instanceof h.ZodOptional:i.isOptional())});return{type:"object",properties:ke({schema:e,isResponse:r,next:t}),...o.length?{required:o}:{}}},xo=()=>({type:"string",nullable:!0,format:"null"}),ho=({isResponse:e})=>{if(e)throw new b("Please use z.dateOut() for output.");return{description:"YYYY-MM-DDTHH:mm:ss.sssZ",type:"string",format:"date-time",pattern:ot.source,externalDocs:{url:qt}}},To=({isResponse:e})=>{if(!e)throw new b("Please use z.dateIn() for input.");return{description:"YYYY-MM-DDTHH:mm:ss.sssZ",type:"string",format:"date-time",externalDocs:{url:qt}}},So=({isResponse:e})=>{throw new b(`Using z.date() within ${e?"output":"input"} schema is forbidden. Please use z.date${e?"Out":"In"}() instead. Check out the documentation for details.`)},Oo=()=>({type:"boolean"}),bo=()=>({type:"integer",format:"bigint"}),Po=({schema:{keySchema:e,valueSchema:r},isResponse:t,next:o})=>{if(e instanceof h.ZodEnum||e instanceof h.ZodNativeEnum){let n=Object.values(e.enum),i=n.reduce((a,p)=>({...a,[p]:r}),{});return{type:"object",properties:ke({schema:h.object(i),isResponse:t,next:o}),...n.length?{required:n}:{}}}if(e instanceof h.ZodLiteral)return{type:"object",properties:ke({schema:h.object({[e.value]:r}),isResponse:t,next:o}),required:[e.value]};if(e instanceof h.ZodUnion&&e.options.reduce((i,a)=>i&&a instanceof h.ZodLiteral,!0)){let i=e.options.reduce((a,p)=>({...a,[p.value]:r}),{});return{type:"object",properties:ke({schema:h.object(i),isResponse:t,next:o}),required:e.options.map(a=>a.value)}}return{type:"object",additionalProperties:o({schema:r})}},Eo=({schema:{_def:e,element:r},next:t})=>({type:"array",items:t({schema:r}),...e.minLength!==null&&{minItems:e.minLength.value},...e.maxLength!==null&&{maxItems:e.maxLength.value}}),Zo=({schema:{items:e},next:r})=>{let t=e.map(o=>r({schema:o}));return{type:"array",minItems:t.length,maxItems:t.length,items:{oneOf:t,format:"tuple",...t.length>0&&{description:t.map((o,n)=>`${n}: ${o.type}`).join(", ")}}}},Ro=({schema:{isEmail:e,isURL:r,minLength:t,maxLength:o,isUUID:n,isCUID:i,isCUID2:a,isULID:p,isIP:l,isEmoji:c,isDatetime:d,_def:{checks:u}}})=>{let g=u.find(O=>O.kind==="regex"),y=u.find(O=>O.kind==="datetime"),T=g?g.regex:y?y.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}:\\d{2})|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$"):void 0;return{type:"string",...d&&{format:"date-time"},...e&&{format:"email"},...r&&{format:"url"},...n&&{format:"uuid"},...i&&{format:"cuid"},...a&&{format:"cuid2"},...p&&{format:"ulid"},...l&&{format:"ip"},...c&&{format:"emoji"},...t!==null&&{minLength:t},...o!==null&&{maxLength:o},...T&&{pattern:`/${T.source}/${T.flags}`}}},Ao=({schema:e})=>{let r=e._def.checks.find(({kind:i})=>i==="min"),t=r?r.inclusive:!0,o=e._def.checks.find(({kind:i})=>i==="max"),n=o?o.inclusive:!0;return{type:e.isInt?"integer":"number",format:e.isInt?"int64":"double",minimum:e.minValue===null?e.isInt?Number.MIN_SAFE_INTEGER:Number.MIN_VALUE:e.minValue,exclusiveMinimum:!t,maximum:e.maxValue===null?e.isInt?Number.MAX_SAFE_INTEGER:Number.MAX_VALUE:e.maxValue,exclusiveMaximum:!n}},ke=({schema:{shape:e},next:r})=>Object.keys(e).reduce((t,o)=>({...t,[o]:r({schema:e[o]})}),{}),Io=e=>{let r=Array.isArray(e.type)?e.type[0]:e.type;return oo?.[r]},Co=({schema:e,isResponse:r,next:t})=>{let o=t({schema:e.innerType()}),{effect:n}=e._def;if(r&&n.type==="transform"){let i=Ze({effect:n,sample:Io(o)});return i&&["number","string","boolean"].includes(i)?{type:i}:t({schema:h.any()})}if(!r&&n.type==="preprocess"){let{type:i,...a}=o;return{...a,format:`${a.format||i} (preprocessed)`}}return o},Mo=({schema:e,isResponse:r,next:t})=>t({schema:e._def[r?"out":"in"]}),No=({schema:e,next:r})=>r({schema:e.unwrap()}),Bt=(e,r,t=[])=>{let o=Ee(e,r);return o.length===0?{}:{examples:o.reduce((n,i,a)=>({...n,[`example${a+1}`]:{value:fe(t,i)}}),{})}},wo=(e,r,t)=>{let o=Ee(e,r);return o.length===0?{}:{examples:o.reduce((n,i,a)=>t in i?{...n,[`example${a+1}`]:{value:i[t]}}:n,{})}};function ue(e){if(e instanceof h.ZodObject)return e;let r;if(e instanceof h.ZodUnion||e instanceof h.ZodDiscriminatedUnion)r=Array.from(e.options.values()).map(t=>ue(t)).reduce((t,o)=>t.merge(o.partial()),h.object({}));else if(e instanceof h.ZodEffects){if(I(e))throw new b("Using transformations on the top level of input schema is not allowed.");r=ue(e._def.schema)}else r=ue(e._def.left).merge(ue(e._def.right));return te(e,r)}var Yt=({path:e,method:r,endpoint:t,inputSources:o})=>{let n=t.getSchema("input"),i=ue(n).shape,a=Je(e),p=o.includes("query"),l=o.includes("params"),c=d=>l&&a.includes(d);return Object.keys(i).filter(d=>p||c(d)).map(d=>({name:d,in:c(d)?"path":"query",required:!i[d].isOptional(),schema:{description:`${r.toUpperCase()} ${e} parameter`,...K({schema:i[d],isResponse:!1,rules:st,onEach:at,onMissing:pt})},...wo(n,!1,d)}))},st={ZodString:Ro,ZodNumber:Ao,ZodBigInt:bo,ZodBoolean:Oo,ZodDateIn:ho,ZodDateOut:To,ZodNull:xo,ZodArray:Eo,ZodTuple:Zo,ZodRecord:Po,ZodObject:go,ZodLiteral:yo,ZodIntersection:mo,ZodUnion:co,ZodFile:po,ZodUpload:ao,ZodAny:so,ZodDefault:no,ZodEnum:Gt,ZodNativeEnum:Gt,ZodEffects:Co,ZodOptional:uo,ZodNullable:fo,ZodDiscriminatedUnion:lo,ZodBranded:No,ZodDate:So,ZodCatch:io,ZodPipeline:Mo},at=({schema:e,isResponse:r})=>{let{description:t}=e,o=Ee(e,r);return{...t&&{description:t},...e.isNullable()&&!(r&&se(e))&&{nullable:!0},...o.length>0&&{example:o[0]}}},pt=e=>{throw new b(`Zod type ${e.constructor.name} is unsupported`)},it=(e,r)=>{let t=e.properties?fe(r,e.properties):void 0,o=e.example?fe(r,e.example):void 0,n=e.required?e.required.filter(p=>!r.includes(p)):void 0,i=e.allOf?e.allOf.map(p=>it(p,r)):void 0,a=e.oneOf?e.oneOf.map(p=>it(p,r)):void 0;return fe(Object.entries({properties:t,required:n,example:o,allOf:i,oneOf:a}).filter(([{},p])=>p===void 0).map(([p])=>p),{...e,properties:t,required:n,example:o,allOf:i,oneOf:a})},Jt=e=>fe(["example"],e),dt=({method:e,path:r,description:t,endpoint:o,isPositive:n})=>{let i=n?o.getSchema("positive"):o.getSchema("negative"),a=n?o.getMimeTypes("positive"):o.getMimeTypes("negative"),p=Jt(K({schema:i,isResponse:!0,rules:st,onEach:at,onMissing:pt})),l=Bt(i,!0);return{description:`${e.toUpperCase()} ${r} ${t}`,content:a.reduce((c,d)=>({...c,[d]:{schema:p,...l}}),{})}},Do=()=>({type:"http",scheme:"basic"}),vo=({format:e})=>({type:"http",scheme:"bearer",...e&&{bearerFormat:e}}),zo=({name:e})=>({type:"apiKey",in:"query",name:e}),jo=({name:e})=>({type:"apiKey",in:"header",name:e}),Lo=({name:e})=>({type:"apiKey",in:"cookie",name:e}),ko=({url:e})=>({type:"openIdConnect",openIdConnectUrl:e}),Uo=({flows:e={}})=>({type:"oauth2",flows:Object.keys(e).reduce((r,t)=>{let o=e[t];if(!o)return r;let{scopes:n={},...i}=o;return{...r,[t]:{...i,scopes:n}}},{})}),Wt=e=>{let r={basic:Do,bearer:vo,input:zo,header:jo,cookie:Lo,openid:ko,oauth2:Uo};return Ae(e,t=>r[t.type](t))},Ue=e=>{if(typeof e=="object"){if("or"in e)return e.or.map(r=>("and"in r?r.and:[r]).reduce((t,{name:o,scopes:n})=>({...t,[o]:n}),{}));if("and"in e)return Ue(Qe(e))}return Ue({or:[e]})},Qt=({method:e,path:r,endpoint:t})=>{let o=Je(r),n=Jt(it(K({schema:t.getSchema("input"),isResponse:!1,rules:st,onEach:at,onMissing:pt}),o)),i=Bt(t.getSchema("input"),!1,o);return{content:t.getMimeTypes("input").reduce((a,p)=>({...a,[p]:{schema:{description:`${e.toUpperCase()} ${r} request body`,...n},...i}}),{})}},Xt=e=>Object.keys(e).map(r=>{let t=e[r];return{name:r,description:typeof t=="string"?t:t.description,...typeof t=="object"&&t.url&&{externalDocs:{url:t.url}}}}),ct=e=>e.length<=$t?e:e.slice(0,$t-1)+"\u2026";var lt=class extends Ho{constructor({routing:t,config:o,title:n,version:i,serverUrl:a,successfulResponseDescription:p="Successful response",errorResponseDescription:l="Error response",hasSummaryFromDescription:c=!0}){super();this.lastSecuritySchemaIds={};this.lastOperationIdSuffixes={};this.addInfo({title:n,version:i}).addServer({url:a}),H({routing:t,onEndpoint:(u,g,y)=>{let T=y,O={path:g,method:T,endpoint:u},[F,_]=["short","long"].map(u.getDescription.bind(u)),he=o.inputSources?.[T]||be[T],Te=Yt({...O,inputSources:he}),P={operationId:this.ensureUniqOperationId(g,T),responses:{[u.getStatusCode("positive")]:dt({...O,description:p,isPositive:!0}),[u.getStatusCode("negative")]:dt({...O,description:l,isPositive:!1})}};_&&(P.description=_,c&&F===void 0&&(P.summary=ct(_))),F&&(P.summary=ct(F)),u.getTags().length>0&&(P.tags=u.getTags()),Te.length>0&&(P.parameters=Te),he.includes("body")&&(P.requestBody=Qt(O));let Se=Ue(Ae(Wt(u.getSecurity()),$e=>{let Zt=this.ensureUniqSecuritySchemaName($e),Or=["oauth2","openIdConnect"].includes($e.type)?u.getScopes():[];return this.addSecurityScheme(Zt,$e),{name:Zt,scopes:Or}}));Se.length>0&&(P.security=Se);let Sr=Vt(g);this.addPath(Sr,{[T]:P})}}),this.rootDoc.tags=o.tags?Xt(o.tags):[]}ensureUniqOperationId(t,o){let n=ae(t,o);return n in this.lastOperationIdSuffixes?(this.lastOperationIdSuffixes[n]++,`${n}${this.lastOperationIdSuffixes[n]}`):(this.lastOperationIdSuffixes[n]=1,n)}ensureUniqSecuritySchemaName(t){for(let o in this.rootDoc.components?.securitySchemes||{})if(JSON.stringify(t)===JSON.stringify(this.rootDoc.components?.securitySchemes?.[o]))return o;return this.lastSecuritySchemaIds[t.type]=(this.lastSecuritySchemaIds?.[t.type]||0)+1,`${t.type.toUpperCase()}_${this.lastSecuritySchemaIds[t.type]}`}};import er from"http";var Ko=e=>({method:"GET",header:jest.fn(()=>j),...e}),Fo=e=>{let r={writableEnded:!1,statusCode:200,statusMessage:er.STATUS_CODES[200],set:jest.fn(()=>r),status:jest.fn(t=>(r.statusCode=t,r.statusMessage=er.STATUS_CODES[t],r)),json:jest.fn(()=>r),end:jest.fn(()=>(r.writableEnded=!0,r)),...e};return r},_o=async({endpoint:e,requestProps:r,responseProps:t,configProps:o,loggerProps:n,__noJest:i})=>{if(!jest||i)throw new Error("You need to install Jest in order to use testEndpoint().");let a=Ko(r),p=Fo(t),l={info:jest.fn(),warn:jest.fn(),error:jest.fn(),debug:jest.fn(),...n},c={cors:!1,logger:l,...o};return await e.execute({request:a,response:p,config:c,logger:l}),{requestMock:a,responseMock:p,loggerMock:l}};import z from"typescript";import w from"typescript";var s=w.factory,X=[s.createModifier(w.SyntaxKind.ExportKeyword)],$o=[s.createModifier(w.SyntaxKind.PublicKeyword),s.createModifier(w.SyntaxKind.ReadonlyKeyword)],tr=[s.createModifier(w.SyntaxKind.ProtectedKeyword),s.createModifier(w.SyntaxKind.ReadonlyKeyword)],Go=s.createTemplateHead(""),qo=s.createTemplateTail(""),Vo=s.createTemplateMiddle(" "),mt=e=>s.createTemplateLiteralType(Go,e.map((r,t)=>s.createTemplateLiteralTypeSpan(s.createTypeReferenceNode(r),t===e.length-1?qo:Vo))),ut=mt(["M","P"]),He=(e,r,t)=>s.createParameterDeclaration(t,void 0,e,void 0,r),Ke=(e,r)=>Object.keys(e).reduce((t,o)=>t.concat(He(o,e[o],r)),[]),ft=(e,r)=>s.createExpressionWithTypeArguments(s.createIdentifier("Record"),[typeof e=="number"?s.createKeywordTypeNode(e):s.createTypeReferenceNode(e),s.createKeywordTypeNode(r)]),rr=e=>s.createConstructorDeclaration(void 0,e,s.createBlock([])),yt=(e,r)=>s.createPropertySignature(void 0,`"${e}"`,void 0,s.createTypeReferenceNode(r)),or=(e,r)=>s.createVariableDeclarationList([s.createVariableDeclaration(e,void 0,void 0,r)],w.NodeFlags.Const),gt=(e,r)=>s.createTypeAliasDeclaration(X,e,void 0,s.createUnionTypeNode(r.map(t=>s.createLiteralTypeNode(s.createStringLiteral(t))))),Fe=(e,r)=>s.createTypeAliasDeclaration(X,e,void 0,r),nr=(e,r,t)=>s.createPropertyDeclaration($o,e,void 0,r,t),ir=(e,r,t=[])=>s.createClassDeclaration(X,e,void 0,void 0,[r,...t]),sr=(e,r)=>s.createTypeReferenceNode("Promise",[s.createIndexedAccessTypeNode(s.createTypeReferenceNode(e),r)]),ar=()=>s.createTypeReferenceNode("Promise",[s.createKeywordTypeNode(w.SyntaxKind.AnyKeyword)]),xt=(e,r,t)=>s.createInterfaceDeclaration(X,e,void 0,r,t),pr=e=>Object.keys(e).reduce((r,t)=>r.concat(s.createTypeParameterDeclaration([],t,s.createTypeReferenceNode(e[t]))),[]),dr=(e,r)=>s.createArrowFunction(void 0,void 0,e.map(t=>He(t)),void 0,void 0,s.createCallExpression(s.createPropertyAccessExpression(s.createThis(),"implementation"),void 0,r)),ht=(e,r,t)=>s.createCallExpression(s.createPropertyAccessExpression(s.createCallExpression(s.createPropertyAccessExpression(s.createIdentifier("Object"),"keys"),void 0,[s.createIdentifier(e)]),"reduce"),void 0,[s.createArrowFunction(void 0,void 0,Ke({acc:void 0,key:void 0}),void 0,void 0,r),t]);import f from"typescript";import{z as Yo}from"zod";import D from"typescript";var{factory:_e}=D,Tt=(e,r)=>{D.addSyntheticLeadingComment(e,D.SyntaxKind.MultiLineCommentTrivia,`* ${r} `,!0)},St=(e,r,t)=>{let o=_e.createTypeAliasDeclaration(void 0,_e.createIdentifier(r),void 0,e);return t&&Tt(o,t),o},cr=(e,r)=>{let t=D.createSourceFile("print.ts","",D.ScriptTarget.Latest,!1,D.ScriptKind.TS);return D.createPrinter(r).printNode(D.EmitHint.Unspecified,e,t)},Bo=/^[A-Za-z_$][A-Za-z0-9_$]*$/,lr=e=>Bo.test(e)?_e.createIdentifier(e):_e.createStringLiteral(e);var{factory:m}=f,Jo={[f.SyntaxKind.AnyKeyword]:"",[f.SyntaxKind.BigIntKeyword]:BigInt(0),[f.SyntaxKind.BooleanKeyword]:!1,[f.SyntaxKind.NumberKeyword]:0,[f.SyntaxKind.ObjectKeyword]:{},[f.SyntaxKind.StringKeyword]:"",[f.SyntaxKind.UndefinedKeyword]:void 0},Wo=({schema:{value:e}})=>m.createLiteralTypeNode(typeof e=="number"?m.createNumericLiteral(e):typeof e=="boolean"?e?m.createTrue():m.createFalse():m.createStringLiteral(e)),Qo=({schema:{shape:e},isResponse:r,next:t})=>{let o=Object.entries(e).map(([n,i])=>{let a=r&&se(i)?i instanceof Yo.ZodOptional:i.isOptional(),p=m.createPropertySignature(void 0,lr(n),a?m.createToken(f.SyntaxKind.QuestionToken):void 0,t({schema:i}));return i.description&&Tt(p,i.description),p});return m.createTypeLiteralNode(o)},Xo=({schema:{element:e},next:r})=>m.createArrayTypeNode(r({schema:e})),en=({schema:{options:e}})=>m.createUnionTypeNode(e.map(r=>m.createLiteralTypeNode(m.createStringLiteral(r)))),mr=({schema:{options:e},next:r})=>m.createUnionTypeNode(e.map(t=>r({schema:t}))),tn=e=>Jo?.[e.kind],rn=({schema:e,next:r,isResponse:t})=>{let o=r({schema:e.innerType()}),n=e._def.effect;if(t&&n.type==="transform"){let i=Ze({effect:n,sample:tn(o)}),a={number:f.SyntaxKind.NumberKeyword,bigint:f.SyntaxKind.BigIntKeyword,boolean:f.SyntaxKind.BooleanKeyword,string:f.SyntaxKind.StringKeyword,undefined:f.SyntaxKind.UndefinedKeyword,object:f.SyntaxKind.ObjectKeyword};return m.createKeywordTypeNode(i&&a[i]||f.SyntaxKind.AnyKeyword)}return o},on=({schema:e})=>m.createUnionTypeNode(Object.values(e.enum).map(r=>m.createLiteralTypeNode(typeof r=="number"?m.createNumericLiteral(r):m.createStringLiteral(r)))),nn=({next:e,schema:r})=>m.createUnionTypeNode([e({schema:r.unwrap()}),m.createKeywordTypeNode(f.SyntaxKind.UndefinedKeyword)]),sn=({next:e,schema:r})=>m.createUnionTypeNode([e({schema:r.unwrap()}),m.createLiteralTypeNode(m.createNull())]),an=({next:e,schema:{items:r}})=>m.createTupleTypeNode(r.map(t=>e({schema:t}))),pn=({next:e,schema:{keySchema:r,valueSchema:t}})=>m.createExpressionWithTypeArguments(m.createIdentifier("Record"),[e({schema:r}),e({schema:t})]),dn=({next:e,schema:r})=>m.createIntersectionTypeNode([r._def.left,r._def.right].map(t=>e({schema:t}))),cn=({next:e,schema:r})=>e({schema:r._def.innerType}),v=e=>()=>m.createKeywordTypeNode(e),ln=({next:e,schema:r})=>e({schema:r.unwrap()}),mn=({next:e,schema:r})=>e({schema:r._def.innerType}),un=({schema:e,next:r,isResponse:t})=>r({schema:e._def[t?"out":"in"]}),fn=()=>m.createLiteralTypeNode(m.createNull()),yn={ZodString:v(f.SyntaxKind.StringKeyword),ZodNumber:v(f.SyntaxKind.NumberKeyword),ZodBigInt:v(f.SyntaxKind.BigIntKeyword),ZodBoolean:v(f.SyntaxKind.BooleanKeyword),ZodDateIn:v(f.SyntaxKind.StringKeyword),ZodDateOut:v(f.SyntaxKind.StringKeyword),ZodNull:fn,ZodArray:Xo,ZodTuple:an,ZodRecord:pn,ZodObject:Qo,ZodLiteral:Wo,ZodIntersection:dn,ZodUnion:mr,ZodFile:v(f.SyntaxKind.StringKeyword),ZodAny:v(f.SyntaxKind.AnyKeyword),ZodDefault:cn,ZodEnum:en,ZodNativeEnum:on,ZodEffects:rn,ZodOptional:nn,ZodNullable:sn,ZodDiscriminatedUnion:mr,ZodBranded:ln,ZodCatch:mn,ZodPipeline:un},Ot=({schema:e,...r})=>K({schema:e,rules:yn,onMissing:()=>m.createKeywordTypeNode(f.SyntaxKind.AnyKeyword),...r});var bt=class{constructor(r){this.agg=[];this.registry={};this.paths=[];H({routing:r,onEndpoint:(y,T,O)=>{let F=ae(T,O,"input"),_=ae(T,O,"response"),he=Ot({schema:y.getSchema("input"),isResponse:!1}),Te=Ot({isResponse:!0,schema:y.getSchema("positive").or(y.getSchema("negative"))}),P=St(he,F),Se=St(Te,_);this.agg.push(P),this.agg.push(Se),O!=="options"&&(this.paths.push(T),this.registry[`${O} ${T}`]={in:F,out:_,isJson:y.getMimeTypes("positive").includes(j)})}});let t=gt("Path",this.paths),o=gt("Method",Lt),n=Fe("MethodPath",mt([o.name,t.name])),i=[s.createHeritageClause(z.SyntaxKind.ExtendsKeyword,[ft(n.name,z.SyntaxKind.AnyKeyword)])],a=xt("Input",i,Object.keys(this.registry).map(y=>yt(y,this.registry[y].in))),p=xt("Response",i,Object.keys(this.registry).map(y=>yt(y,this.registry[y].out))),l=s.createVariableStatement(X,or("jsonEndpoints",s.createObjectLiteralExpression(Object.keys(this.registry).filter(y=>this.registry[y].isJson).map(y=>s.createPropertyAssignment(`"${y}"`,s.createTrue()))))),c=Fe("Provider",s.createFunctionTypeNode(pr({M:o.name,P:t.name}),Ke({method:s.createTypeReferenceNode("M"),path:s.createTypeReferenceNode("P"),params:s.createIndexedAccessTypeNode(s.createTypeReferenceNode(a.name),ut)}),sr(p.name,ut))),d=Fe("Implementation",s.createFunctionTypeNode(void 0,Ke({method:s.createTypeReferenceNode(o.name),path:s.createKeywordTypeNode(z.SyntaxKind.StringKeyword),params:ft(z.SyntaxKind.StringKeyword,z.SyntaxKind.AnyKeyword)}),ar())),u=s.createTemplateExpression(s.createTemplateHead(":"),[s.createTemplateSpan(s.createIdentifier("key"),s.createTemplateTail(""))]),g=ir("ExpressZodAPIClient",rr([He("implementation",s.createTypeReferenceNode(d.name),tr)]),[nr("provide",s.createTypeReferenceNode(c.name),dr(["method","path","params"],[s.createIdentifier("method"),ht("params",s.createCallExpression(s.createPropertyAccessExpression(s.createIdentifier("acc"),"replace"),void 0,[u,s.createElementAccessExpression(s.createIdentifier("params"),s.createIdentifier("key"))]),s.createIdentifier("path")),ht("params",s.createConditionalExpression(s.createBinaryExpression(s.createCallExpression(s.createPropertyAccessExpression(s.createIdentifier("path"),"indexOf"),void 0,[u]),z.SyntaxKind.GreaterThanEqualsToken,s.createNumericLiteral(0)),void 0,s.createIdentifier("acc"),void 0,s.createObjectLiteralExpression([s.createSpreadAssignment(s.createIdentifier("acc")),s.createPropertyAssignment("[key]",s.createElementAccessExpression(s.createIdentifier("params"),s.createIdentifier("key")))])),s.createObjectLiteralExpression())]))]);z.addSyntheticLeadingComment(g,z.SyntaxKind.MultiLineCommentTrivia,`
|
|
34
|
+
export const exampleImplementation: Implementation = async (
|
|
35
|
+
method,
|
|
36
|
+
path,
|
|
37
|
+
params
|
|
38
|
+
) => {
|
|
39
|
+
const searchParams =
|
|
40
|
+
method === "get" ? \`?\${new URLSearchParams(params)}\` : "";
|
|
41
|
+
const response = await fetch(\`https://example.com\${path}\${searchParams}\`, {
|
|
42
|
+
method: method.toUpperCase(),
|
|
43
|
+
headers:
|
|
44
|
+
method === "get" ? undefined : { "Content-Type": "application/json" },
|
|
45
|
+
body: method === "get" ? undefined : JSON.stringify(params),
|
|
46
|
+
});
|
|
47
|
+
if (\`\${method} \${path}\` in jsonEndpoints) {
|
|
48
|
+
return response.json();
|
|
49
|
+
}
|
|
50
|
+
return response.text();
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const client = new ExpressZodAPIClient(exampleImplementation);
|
|
54
|
+
client.provide("get", "/v1/user/retrieve", { id: "10" });
|
|
55
|
+
`,!0),this.agg.push(t,o,n,a,p,l,c,d,g)}print(r){return this.agg.map(t=>cr(t,r)).join(`
|
|
56
|
+
|
|
57
|
+
`)}};import{INVALID as ur,ZodIssueCode as fr,ZodParsedType as yr,ZodType as gn,addIssueToContext as gr}from"zod";var xn="ZodDateOut",Pt=class extends gn{_parse(r){let{status:t,ctx:o}=this._processInputParams(r);return o.parsedType!==yr.date?(gr(o,{code:fr.invalid_type,expected:yr.date,received:o.parsedType}),ur):Pe(o.data)?{status:t.value,value:o.data.toISOString()}:(gr(o,{code:fr.invalid_date}),ur)}},ye=Pt;ye.create=()=>new Pt({typeName:xn});import{INVALID as hn,ZodIssueCode as xr,ZodParsedType as hr,ZodType as Tn,addIssueToContext as Tr}from"zod";var Sn="ZodFile",On=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,xe=class extends Tn{constructor(){super(...arguments);this.binary=t=>new xe({...this._def,checks:[...this._def.checks,{kind:"binary",...We(t)}]});this.base64=t=>new xe({...this._def,checks:[...this._def.checks,{kind:"base64",...We(t)}]})}_parse(t){let{status:o,ctx:n}=this._processInputParams(t);if(n.parsedType!==hr.string)return Tr(n,{code:xr.invalid_type,expected:hr.string,received:n.parsedType}),hn;for(let i of this._def.checks)i.kind==="base64"&&(On.test(n.data)||(Tr(n,{code:xr.custom,message:i.message}),o.dirty()));return{status:o.value,value:n.data}}get isBinary(){return!!this._def.checks.find(t=>t.kind==="binary")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}},ge=xe;ge.create=()=>new xe({checks:[],typeName:Sn});var Et;(n=>(n.file=ge.create,n.upload=L.create,n.dateIn=me.create,n.dateOut=ye.create))(Et||(Et={}));import La from"http-errors";export{J as AbstractEndpoint,bt as Client,ce as DependsOnMethod,pe as DependsOnMethodError,de as EndpointsFactory,C as InputValidationError,lt as OpenAPI,b as OpenAPIError,U as OutputValidationError,$ as RoutingError,le as ServeStatic,Xr as attachRouting,Pr as createConfig,La as createHttpError,Le as createLogger,Xe as createMiddleware,Mt as createResultHandler,eo as createServer,jr as defaultEndpointsFactory,Y as defaultResultHandler,Et as ez,k as getMessageFromError,Ye as getStatusCodeFromError,_o as testEndpoint,ee as withMeta};
|
|
58
|
+
//# sourceMappingURL=index.js.map
|