express-zod-api 4.2.0 → 5.1.0-beta2
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 +66 -0
- package/README.md +68 -6
- package/SECURITY.md +2 -1
- package/dist/config-type.d.ts +6 -0
- package/dist/config-type.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/mock.d.ts +30 -0
- package/dist/mock.js +59 -0
- package/dist/mock.js.map +1 -0
- package/dist/server.d.ts +7 -2
- package/dist/server.js +11 -1
- package/dist/server.js.map +1 -1
- package/dist/startup-logo.js +1 -1
- package/dist-esm/config-type.js.map +1 -1
- package/dist-esm/index.js +1 -0
- package/dist-esm/index.js.map +1 -1
- package/dist-esm/mock.js +52 -0
- package/dist-esm/mock.js.map +1 -0
- package/dist-esm/package.json +1 -1
- package/dist-esm/server.js +11 -1
- package/dist-esm/server.js.map +1 -1
- package/dist-esm/startup-logo.js +1 -1
- package/package.json +13 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,71 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## Version 5
|
|
4
|
+
|
|
5
|
+
### v5.1.0-beta2
|
|
6
|
+
|
|
7
|
+
- Fixing a warning message when using `testEndpoint()` method.
|
|
8
|
+
|
|
9
|
+
### v5.1.0-beta1
|
|
10
|
+
|
|
11
|
+
- Feature #252: a helper method for testing your endpoints: `testEndpoint()`.
|
|
12
|
+
- Requires `jest` (and optionally `@types/jest`) to be installed.
|
|
13
|
+
- The method helps to mock the request, response, config and logger required to execute the endpoint.
|
|
14
|
+
- The method executes the endpoint and returns the created mocks.
|
|
15
|
+
- After that you only need to assert your expectations in the test.
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { testEndpoint } from "express-zod-api";
|
|
19
|
+
|
|
20
|
+
test("should respond successfully", async () => {
|
|
21
|
+
const { responseMock, loggerMock } = await testEndpoint({
|
|
22
|
+
endpoint: yourEndpoint,
|
|
23
|
+
requestProps: {
|
|
24
|
+
method: "POST",
|
|
25
|
+
body: { ... },
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
expect(loggerMock.error).toBeCalledTimes(0);
|
|
29
|
+
expect(responseMock.status).toBeCalledWith(200);
|
|
30
|
+
expect(responseMock.json).toBeCalledWith({
|
|
31
|
+
status: "success",
|
|
32
|
+
data: { ... },
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### v5.0.0
|
|
38
|
+
|
|
39
|
+
- No changes.
|
|
40
|
+
|
|
41
|
+
### v5.0.0-beta1
|
|
42
|
+
|
|
43
|
+
- The ability to configure and run an additional HTTPS server to process requests over a secure protocol.
|
|
44
|
+
- This option is only available when using `createServer()` method.
|
|
45
|
+
- **Breaking changes**: Instead of HTTP Server the method `createServer()` now returns an object with the following
|
|
46
|
+
entities: `app, httpServer, httpsServer, logger`.
|
|
47
|
+
- New configuration option `https`:
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
import { createConfig } from "express-zod-api";
|
|
51
|
+
|
|
52
|
+
const config = createConfig({
|
|
53
|
+
server: {
|
|
54
|
+
listen: 80,
|
|
55
|
+
},
|
|
56
|
+
// enables HTTPS server as well
|
|
57
|
+
https: {
|
|
58
|
+
// at least "cert" and "key" options required
|
|
59
|
+
options: {
|
|
60
|
+
cert: fs.readFileSync("fullchain.pem", "utf-8"),
|
|
61
|
+
key: fs.readFileSync("privkey.pem", "utf-8"),
|
|
62
|
+
},
|
|
63
|
+
listen: 443, // port or socket
|
|
64
|
+
},
|
|
65
|
+
// ...
|
|
66
|
+
});
|
|
67
|
+
```
|
|
68
|
+
|
|
3
69
|
## Version 4
|
|
4
70
|
|
|
5
71
|
### v4.2.0
|
package/README.md
CHANGED
|
@@ -38,14 +38,16 @@ Start your API server with I/O schema validation and custom middlewares in minut
|
|
|
38
38
|
10. [Usage with your own express app](#usage-with-your-own-express-app)
|
|
39
39
|
11. [Multiple schemas for one route](#multiple-schemas-for-one-route)
|
|
40
40
|
12. [Customizing input sources](#customizing-input-sources)
|
|
41
|
-
13. [
|
|
42
|
-
14. [
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
13. [Enabling HTTPS](#enabling-https)
|
|
42
|
+
14. [Exporting endpoint types to frontend](#exporting-endpoint-types-to-frontend)
|
|
43
|
+
15. [Creating a documentation](#creating-a-documentation)
|
|
44
|
+
5. [Additional hints](#additional-hints)
|
|
45
|
+
1. [How to test endpoints](#how-to-test-endpoints)
|
|
46
|
+
2. [Excessive properties in endpoint output](#excessive-properties-in-endpoint-output)
|
|
45
47
|
6. [Your input to my output](#your-input-to-my-output)
|
|
46
48
|
|
|
47
49
|
You can find the release notes in [Changelog](CHANGELOG.md). Along with recommendations for migrating from
|
|
48
|
-
[v3](CHANGELOG.md#v400), [v2](CHANGELOG.md#v300-beta1) and [v1](CHANGELOG.md#v200-beta1).
|
|
50
|
+
[v4](CHANGELOG.md#v500-beta1), [v3](CHANGELOG.md#v400), [v2](CHANGELOG.md#v300-beta1) and [v1](CHANGELOG.md#v200-beta1).
|
|
49
51
|
|
|
50
52
|
# Why and what is it for
|
|
51
53
|
|
|
@@ -573,6 +575,36 @@ createConfig({
|
|
|
573
575
|
});
|
|
574
576
|
```
|
|
575
577
|
|
|
578
|
+
## Enabling HTTPS
|
|
579
|
+
|
|
580
|
+
The modern API standard often assumes the use of a secure data transfer protocol, confirmed by a TLS certificate, also
|
|
581
|
+
often called an SSL certificate in habit. When using the `createServer()` method, you can additionally configure and
|
|
582
|
+
run the HTTPS server.
|
|
583
|
+
|
|
584
|
+
```typescript
|
|
585
|
+
import { createConfig, createServer } from "express-zod-api";
|
|
586
|
+
|
|
587
|
+
const config = createConfig({
|
|
588
|
+
server: {
|
|
589
|
+
listen: 80,
|
|
590
|
+
},
|
|
591
|
+
https: {
|
|
592
|
+
options: {
|
|
593
|
+
cert: fs.readFileSync("fullchain.pem", "utf-8"),
|
|
594
|
+
key: fs.readFileSync("privkey.pem", "utf-8"),
|
|
595
|
+
},
|
|
596
|
+
listen: 443, // port or socket
|
|
597
|
+
},
|
|
598
|
+
// ... cors, logger, etc
|
|
599
|
+
});
|
|
600
|
+
|
|
601
|
+
const { app, httpServer, httpsServer, logger } = createServer(config, routing);
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
At least you need to specify the port or socket (usually it is 443), certificate and the key, issued by the
|
|
605
|
+
certifying authority. For example, you can acquire a free TLS certificate for your API at
|
|
606
|
+
[Let's Encrypt](https://letsencrypt.org/).
|
|
607
|
+
|
|
576
608
|
## Exporting endpoint types to frontend
|
|
577
609
|
|
|
578
610
|
You can export only the types of your endpoints for your frontend. Here is an approach:
|
|
@@ -629,7 +661,37 @@ const exampleEndpoint = defaultEndpointsFactory.build({
|
|
|
629
661
|
_See the example of the generated documentation
|
|
630
662
|
[here](https://github.com/RobinTail/express-zod-api/blob/master/example/example.swagger.yaml)_
|
|
631
663
|
|
|
632
|
-
#
|
|
664
|
+
# Additional hints
|
|
665
|
+
|
|
666
|
+
## How to test endpoints
|
|
667
|
+
|
|
668
|
+
The way to test endpoints is to mock the request, response, and logger objects, invoke the `execute()` method, and
|
|
669
|
+
assert the expectations for calls of certain mocked methods. The library provides a special method that makes mocking
|
|
670
|
+
easier, so the test might look the following way:
|
|
671
|
+
|
|
672
|
+
```typescript
|
|
673
|
+
import { testEndpoint } from "express-zod-api";
|
|
674
|
+
|
|
675
|
+
test("should respond successfully", async () => {
|
|
676
|
+
const { responseMock, loggerMock } = await testEndpoint({
|
|
677
|
+
endpoint: yourEndpoint,
|
|
678
|
+
// available options: requestProps, responseProps, configProps, loggerProps
|
|
679
|
+
requestProps: {
|
|
680
|
+
method: "POST", // default: GET
|
|
681
|
+
body: { ... },
|
|
682
|
+
},
|
|
683
|
+
});
|
|
684
|
+
expect(loggerMock.error).toBeCalledTimes(0);
|
|
685
|
+
expect(responseMock.status).toBeCalledWith(200);
|
|
686
|
+
expect(responseMock.json).toBeCalledWith({
|
|
687
|
+
status: "success",
|
|
688
|
+
data: { ... },
|
|
689
|
+
});
|
|
690
|
+
});
|
|
691
|
+
```
|
|
692
|
+
|
|
693
|
+
_This method is optimized for the standard result handler. With the flexibility to customize, you can add additional
|
|
694
|
+
properties as needed._
|
|
633
695
|
|
|
634
696
|
## Excessive properties in endpoint output
|
|
635
697
|
|
package/SECURITY.md
CHANGED
package/dist/config-type.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { NextHandleFunction } from "connect";
|
|
2
3
|
import { Express, Request } from "express";
|
|
3
4
|
import fileUpload from "express-fileupload";
|
|
5
|
+
import { ServerOptions } from "https";
|
|
4
6
|
import { Logger } from "winston";
|
|
5
7
|
import { Method } from "./method";
|
|
6
8
|
import { ResultHandlerDefinition } from "./result-handler";
|
|
@@ -20,6 +22,10 @@ export interface ServerConfig {
|
|
|
20
22
|
jsonParser?: NextHandleFunction;
|
|
21
23
|
upload?: boolean | UploadOptions;
|
|
22
24
|
};
|
|
25
|
+
https?: {
|
|
26
|
+
options: ServerOptions;
|
|
27
|
+
listen: number | string;
|
|
28
|
+
};
|
|
23
29
|
}
|
|
24
30
|
export interface AppConfig {
|
|
25
31
|
app: Express;
|
package/dist/config-type.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-type.js","sourceRoot":"","sources":["../src/config-type.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"config-type.js","sourceRoot":"","sources":["../src/config-type.ts"],"names":[],"mappings":";;;AAQa,QAAA,YAAY,GAAG;IAC1B,MAAM,EAAE,IAAI;IACZ,IAAI,EAAE,IAAI;IACV,KAAK,EAAE,IAAI;CACZ,CAAC;AA0DK,MAAM,YAAY,GAAG,CAG1B,MAAS,EACN,EAAE,CAAC,MAAM,CAAC;AAJF,QAAA,YAAY,gBAIV"}
|
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export { createServer, attachRouting } from "./server";
|
|
|
12
12
|
export { OpenAPI } from "./open-api";
|
|
13
13
|
export { OpenAPIError, DependsOnMethodError, RoutingError } from "./errors";
|
|
14
14
|
export { withMeta } from "./metadata";
|
|
15
|
+
export { testEndpoint } from "./mock";
|
|
15
16
|
import * as z from "./extend-zod";
|
|
16
17
|
import createHttpError from "http-errors";
|
|
17
18
|
export { createHttpError, z };
|
package/dist/index.js
CHANGED
|
@@ -22,7 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
22
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.z = exports.createHttpError = exports.withMeta = exports.RoutingError = exports.DependsOnMethodError = exports.OpenAPIError = exports.OpenAPI = exports.attachRouting = exports.createServer = exports.DependsOnMethod = exports.defaultResultHandler = exports.createResultHandler = exports.createMiddleware = exports.createLogger = exports.createApiResponse = exports.markOutput = exports.defaultEndpointsFactory = exports.EndpointsFactory = exports.AbstractEndpoint = exports.createConfig = void 0;
|
|
25
|
+
exports.z = exports.createHttpError = exports.testEndpoint = exports.withMeta = exports.RoutingError = exports.DependsOnMethodError = exports.OpenAPIError = exports.OpenAPI = exports.attachRouting = exports.createServer = exports.DependsOnMethod = exports.defaultResultHandler = exports.createResultHandler = exports.createMiddleware = exports.createLogger = exports.createApiResponse = exports.markOutput = exports.defaultEndpointsFactory = exports.EndpointsFactory = exports.AbstractEndpoint = exports.createConfig = void 0;
|
|
26
26
|
var config_type_1 = require("./config-type");
|
|
27
27
|
Object.defineProperty(exports, "createConfig", { enumerable: true, get: function () { return config_type_1.createConfig; } });
|
|
28
28
|
var endpoint_1 = require("./endpoint");
|
|
@@ -54,6 +54,8 @@ Object.defineProperty(exports, "DependsOnMethodError", { enumerable: true, get:
|
|
|
54
54
|
Object.defineProperty(exports, "RoutingError", { enumerable: true, get: function () { return errors_1.RoutingError; } });
|
|
55
55
|
var metadata_1 = require("./metadata");
|
|
56
56
|
Object.defineProperty(exports, "withMeta", { enumerable: true, get: function () { return metadata_1.withMeta; } });
|
|
57
|
+
var mock_1 = require("./mock");
|
|
58
|
+
Object.defineProperty(exports, "testEndpoint", { enumerable: true, get: function () { return mock_1.testEndpoint; } });
|
|
57
59
|
const z = __importStar(require("./extend-zod"));
|
|
58
60
|
exports.z = z;
|
|
59
61
|
const http_errors_1 = __importDefault(require("http-errors"));
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA2D;AAAlD,2GAAA,YAAY,OAAA;AACrB,uCAKoB;AAJlB,4GAAA,gBAAgB,OAAA;AAMlB,yDAAgF;AAAvE,qHAAA,gBAAgB,OAAA;AAAE,4HAAA,uBAAuB,OAAA;AAClD,mDAAoE;AAArC,4GAAA,UAAU,OAAA;AACzC,+CAAmD;AAA1C,iHAAA,iBAAiB,OAAA;AAC1B,mCAAwC;AAA/B,sGAAA,YAAY,OAAA;AACrB,2CAAgD;AAAvC,8GAAA,gBAAgB,OAAA;AACzB,mDAA6E;AAApE,qHAAA,mBAAmB,OAAA;AAAE,sHAAA,oBAAoB,OAAA;AAClD,qCAAqD;AAAnC,0GAAA,eAAe,OAAA;AACjC,mCAAuD;AAA9C,sGAAA,YAAY,OAAA;AAAE,uGAAA,aAAa,OAAA;AACpC,uCAAqC;AAA5B,mGAAA,OAAO,OAAA;AAChB,mCAA4E;AAAnE,sGAAA,YAAY,OAAA;AAAE,8GAAA,oBAAoB,OAAA;AAAE,sGAAA,YAAY,OAAA;AACzD,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA2D;AAAlD,2GAAA,YAAY,OAAA;AACrB,uCAKoB;AAJlB,4GAAA,gBAAgB,OAAA;AAMlB,yDAAgF;AAAvE,qHAAA,gBAAgB,OAAA;AAAE,4HAAA,uBAAuB,OAAA;AAClD,mDAAoE;AAArC,4GAAA,UAAU,OAAA;AACzC,+CAAmD;AAA1C,iHAAA,iBAAiB,OAAA;AAC1B,mCAAwC;AAA/B,sGAAA,YAAY,OAAA;AACrB,2CAAgD;AAAvC,8GAAA,gBAAgB,OAAA;AACzB,mDAA6E;AAApE,qHAAA,mBAAmB,OAAA;AAAE,sHAAA,oBAAoB,OAAA;AAClD,qCAAqD;AAAnC,0GAAA,eAAe,OAAA;AACjC,mCAAuD;AAA9C,sGAAA,YAAY,OAAA;AAAE,uGAAA,aAAa,OAAA;AACpC,uCAAqC;AAA5B,mGAAA,OAAO,OAAA;AAChB,mCAA4E;AAAnE,sGAAA,YAAY,OAAA;AAAE,8GAAA,oBAAoB,OAAA;AAAE,sGAAA,YAAY,OAAA;AACzD,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,+BAAsC;AAA7B,oGAAA,YAAY,OAAA;AAErB,gDAAkC;AAGR,cAAC;AAF3B,8DAA0C;AAEjC,0BAFF,qBAAe,CAEE"}
|
package/dist/mock.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/// <reference types="qs" />
|
|
2
|
+
/// <reference types="jest" />
|
|
3
|
+
import { Request, Response } from "express";
|
|
4
|
+
import { Logger } from "winston";
|
|
5
|
+
import { CommonConfig } from "./config-type";
|
|
6
|
+
import { AbstractEndpoint } from "./endpoint";
|
|
7
|
+
interface TestEndpointProps<REQ, RES, LOG> {
|
|
8
|
+
endpoint: AbstractEndpoint;
|
|
9
|
+
requestProps?: REQ;
|
|
10
|
+
responseProps?: RES;
|
|
11
|
+
configProps?: Partial<CommonConfig>;
|
|
12
|
+
loggerProps?: LOG;
|
|
13
|
+
/** @deprecated for testing purposes only */
|
|
14
|
+
__noJest?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* @description You need to install Jest and probably @types/jest to use this method
|
|
18
|
+
*/
|
|
19
|
+
export declare const testEndpoint: <REQ extends Partial<Record<keyof Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, any>> | undefined = undefined, RES extends Partial<Record<keyof Response<any, Record<string, any>>, any>> | undefined = undefined, LOG extends Partial<Record<keyof Logger, any>> | undefined = undefined>({ endpoint, requestProps, responseProps, configProps, loggerProps, __noJest, }: TestEndpointProps<REQ, RES, LOG>) => Promise<{
|
|
20
|
+
requestMock: {
|
|
21
|
+
method: string;
|
|
22
|
+
} & Record<"header", jest.Mock<any, any>> & (REQ extends undefined ? {} : REQ);
|
|
23
|
+
responseMock: {
|
|
24
|
+
writableEnded: boolean;
|
|
25
|
+
statusCode: number;
|
|
26
|
+
statusMessage: string;
|
|
27
|
+
} & Record<"json" | "status" | "set" | "end", jest.Mock<any, any>> & (RES extends undefined ? {} : RES);
|
|
28
|
+
loggerMock: Record<"error" | "warn" | "debug" | "info", jest.Mock<any, any>> & (LOG extends undefined ? {} : LOG);
|
|
29
|
+
}>;
|
|
30
|
+
export {};
|
package/dist/mock.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.testEndpoint = void 0;
|
|
7
|
+
const http_1 = __importDefault(require("http"));
|
|
8
|
+
const mime_1 = require("./mime");
|
|
9
|
+
/**
|
|
10
|
+
* @description You need to install Jest and probably @types/jest to use this method
|
|
11
|
+
*/
|
|
12
|
+
const testEndpoint = async ({ endpoint, requestProps, responseProps, configProps, loggerProps, __noJest, }) => {
|
|
13
|
+
if (!jest || __noJest) {
|
|
14
|
+
throw new Error("You need to install Jest in order to use testEndpoint().");
|
|
15
|
+
}
|
|
16
|
+
const requestMock = {
|
|
17
|
+
method: "GET",
|
|
18
|
+
header: jest.fn(() => mime_1.mimeJson),
|
|
19
|
+
...requestProps,
|
|
20
|
+
};
|
|
21
|
+
const responseMock = {
|
|
22
|
+
writableEnded: false,
|
|
23
|
+
statusCode: 200,
|
|
24
|
+
statusMessage: http_1.default.STATUS_CODES[200],
|
|
25
|
+
set: jest.fn(() => responseMock),
|
|
26
|
+
status: jest.fn((code) => {
|
|
27
|
+
responseMock.statusCode = code;
|
|
28
|
+
responseMock.statusMessage = http_1.default.STATUS_CODES[code];
|
|
29
|
+
return responseMock;
|
|
30
|
+
}),
|
|
31
|
+
json: jest.fn(() => responseMock),
|
|
32
|
+
end: jest.fn(() => {
|
|
33
|
+
responseMock.writableEnded = true;
|
|
34
|
+
return responseMock;
|
|
35
|
+
}),
|
|
36
|
+
...responseProps,
|
|
37
|
+
};
|
|
38
|
+
const loggerMock = {
|
|
39
|
+
info: jest.fn(),
|
|
40
|
+
warn: jest.fn(),
|
|
41
|
+
error: jest.fn(),
|
|
42
|
+
debug: jest.fn(),
|
|
43
|
+
...loggerProps,
|
|
44
|
+
};
|
|
45
|
+
const configMock = {
|
|
46
|
+
cors: false,
|
|
47
|
+
logger: loggerMock,
|
|
48
|
+
...configProps,
|
|
49
|
+
};
|
|
50
|
+
await endpoint.execute({
|
|
51
|
+
request: requestMock,
|
|
52
|
+
response: responseMock,
|
|
53
|
+
config: configMock,
|
|
54
|
+
logger: loggerMock,
|
|
55
|
+
});
|
|
56
|
+
return { requestMock, responseMock, loggerMock };
|
|
57
|
+
};
|
|
58
|
+
exports.testEndpoint = testEndpoint;
|
|
59
|
+
//# sourceMappingURL=mock.js.map
|
package/dist/mock.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock.js","sourceRoot":"","sources":["../src/mock.ts"],"names":[],"mappings":";;;;;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AK,EAAE,IAAI,CAAC,EAAE,EAAE;QAChB,GAAG,WAAW;KACf,CAAC;IACF,MAAM,UAAU,GAAG;QACjB,IAAI,EAAE,KAAK;QACX,MAAM,EAAE,UAAU;QAClB,GAAG,WAAW;KACf,CAAC;IACF,MAAM,QAAQ,CAAC,OAAO,CAAC;QACrB,OAAO,EAAE,WAAiC;QAC1C,QAAQ,EAAE,YAAmC;QAC7C,MAAM,EAAE,UAA0B;QAClC,MAAM,EAAE,UAA+B;KACxC,CAAC,CAAC;IACH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC;AACnD,CAAC,CAAC;AArEW,QAAA,YAAY,gBAqEvB"}
|
package/dist/server.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import express, { ErrorRequestHandler, RequestHandler } from "express";
|
|
4
|
-
import
|
|
4
|
+
import https from "https";
|
|
5
5
|
import { Logger } from "winston";
|
|
6
6
|
import { AppConfig, CommonConfig, ServerConfig } from "./config-type";
|
|
7
7
|
import { Routing } from "./routing";
|
|
@@ -11,4 +11,9 @@ export declare function attachRouting(config: AppConfig & CommonConfig, routing:
|
|
|
11
11
|
notFoundHandler: express.RequestHandler<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
|
|
12
12
|
logger: Logger;
|
|
13
13
|
};
|
|
14
|
-
export declare function createServer(config: ServerConfig & CommonConfig, routing: Routing):
|
|
14
|
+
export declare function createServer(config: ServerConfig & CommonConfig, routing: Routing): {
|
|
15
|
+
app: import("express-serve-static-core").Express;
|
|
16
|
+
httpServer: import("http").Server;
|
|
17
|
+
httpsServer: https.Server | undefined;
|
|
18
|
+
logger: Logger;
|
|
19
|
+
};
|
package/dist/server.js
CHANGED
|
@@ -25,6 +25,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
25
25
|
exports.createServer = exports.attachRouting = exports.createNotFoundHandler = exports.createParserFailureHandler = void 0;
|
|
26
26
|
const express_1 = __importStar(require("express"));
|
|
27
27
|
const express_fileupload_1 = __importDefault(require("express-fileupload"));
|
|
28
|
+
const https_1 = __importDefault(require("https"));
|
|
28
29
|
const errors_1 = require("./errors");
|
|
29
30
|
const common_helpers_1 = require("./common-helpers");
|
|
30
31
|
const logger_1 = require("./logger");
|
|
@@ -98,9 +99,18 @@ function createServer(config, routing) {
|
|
|
98
99
|
app.use((0, exports.createParserFailureHandler)(errorHandler, logger));
|
|
99
100
|
(0, routing_1.initRouting)({ app, routing, logger, config });
|
|
100
101
|
app.use((0, exports.createNotFoundHandler)(errorHandler, logger));
|
|
101
|
-
|
|
102
|
+
const httpServer = app.listen(config.server.listen, () => {
|
|
102
103
|
logger.info(`Listening ${config.server.listen}`);
|
|
103
104
|
});
|
|
105
|
+
let httpsServer;
|
|
106
|
+
if (config.https) {
|
|
107
|
+
httpsServer = https_1.default
|
|
108
|
+
.createServer(config.https.options, app)
|
|
109
|
+
.listen(config.https.listen, () => {
|
|
110
|
+
logger.info(`Listening ${config.https.listen}`);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
return { app, httpServer, httpsServer, logger };
|
|
104
114
|
}
|
|
105
115
|
exports.createServer = createServer;
|
|
106
116
|
//# sourceMappingURL=server.js.map
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAA6E;AAC7E,4EAA4C;
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAA6E;AAC7E,4EAA4C;AAC5C,kDAA0B;AAG1B,qCAA8C;AAC9C,qDAAkD;AAClD,qCAAwC;AACxC,qDAA2E;AAC3E,uCAAiD;AACjD,8DAA0C;AA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AAC,IAAA,kCAA0B,EAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1D,IAAA,qBAAW,EAAC,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC9C,GAAG,CAAC,GAAG,CAAC,IAAA,6BAAqB,EAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC;IAErD,MAAM,UAAU,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE;QACvD,MAAM,CAAC,IAAI,CAAC,aAAa,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;IAEH,IAAI,WAAqC,CAAC;IAC1C,IAAI,MAAM,CAAC,KAAK,EAAE;QAChB,WAAW,GAAG,eAAK;aAChB,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC;aACvC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,EAAE;YAChC,MAAM,CAAC,IAAI,CAAC,aAAa,MAAM,CAAC,KAAM,CAAC,MAAM,EAAE,CAAC,CAAC;QACnD,CAAC,CAAC,CAAC;KACN;IAED,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;AAClD,CAAC;AAvCD,oCAuCC"}
|
package/dist/startup-logo.js
CHANGED
|
@@ -17,7 +17,7 @@ const getStartupLogo = () => {
|
|
|
17
17
|
[95m8888888888 888 888 88888P" 888 "Y8888 88888P' 88888P' d8888888888 "Y88P" "Y88888 d88P 888 888 8888888[39m[94m[39m
|
|
18
18
|
[94m 888[39m
|
|
19
19
|
[94m 888[3m Proudly supports transgender community.[23m[39m
|
|
20
|
-
[94m[3mfor
|
|
20
|
+
[94m[3mfor Ella [23m 888[3m Start your API server with I/O schema validation and custom middlewares in minutes.[23m[39m[90m[39m
|
|
21
21
|
[90m[3m Thank you for choosing Express Zod API for your project.[23m[39m[0m[0m
|
|
22
22
|
[0m[0m
|
|
23
23
|
[0m[0m
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-type.js","sourceRoot":"","sources":["../src/config-type.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config-type.js","sourceRoot":"","sources":["../src/config-type.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,MAAM,EAAE,IAAI;IACZ,IAAI,EAAE,IAAI;IACV,KAAK,EAAE,IAAI;CACZ,CAAC;AA0DF,MAAM,CAAC,MAAM,YAAY,GAAG,CAG1B,MAAS,EACN,EAAE,CAAC,MAAM,CAAC"}
|
package/dist-esm/index.js
CHANGED
|
@@ -11,6 +11,7 @@ export { createServer, attachRouting } from "./server.js";
|
|
|
11
11
|
export { OpenAPI } from "./open-api.js";
|
|
12
12
|
export { OpenAPIError, DependsOnMethodError, RoutingError } from "./errors.js";
|
|
13
13
|
export { withMeta } from "./metadata.js";
|
|
14
|
+
export { testEndpoint } from "./mock.js";
|
|
14
15
|
import * as z from "./extend-zod.js";
|
|
15
16
|
import createHttpError from "http-errors";
|
|
16
17
|
export { createHttpError, z };
|
package/dist-esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAgB,MAAM,eAAe,CAAC;AAC3D,OAAO,EACL,gBAAgB,GAIjB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAwB,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE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AU,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,eAAe,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,CAAC"}
|
package/dist-esm/mock.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import http from "http";
|
|
2
|
+
import { mimeJson } from "./mime.js";
|
|
3
|
+
/**
|
|
4
|
+
* @description You need to install Jest and probably @types/jest to use this method
|
|
5
|
+
*/
|
|
6
|
+
export const testEndpoint = async ({ endpoint, requestProps, responseProps, configProps, loggerProps, __noJest, }) => {
|
|
7
|
+
if (!jest || __noJest) {
|
|
8
|
+
throw new Error("You need to install Jest in order to use testEndpoint().");
|
|
9
|
+
}
|
|
10
|
+
const requestMock = {
|
|
11
|
+
method: "GET",
|
|
12
|
+
header: jest.fn(() => mimeJson),
|
|
13
|
+
...requestProps,
|
|
14
|
+
};
|
|
15
|
+
const responseMock = {
|
|
16
|
+
writableEnded: false,
|
|
17
|
+
statusCode: 200,
|
|
18
|
+
statusMessage: http.STATUS_CODES[200],
|
|
19
|
+
set: jest.fn(() => responseMock),
|
|
20
|
+
status: jest.fn((code) => {
|
|
21
|
+
responseMock.statusCode = code;
|
|
22
|
+
responseMock.statusMessage = http.STATUS_CODES[code];
|
|
23
|
+
return responseMock;
|
|
24
|
+
}),
|
|
25
|
+
json: jest.fn(() => responseMock),
|
|
26
|
+
end: jest.fn(() => {
|
|
27
|
+
responseMock.writableEnded = true;
|
|
28
|
+
return responseMock;
|
|
29
|
+
}),
|
|
30
|
+
...responseProps,
|
|
31
|
+
};
|
|
32
|
+
const loggerMock = {
|
|
33
|
+
info: jest.fn(),
|
|
34
|
+
warn: jest.fn(),
|
|
35
|
+
error: jest.fn(),
|
|
36
|
+
debug: jest.fn(),
|
|
37
|
+
...loggerProps,
|
|
38
|
+
};
|
|
39
|
+
const configMock = {
|
|
40
|
+
cors: false,
|
|
41
|
+
logger: loggerMock,
|
|
42
|
+
...configProps,
|
|
43
|
+
};
|
|
44
|
+
await endpoint.execute({
|
|
45
|
+
request: requestMock,
|
|
46
|
+
response: responseMock,
|
|
47
|
+
config: configMock,
|
|
48
|
+
logger: loggerMock,
|
|
49
|
+
});
|
|
50
|
+
return { requestMock, responseMock, loggerMock };
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=mock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock.js","sourceRoot":"","sources":["../src/mock.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,MAAM,CAAC;AAIxB,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAYlC;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAI/B,EACA,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,WAAW,EACX,WAAW,EACX,QAAQ,GACyB,EAAE,EAAE;IACrC,IAAI,CAAC,IAAI,IAAI,QAAQ,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;KAC7E;IACD,MAAM,WAAW,GAGhB;QACC,MAAM,EAAE,KAAK;QACb,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC;QAC/B,GAAG,YAAY;KAChB,CAAC;IACF,MAAM,YAAY,GAOjB;QACC,aAAa,EAAE,KAAK;QACpB,UAAU,EAAE,GAAG;QACf,aAAa,EAAE,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC;QACrC,GAAG,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC;QAChC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,IAAY,EAAE,EAAE;YAC/B,YAAY,CAAC,UAAU,GAAG,IAAI,CAAC;YAC/B,YAAY,CAAC,aAAa,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;YACrD,OAAO,YAAY,CAAC;QACtB,CAAC,CAAC;QACF,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC;QACjC,GAAG,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE;YAChB,YAAY,CAAC,aAAa,GAAG,IAAI,CAAC;YAClC,OAAO,YAAY,CAAC;QACtB,CAAC,CAAC;QACF,GAAG,aAAa;KACjB,CAAC;IACF,MAAM,UAAU,GAGf;QACC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE;QACf,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE;QACf,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE;QAChB,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE;QAChB,GAAG,WAAW;KACf,CAAC;IACF,MAAM,UAAU,GAAG;QACjB,IAAI,EAAE,KAAK;QACX,MAAM,EAAE,UAAU;QAClB,GAAG,WAAW;KACf,CAAC;IACF,MAAM,QAAQ,CAAC,OAAO,CAAC;QACrB,OAAO,EAAE,WAAiC;QAC1C,QAAQ,EAAE,YAAmC;QAC7C,MAAM,EAAE,UAA0B;QAClC,MAAM,EAAE,UAA+B;KACxC,CAAC,CAAC;IACH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC;AACnD,CAAC,CAAC"}
|
package/dist-esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"
|
|
1
|
+
{"type":"module","version":"5.1.0-beta2"}
|
package/dist-esm/server.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import express, { json } from "express";
|
|
2
2
|
import fileUpload from "express-fileupload";
|
|
3
|
+
import https from "https";
|
|
3
4
|
import { ResultHandlerError } from "./errors.js";
|
|
4
5
|
import { isLoggerConfig } from "./common-helpers.js";
|
|
5
6
|
import { createLogger } from "./logger.js";
|
|
@@ -70,8 +71,17 @@ export function createServer(config, routing) {
|
|
|
70
71
|
app.use(createParserFailureHandler(errorHandler, logger));
|
|
71
72
|
initRouting({ app, routing, logger, config });
|
|
72
73
|
app.use(createNotFoundHandler(errorHandler, logger));
|
|
73
|
-
|
|
74
|
+
const httpServer = app.listen(config.server.listen, () => {
|
|
74
75
|
logger.info(`Listening ${config.server.listen}`);
|
|
75
76
|
});
|
|
77
|
+
let httpsServer;
|
|
78
|
+
if (config.https) {
|
|
79
|
+
httpsServer = https
|
|
80
|
+
.createServer(config.https.options, app)
|
|
81
|
+
.listen(config.https.listen, () => {
|
|
82
|
+
logger.info(`Listening ${config.https.listen}`);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return { app, httpServer, httpsServer, logger };
|
|
76
86
|
}
|
|
77
87
|
//# sourceMappingURL=server.js.map
|
package/dist-esm/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAuC,IAAI,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,UAAU,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAuC,IAAI,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,UAAU,MAAM,oBAAoB,CAAC;AAC5C,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAW,MAAM,WAAW,CAAC;AACj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E,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC9C,GAAG,CAAC,GAAG,CAAC,qBAAqB,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC;IAErD,MAAM,UAAU,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE;QACvD,MAAM,CAAC,IAAI,CAAC,aAAa,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;IAEH,IAAI,WAAqC,CAAC;IAC1C,IAAI,MAAM,CAAC,KAAK,EAAE;QAChB,WAAW,GAAG,KAAK;aAChB,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC;aACvC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,EAAE;YAChC,MAAM,CAAC,IAAI,CAAC,aAAa,MAAM,CAAC,KAAM,CAAC,MAAM,EAAE,CAAC,CAAC;QACnD,CAAC,CAAC,CAAC;KACN;IAED,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;AAClD,CAAC"}
|
package/dist-esm/startup-logo.js
CHANGED
|
@@ -14,7 +14,7 @@ export const getStartupLogo = () => {
|
|
|
14
14
|
[95m8888888888 888 888 88888P" 888 "Y8888 88888P' 88888P' d8888888888 "Y88P" "Y88888 d88P 888 888 8888888[39m[94m[39m
|
|
15
15
|
[94m 888[39m
|
|
16
16
|
[94m 888[3m Proudly supports transgender community.[23m[39m
|
|
17
|
-
[94m[3mfor
|
|
17
|
+
[94m[3mfor Ella [23m 888[3m Start your API server with I/O schema validation and custom middlewares in minutes.[23m[39m[90m[39m
|
|
18
18
|
[90m[3m Thank you for choosing Express Zod API for your project.[23m[39m[0m[0m
|
|
19
19
|
[0m[0m
|
|
20
20
|
[0m[0m
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "express-zod-api",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.1.0-beta2",
|
|
4
4
|
"description": "A Typescript library to help you get an API server up and running with I/O schema validation and custom middlewares in minutes.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"scripts": {
|
|
@@ -44,6 +44,18 @@
|
|
|
44
44
|
"winston": "3.3.3",
|
|
45
45
|
"zod": "3.11.6"
|
|
46
46
|
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"@types/jest": "*",
|
|
49
|
+
"jest": ">=25 <28"
|
|
50
|
+
},
|
|
51
|
+
"peerDependenciesMeta": {
|
|
52
|
+
"jest": {
|
|
53
|
+
"optional": true
|
|
54
|
+
},
|
|
55
|
+
"@types/jest": {
|
|
56
|
+
"optional": true
|
|
57
|
+
}
|
|
58
|
+
},
|
|
47
59
|
"devDependencies": {
|
|
48
60
|
"@tsconfig/node12": "^1.0.9",
|
|
49
61
|
"@types/express": "^4.17.13",
|