@domain.js/main 0.1.2 → 0.1.3
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/cli/index.d.ts +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/http/defines.d.ts +5 -5
- package/dist/http/index.d.ts +2 -1
- package/dist/http/index.js +2 -1
- package/dist/http/router.d.ts +2 -1
- package/dist/http/router.js +3 -3
- package/package.json +2 -1
package/dist/cli/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
#! /usr/bin/env
|
|
1
|
+
#! /usr/bin/env node
|
|
2
2
|
export {};
|
package/dist/cli/index.js
CHANGED
package/dist/http/defines.d.ts
CHANGED
|
@@ -31,12 +31,12 @@ export interface Profile {
|
|
|
31
31
|
export interface HttpCodes {
|
|
32
32
|
[propName: string]: number;
|
|
33
33
|
}
|
|
34
|
-
interface
|
|
35
|
-
[propName: string]: (profile: Profile, params: any) => any |
|
|
34
|
+
export interface Domain {
|
|
35
|
+
[propName: string]: (profile: Profile, params: any) => any | Domain;
|
|
36
|
+
}
|
|
37
|
+
export interface GetSchemaByPath {
|
|
38
|
+
(methodPath: string): [any, any];
|
|
36
39
|
}
|
|
37
|
-
export declare type Domain = _Domain & {
|
|
38
|
-
_getSchemaByPath(methodPath: string): [any, any];
|
|
39
|
-
};
|
|
40
40
|
export interface Err {
|
|
41
41
|
message: string;
|
|
42
42
|
code?: number | string;
|
package/dist/http/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import * as restify from "restify";
|
|
2
2
|
import { Router } from "./router";
|
|
3
|
-
import { Cnf, Domain, Profile, HttpCodes } from "./defines";
|
|
3
|
+
import { Cnf, Domain, Profile, HttpCodes, GetSchemaByPath } from "./defines";
|
|
4
4
|
interface Deps {
|
|
5
5
|
routers(r: ReturnType<typeof Router>): void;
|
|
6
6
|
domain: Domain;
|
|
7
7
|
httpCodes: HttpCodes;
|
|
8
|
+
getSchemaByPath: GetSchemaByPath;
|
|
8
9
|
swaggerDocJson?: any;
|
|
9
10
|
makeProfileHook?: (obj: Profile, req: restify.Request) => any;
|
|
10
11
|
}
|
package/dist/http/index.js
CHANGED
|
@@ -6,7 +6,7 @@ const router_1 = require("./router");
|
|
|
6
6
|
const utils_1 = require("./utils");
|
|
7
7
|
function Main(cnf, deps) {
|
|
8
8
|
const utils = (0, utils_1.Utils)(cnf);
|
|
9
|
-
const { routers, domain, httpCodes, swaggerDocJson, makeProfileHook } = deps;
|
|
9
|
+
const { routers, getSchemaByPath, domain, httpCodes, swaggerDocJson, makeProfileHook } = deps;
|
|
10
10
|
const server = restify.createServer();
|
|
11
11
|
server.use(restify.plugins.queryParser());
|
|
12
12
|
server.use(restify.plugins.bodyParser({
|
|
@@ -18,6 +18,7 @@ function Main(cnf, deps) {
|
|
|
18
18
|
server,
|
|
19
19
|
httpCodes,
|
|
20
20
|
makeProfileHook,
|
|
21
|
+
getSchemaByPath,
|
|
21
22
|
domain,
|
|
22
23
|
apisRoute: cnf.apisRoute,
|
|
23
24
|
swagger: [cnf.swaggerApiPath, swaggerDocJson],
|
package/dist/http/router.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as restify from "restify";
|
|
2
2
|
import { Utils } from "./utils";
|
|
3
|
-
import { HttpCodes, Domain, Profile } from "./defines";
|
|
3
|
+
import { HttpCodes, Domain, Profile, GetSchemaByPath } from "./defines";
|
|
4
4
|
interface Deps {
|
|
5
5
|
domain: Domain;
|
|
6
|
+
getSchemaByPath: GetSchemaByPath;
|
|
6
7
|
utils: ReturnType<typeof Utils>;
|
|
7
8
|
server: restify.Server;
|
|
8
9
|
httpCodes: HttpCodes;
|
package/dist/http/router.js
CHANGED
|
@@ -5,7 +5,7 @@ const _ = require("lodash");
|
|
|
5
5
|
const errors = require("restify-errors");
|
|
6
6
|
const swaggerUi = require("swagger-ui-restify");
|
|
7
7
|
function Router(deps) {
|
|
8
|
-
const { domain, apisRoute, utils, server, httpCodes = {}, makeProfileHook, swagger = ["", {}], } = deps;
|
|
8
|
+
const { domain, apisRoute, getSchemaByPath, utils, server, httpCodes = {}, makeProfileHook, swagger = ["", {}], } = deps;
|
|
9
9
|
const { ucwords, makeParams, makeProfile, outputCSV, jsonSchema2Swagger } = utils;
|
|
10
10
|
// 改写 HttpErrorToJSON 处理 data
|
|
11
11
|
const HttpErrorToJSON = errors.HttpError.prototype.toJSON;
|
|
@@ -56,7 +56,7 @@ function Router(deps) {
|
|
|
56
56
|
const { path } = req.query;
|
|
57
57
|
try {
|
|
58
58
|
const { all } = req.query;
|
|
59
|
-
const schema =
|
|
59
|
+
const schema = getSchemaByPath(path);
|
|
60
60
|
res.send(all === undefined ? schema[1] : schema);
|
|
61
61
|
}
|
|
62
62
|
catch (e) {
|
|
@@ -72,7 +72,7 @@ function Router(deps) {
|
|
|
72
72
|
let apiSchema = [];
|
|
73
73
|
let desc = "";
|
|
74
74
|
try {
|
|
75
|
-
apiSchema =
|
|
75
|
+
apiSchema = getSchemaByPath(methodPath);
|
|
76
76
|
desc = apiSchema[1] ? apiSchema[1].description : "unknow";
|
|
77
77
|
apiSchema = jsonSchema2Swagger(apiSchema[1] ? apiSchema[1] : {}, verb, methodPath, swaggerDocJson);
|
|
78
78
|
}
|
package/package.json
CHANGED