@yinuo-ngm/server 1.0.4 → 1.0.6

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.
Files changed (58) hide show
  1. package/lib/app.js +2 -0
  2. package/lib/plugins/api-client.plugin.d.ts +3 -0
  3. package/lib/plugins/api-client.plugin.js +56 -0
  4. package/lib/plugins/core.plugin.d.ts +0 -6
  5. package/lib/plugins/error-handler.plugin.js +1 -0
  6. package/lib/plugins/routes.plugin.js +2 -10
  7. package/lib/routes/api-client/collection.routes.d.ts +2 -0
  8. package/lib/routes/api-client/collection.routes.js +78 -0
  9. package/lib/routes/api-client/env.routes.d.ts +2 -0
  10. package/lib/routes/api-client/env.routes.js +44 -0
  11. package/lib/routes/api-client/history.routes.d.ts +2 -0
  12. package/lib/routes/api-client/history.routes.js +36 -0
  13. package/lib/routes/api-client/index.d.ts +5 -0
  14. package/lib/routes/api-client/index.js +21 -0
  15. package/lib/routes/api-client/request.routes.d.ts +2 -0
  16. package/lib/routes/api-client/request.routes.js +62 -0
  17. package/lib/routes/api-client/send.routes.d.ts +2 -0
  18. package/lib/routes/api-client/send.routes.js +22 -0
  19. package/lib/routes/index.d.ts +2 -10
  20. package/lib/routes/index.js +18 -10
  21. package/package.json +38 -37
  22. package/www/browser/{chunk-X7DKZB43.js → chunk-2PBA7FNM.js} +2 -2
  23. package/www/browser/chunk-35COW2FA.js +1 -0
  24. package/www/browser/{chunk-IGJYBE5M.js → chunk-3N7T4ZJF.js} +1 -1
  25. package/www/browser/{chunk-6ZXMOHQD.js → chunk-5IUYSJVD.js} +1 -1
  26. package/www/browser/{chunk-CF64VPDQ.js → chunk-5MHC25IS.js} +1 -1
  27. package/www/browser/chunk-7U5ZOE34.js +1 -0
  28. package/www/browser/{chunk-GKOCPXFS.js → chunk-A2SBXP7A.js} +1 -1
  29. package/www/browser/chunk-CJISJEP3.js +1 -0
  30. package/www/browser/chunk-CPA2B3DD.js +1 -0
  31. package/www/browser/{chunk-TN5O5PXP.js → chunk-DUC7XBYN.js} +1 -1
  32. package/www/browser/{chunk-UIDFNBD4.js → chunk-DV7BEQJD.js} +1 -1
  33. package/www/browser/{chunk-ZGEEPU7F.js → chunk-EAYGWAZB.js} +1 -1
  34. package/www/browser/{chunk-GNFBCMLE.js → chunk-EC33AXSR.js} +1 -1
  35. package/www/browser/{chunk-K6ZRTM2Q.js → chunk-FL6BUQ4M.js} +1 -1
  36. package/www/browser/{chunk-A6CKMRBS.js → chunk-FPDGZ3ZC.js} +1 -1
  37. package/www/browser/{chunk-ECWYTW7Q.js → chunk-IXHH6ENJ.js} +1 -1
  38. package/www/browser/chunk-KKLLU6U7.js +3 -0
  39. package/www/browser/chunk-MN4WB67T.js +1 -0
  40. package/www/browser/{chunk-ZJKBRM7K.js → chunk-POZS3PD3.js} +1 -1
  41. package/www/browser/{chunk-J43J3F2V.js → chunk-PTMJ422K.js} +6 -6
  42. package/www/browser/{chunk-HT3VTKOZ.js → chunk-PYGKDDJK.js} +1 -1
  43. package/www/browser/{chunk-34QRY4VA.js → chunk-ROB7EMN5.js} +13 -13
  44. package/www/browser/chunk-TLFV3T3W.js +1 -0
  45. package/www/browser/chunk-U7FBNFSB.js +1 -0
  46. package/www/browser/chunk-UWKUE7CZ.js +11 -0
  47. package/www/browser/{chunk-R7E5ZK2M.js → chunk-V6LX42JA.js} +1 -1
  48. package/www/browser/dark.css +1 -1
  49. package/www/browser/default.css +1 -1
  50. package/www/browser/index.html +1 -1
  51. package/www/browser/main-IIW5QQA5.js +29 -0
  52. package/www/browser/chunk-5RKAWOOJ.js +0 -1
  53. package/www/browser/chunk-ACZLOZZH.js +0 -1
  54. package/www/browser/chunk-C3KAVW4L.js +0 -1
  55. package/www/browser/chunk-CKWTUTVS.js +0 -1
  56. package/www/browser/chunk-QC33YQSO.js +0 -11
  57. package/www/browser/chunk-U76AMP2X.js +0 -3
  58. package/www/browser/main-F763G7F7.js +0 -29
package/lib/app.js CHANGED
@@ -12,6 +12,7 @@ const routes_plugin_1 = __importDefault(require("./plugins/routes.plugin"));
12
12
  const static_plugin_1 = __importDefault(require("./plugins/static.plugin"));
13
13
  const success_handle_plugin_1 = __importDefault(require("./plugins/success-handle.plugin"));
14
14
  const ws_plugin_1 = __importDefault(require("./plugins/ws/ws.plugin"));
15
+ const api_client_plugin_1 = __importDefault(require("./plugins/api-client.plugin"));
15
16
  function normalizeLogLevel(v) {
16
17
  const lv = (v ?? "").toLowerCase().trim();
17
18
  if (!lv)
@@ -55,6 +56,7 @@ async function createServer() {
55
56
  await fastify.register(success_handle_plugin_1.default);
56
57
  await fastify.register(core_plugin_1.default);
57
58
  await fastify.register(ws_plugin_1.default);
59
+ await fastify.register(api_client_plugin_1.default);
58
60
  await fastify.register(routes_plugin_1.default);
59
61
  await fastify.register(static_plugin_1.default);
60
62
  fastify.addHook('onClose', async () => {
@@ -0,0 +1,3 @@
1
+ import type { FastifyInstance } from "fastify";
2
+ declare const _default: (fastify: FastifyInstance) => Promise<void>;
3
+ export default _default;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ const api_1 = require("@yinuo-ngm/api");
40
+ const fastify_plugin_1 = __importDefault(require("fastify-plugin"));
41
+ const path = __importStar(require("path"));
42
+ const env_1 = require("../env");
43
+ const json_collection_repo_1 = require("@yinuo-ngm/api/src/infra/storage/json/json-collection-repo");
44
+ exports.default = (0, fastify_plugin_1.default)(async function apiClientPlugin(fastify) {
45
+ const rootDir = path.join(env_1.env.dataDir, "api");
46
+ const repo = new api_1.JsonRequestRepo({ rootDir });
47
+ const envRepo = new api_1.JsonEnvRepo({ rootDir });
48
+ const historyRepo = new api_1.JsonHistoryRepo({ rootDir });
49
+ const collectionRepo = new json_collection_repo_1.JsonCollectionRepo({ rootDir });
50
+ const http = new api_1.NodeHttpClient();
51
+ const resolver = new api_1.VariableResolver();
52
+ const sendService = new api_1.ApiSendService(repo, envRepo, historyRepo, http, resolver);
53
+ const apiClient = new api_1.ApiClient(repo, envRepo, historyRepo, collectionRepo, sendService);
54
+ fastify.decorate("api", apiClient);
55
+ fastify.log.info("[api] api client initialized");
56
+ });
@@ -1,9 +1,3 @@
1
1
  import type { FastifyInstance } from "fastify";
2
- import { type CoreApp } from "@yinuo-ngm/core";
3
- declare module "fastify" {
4
- interface FastifyInstance {
5
- core: CoreApp;
6
- }
7
- }
8
2
  declare const _default: (fastify: FastifyInstance) => Promise<void>;
9
3
  export default _default;
@@ -103,6 +103,7 @@ exports.errorHandlerPlugin = (0, fastify_plugin_1.default)(async (app) => {
103
103
  .status(400)
104
104
  .send(buildErrorBody(requestId, "VALIDATION_ERROR", "参数不合法", err.validation));
105
105
  }
106
+ console.log('err', err);
106
107
  req.log.error({ err, requestId }, "Unhandled error");
107
108
  return reply.status(500).send(buildErrorBody(requestId, "INTERNAL_ERROR", "服务异常,请稍后重试"));
108
109
  });
@@ -4,15 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const fastify_plugin_1 = __importDefault(require("fastify-plugin"));
7
- const routes_1 = require("../routes");
7
+ const routes_1 = __importDefault(require("../routes"));
8
8
  exports.default = (0, fastify_plugin_1.default)(async function routesPlugin(fastify) {
9
- await fastify.register(routes_1.systemRoutes);
10
- await fastify.register(routes_1.taskRoutes, { prefix: '/api/tasks' });
11
- await fastify.register(routes_1.projectRoutes, { prefix: '/api/projects' });
12
- await fastify.register(routes_1.depsRoutes, { prefix: '/api/deps' });
13
- await fastify.register(routes_1.fsRoutes, { prefix: '/api/fs' });
14
- await fastify.register(routes_1.configRoutes, { prefix: '/api/config' });
15
- await fastify.register(routes_1.dashboardRoutes, { prefix: '/api/dashboard' });
16
- await fastify.register(routes_1.rssRoutes, { prefix: '/api/rss' });
17
- await fastify.register(routes_1.spriteRoutes, { prefix: '/api/sprite' });
9
+ await (0, routes_1.default)(fastify);
18
10
  });
@@ -0,0 +1,2 @@
1
+ import type { FastifyInstance } from "fastify";
2
+ export declare function apiClientCollectionsRoutes(fastify: FastifyInstance): Promise<void>;
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.apiClientCollectionsRoutes = apiClientCollectionsRoutes;
4
+ const api_1 = require("@yinuo-ngm/api");
5
+ function assertProjectScope(scope, projectId) {
6
+ if (scope === "project" && !projectId)
7
+ throw new Error("projectId is required when scope=project");
8
+ }
9
+ function now() { return Date.now(); }
10
+ async function apiClientCollectionsRoutes(fastify) {
11
+ const api = fastify.api;
12
+ fastify.get("/", async (req) => {
13
+ const q = req.query;
14
+ const scope = (q.scope ?? "project");
15
+ assertProjectScope(scope, q.projectId);
16
+ const items = await api.listCollections(scope, q.projectId);
17
+ return items.sort((a, b) => (a.parentId ?? "").localeCompare(b.parentId ?? "") || a.order - b.order || a.name.localeCompare(b.name));
18
+ });
19
+ fastify.post("/", async (req) => {
20
+ const body = req.body;
21
+ const scope = (body.scope ?? "project");
22
+ assertProjectScope(scope, body.projectId);
23
+ const ts = now();
24
+ const entity = {
25
+ id: (0, api_1.newId)("col"),
26
+ name: String(body.name ?? "").trim() || "New Collection",
27
+ kind: body.kind ?? "collection",
28
+ scope,
29
+ nodes: [],
30
+ projectId: scope === "project" ? body.projectId : undefined,
31
+ parentId: body.parentId ?? null,
32
+ order: body.order ?? ts,
33
+ createdAt: ts,
34
+ updatedAt: ts,
35
+ };
36
+ await api.saveCollection(entity, scope, body.projectId);
37
+ return entity;
38
+ });
39
+ fastify.post("/:id", async (req, reply) => {
40
+ const params = req.params;
41
+ const q = req.query;
42
+ const body = req.body;
43
+ const scope = (q.scope ?? "project");
44
+ assertProjectScope(scope, q.projectId);
45
+ const old = await api.getCollection(params.id, scope, q.projectId);
46
+ if (!old) {
47
+ return reply.code(404).send({ code: "COLLECTION_NOT_FOUND", message: `collection not found: ${params.id}` });
48
+ }
49
+ const ts = now();
50
+ const next = {
51
+ ...old,
52
+ name: body.name != null ? String(body.name).trim() || old.name : old.name,
53
+ parentId: body.parentId !== undefined ? body.parentId : old.parentId,
54
+ order: body.order !== undefined ? Number(body.order) : old.order,
55
+ updatedAt: ts,
56
+ };
57
+ await api.saveCollection(next, scope, q.projectId);
58
+ return next;
59
+ });
60
+ fastify.delete("/:id", async (req, reply) => {
61
+ const params = req.params;
62
+ const q = req.query;
63
+ const scope = (q.scope ?? "project");
64
+ assertProjectScope(scope, q.projectId);
65
+ const allCols = await api.listCollections(scope, q.projectId);
66
+ const hasChildCol = allCols.some(c => (c.parentId ?? null) === params.id);
67
+ if (hasChildCol) {
68
+ return reply.code(409).send({ code: "COLLECTION_NOT_EMPTY", message: "collection has child collections" });
69
+ }
70
+ const reqs = await api.listRequests(scope, q.projectId);
71
+ const hasReq = reqs.some((r) => (r.collectionId ?? null) === params.id);
72
+ if (hasReq) {
73
+ return reply.code(409).send({ code: "COLLECTION_NOT_EMPTY", message: "collection has requests" });
74
+ }
75
+ await api.deleteCollection(params.id, scope, q.projectId);
76
+ return { ok: true };
77
+ });
78
+ }
@@ -0,0 +1,2 @@
1
+ import type { FastifyInstance } from "fastify";
2
+ export declare function apiClientEnvsRoutes(fastify: FastifyInstance): Promise<void>;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.apiClientEnvsRoutes = apiClientEnvsRoutes;
4
+ function parseScope(q) {
5
+ const scope = (q?.scope ?? "project");
6
+ const projectId = q?.projectId;
7
+ if (scope === "project" && !projectId) {
8
+ throw new Error("projectId is required when scope=project");
9
+ }
10
+ return { scope, projectId };
11
+ }
12
+ async function apiClientEnvsRoutes(fastify) {
13
+ const env = fastify.api;
14
+ fastify.get("/", async (req) => {
15
+ const { scope, projectId } = parseScope(req.query);
16
+ return await env.listEnvs(scope, projectId);
17
+ });
18
+ fastify.get("/:id", async (req, reply) => {
19
+ const { scope, projectId } = parseScope(req.query);
20
+ const id = req.params.id;
21
+ const item = await env.getEnv(id, scope, projectId);
22
+ if (!item) {
23
+ reply.code(404);
24
+ return { message: "env not found", id };
25
+ }
26
+ return item;
27
+ });
28
+ fastify.post("/", async (req) => {
29
+ const body = req.body;
30
+ const scope = body?.scope ?? "project";
31
+ if (scope === "project" && !body.projectId)
32
+ throw new Error("projectId is required when scope=project");
33
+ if (!body?.env?.id)
34
+ throw new Error("env.id is required");
35
+ await env.saveEnv(body.env, scope, body.projectId);
36
+ return { id: body.env.id };
37
+ });
38
+ fastify.delete("/:id", async (req) => {
39
+ const { scope, projectId } = parseScope(req.query);
40
+ const id = req.params.id;
41
+ await env.deleteEnv(id, scope, projectId);
42
+ return { id };
43
+ });
44
+ }
@@ -0,0 +1,2 @@
1
+ import type { FastifyInstance } from "fastify";
2
+ export declare function apiClientHistoryRoutes(fastify: FastifyInstance): Promise<void>;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.apiClientHistoryRoutes = apiClientHistoryRoutes;
4
+ function parseScope(q) {
5
+ const scope = (q?.scope ?? "project");
6
+ const projectId = q?.projectId;
7
+ if (scope === "project" && !projectId)
8
+ throw new Error("projectId is required when scope=project");
9
+ return { scope, projectId };
10
+ }
11
+ function parseNum(v, fallback) {
12
+ const n = Number(v);
13
+ return Number.isFinite(n) ? n : fallback;
14
+ }
15
+ async function apiClientHistoryRoutes(fastify) {
16
+ const api = fastify.api;
17
+ fastify.get("/", async (req) => {
18
+ const { scope, projectId } = parseScope(req.query);
19
+ const limit = parseNum(req.query?.limit, 50);
20
+ const offset = parseNum(req.query?.offset, 0);
21
+ return await api.listHistory({ scope, projectId, limit, offset });
22
+ });
23
+ fastify.post("/purge", async (req) => {
24
+ const body = req.body;
25
+ const scope = body?.scope ?? "project";
26
+ if (scope === "project" && !body.projectId)
27
+ throw new Error("projectId is required when scope=project");
28
+ const removed = await api.purgeHistory({
29
+ scope,
30
+ projectId: body.projectId,
31
+ olderThan: body.olderThan,
32
+ maxCount: body.maxCount,
33
+ });
34
+ return { removed };
35
+ });
36
+ }
@@ -0,0 +1,5 @@
1
+ export * from './env.routes';
2
+ export * from './request.routes';
3
+ export * from './history.routes';
4
+ export * from './send.routes';
5
+ export * from './collection.routes';
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./env.routes"), exports);
18
+ __exportStar(require("./request.routes"), exports);
19
+ __exportStar(require("./history.routes"), exports);
20
+ __exportStar(require("./send.routes"), exports);
21
+ __exportStar(require("./collection.routes"), exports);
@@ -0,0 +1,2 @@
1
+ import type { FastifyInstance } from "fastify";
2
+ export declare function apiClientRequestsRoutes(fastify: FastifyInstance): Promise<void>;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.apiClientRequestsRoutes = apiClientRequestsRoutes;
4
+ function parseScope(q) {
5
+ const scope = (q?.scope ?? "project");
6
+ const projectId = q?.projectId;
7
+ if (scope === "project" && !projectId) {
8
+ throw new Error("projectId is required when scope=project");
9
+ }
10
+ return { scope, projectId };
11
+ }
12
+ async function apiClientRequestsRoutes(fastify) {
13
+ const api = fastify.api;
14
+ fastify.get("/", async (req) => {
15
+ const { scope, projectId } = parseScope(req.query);
16
+ const items = await api.listRequests(scope, projectId);
17
+ return items;
18
+ });
19
+ fastify.get("/:id", async (req, reply) => {
20
+ const { scope, projectId } = parseScope(req.query);
21
+ const id = req.params.id;
22
+ const item = await api.getRequest(id, scope, projectId);
23
+ if (!item) {
24
+ reply.code(404);
25
+ return { message: "request not found", id };
26
+ }
27
+ return item;
28
+ });
29
+ fastify.post("/", async (req) => {
30
+ const body = req.body;
31
+ const scope = body?.scope ?? "project";
32
+ if (scope === "project" && !body.projectId)
33
+ throw new Error("projectId is required when scope=project");
34
+ if (!body?.request?.id)
35
+ throw new Error("request.id is required");
36
+ await api.saveRequest(body.request, scope, body.projectId);
37
+ return { id: body.request.id };
38
+ });
39
+ fastify.post("/update", async (req) => {
40
+ const body = req.body;
41
+ const scope = body?.scope ?? "project";
42
+ if (scope === "project" && !body.projectId)
43
+ throw new Error("projectId is required when scope=project");
44
+ if (!body?.request?.id)
45
+ throw new Error("request.id is required");
46
+ const old = await api.getRequest(body.request.id, scope, body.projectId);
47
+ if (!old)
48
+ throw new Error("request not found: " + body.request.id);
49
+ const updated = {
50
+ ...old,
51
+ ...body.request,
52
+ };
53
+ await api.saveRequest(updated, scope, body.projectId);
54
+ return { id: body.request.id };
55
+ });
56
+ fastify.delete("/:id", async (req) => {
57
+ const { scope, projectId } = parseScope(req.query);
58
+ const id = req.params.id;
59
+ await api.deleteRequest(id, scope, projectId);
60
+ return { id };
61
+ });
62
+ }
@@ -0,0 +1,2 @@
1
+ import type { FastifyInstance } from "fastify";
2
+ export declare function apiClientSendRoutes(fastify: FastifyInstance): Promise<void>;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.apiClientSendRoutes = apiClientSendRoutes;
4
+ async function apiClientSendRoutes(fastify) {
5
+ const api = fastify.api;
6
+ fastify.post("/", async (req) => {
7
+ const body = req.body;
8
+ const scope = body.scope ?? "project";
9
+ if (scope === "project" && !body.projectId)
10
+ throw new Error("projectId is required when scope=project");
11
+ if (!body.request && !body.requestId)
12
+ throw new Error("request or requestId is required");
13
+ return await api.send({
14
+ scope,
15
+ projectId: body.projectId,
16
+ requestId: body.requestId,
17
+ request: body.request,
18
+ envId: body.envId,
19
+ projectRoot: body.projectRoot,
20
+ });
21
+ });
22
+ }
@@ -1,10 +1,2 @@
1
- import configRoutes from './config.routes';
2
- import dashboardRoutes from './dashboard.routes';
3
- import depsRoutes from './deps.route';
4
- import fsRoutes from './fs.routes';
5
- import projectRoutes from './project.routes';
6
- import rssRoutes from './rss.routes';
7
- import { spriteRoutes } from './sprite.routes';
8
- import systemRoutes from './system.routes';
9
- import taskRoutes from './task.routes';
10
- export { configRoutes, depsRoutes, fsRoutes, projectRoutes, systemRoutes, taskRoutes, dashboardRoutes, rssRoutes, spriteRoutes };
1
+ import { FastifyInstance } from 'fastify';
2
+ export default function routes(fastify: FastifyInstance): Promise<void>;
@@ -3,22 +3,30 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.spriteRoutes = exports.rssRoutes = exports.dashboardRoutes = exports.taskRoutes = exports.systemRoutes = exports.projectRoutes = exports.fsRoutes = exports.depsRoutes = exports.configRoutes = void 0;
6
+ exports.default = routes;
7
7
  const config_routes_1 = __importDefault(require("./config.routes"));
8
- exports.configRoutes = config_routes_1.default;
9
8
  const dashboard_routes_1 = __importDefault(require("./dashboard.routes"));
10
- exports.dashboardRoutes = dashboard_routes_1.default;
11
9
  const deps_route_1 = __importDefault(require("./deps.route"));
12
- exports.depsRoutes = deps_route_1.default;
13
10
  const fs_routes_1 = __importDefault(require("./fs.routes"));
14
- exports.fsRoutes = fs_routes_1.default;
15
11
  const project_routes_1 = __importDefault(require("./project.routes"));
16
- exports.projectRoutes = project_routes_1.default;
17
12
  const rss_routes_1 = __importDefault(require("./rss.routes"));
18
- exports.rssRoutes = rss_routes_1.default;
19
13
  const sprite_routes_1 = require("./sprite.routes");
20
- Object.defineProperty(exports, "spriteRoutes", { enumerable: true, get: function () { return sprite_routes_1.spriteRoutes; } });
21
14
  const system_routes_1 = __importDefault(require("./system.routes"));
22
- exports.systemRoutes = system_routes_1.default;
23
15
  const task_routes_1 = __importDefault(require("./task.routes"));
24
- exports.taskRoutes = task_routes_1.default;
16
+ const api_client_1 = require("./api-client");
17
+ async function routes(fastify) {
18
+ await fastify.register(system_routes_1.default);
19
+ await fastify.register(task_routes_1.default, { prefix: '/api/tasks' });
20
+ await fastify.register(project_routes_1.default, { prefix: '/api/projects' });
21
+ await fastify.register(deps_route_1.default, { prefix: '/api/deps' });
22
+ await fastify.register(fs_routes_1.default, { prefix: '/api/fs' });
23
+ await fastify.register(config_routes_1.default, { prefix: '/api/config' });
24
+ await fastify.register(dashboard_routes_1.default, { prefix: '/api/dashboard' });
25
+ await fastify.register(rss_routes_1.default, { prefix: '/api/rss' });
26
+ await fastify.register(sprite_routes_1.spriteRoutes, { prefix: '/api/sprite' });
27
+ await fastify.register(api_client_1.apiClientEnvsRoutes, { prefix: '/api/client/envs' });
28
+ await fastify.register(api_client_1.apiClientRequestsRoutes, { prefix: '/api/client/requests' });
29
+ await fastify.register(api_client_1.apiClientHistoryRoutes, { prefix: '/api/client/history' });
30
+ await fastify.register(api_client_1.apiClientSendRoutes, { prefix: '/api/client/send' });
31
+ await fastify.register(api_client_1.apiClientCollectionsRoutes, { prefix: '/api/client/collections' });
32
+ }
package/package.json CHANGED
@@ -1,37 +1,38 @@
1
- {
2
- "name": "@yinuo-ngm/server",
3
- "version": "1.0.4",
4
- "description": "",
5
- "main": "lib/index.js",
6
- "keywords": [],
7
- "author": "ZhangJing",
8
- "license": "ISC",
9
- "types": "lib/index.d.ts",
10
- "files": [
11
- "lib",
12
- "www"
13
- ],
14
- "publishConfig": {
15
- "access": "public"
16
- },
17
- "scripts": {
18
- "dev": "tsx watch src/index.ts",
19
- "build": "tsc -p tsconfig.json",
20
- "start": "node lib/index.js"
21
- },
22
- "dependencies": {
23
- "@fastify/static": "^9.0.0",
24
- "@fastify/websocket": "^11.2.0",
25
- "@yinuo-ngm/core": "^0.1.3",
26
- "@yinuo-ngm/sprite": "^0.1.1",
27
- "fastify": "^5.6.2",
28
- "fastify-plugin": "^5.1.0",
29
- "launch-editor": "^2.12.0",
30
- "pino-pretty": "^13.1.3",
31
- "rss-parser": "^3.13.0"
32
- },
33
- "devDependencies": {
34
- "tsx": "^4.21.0"
35
- },
36
- "gitHead": "ebfaab3c1457d597f904b5d121292f5a84486609"
37
- }
1
+ {
2
+ "name": "@yinuo-ngm/server",
3
+ "version": "1.0.6",
4
+ "description": "a server package for Yinuo NG Manager",
5
+ "author": "ZhangJing <892295834@qq.com>",
6
+ "license": "ISC",
7
+ "main": "lib/index.js",
8
+ "types": "lib/index.d.ts",
9
+ "keywords": [],
10
+ "files": [
11
+ "lib",
12
+ "www"
13
+ ],
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "scripts": {
18
+ "dev": "tsx watch src/index.ts",
19
+ "build": "tsc -p tsconfig.json",
20
+ "start": "node lib/index.js"
21
+ },
22
+ "dependencies": {
23
+ "@fastify/static": "^9.0.0",
24
+ "@fastify/websocket": "^11.2.0",
25
+ "@yinuo-ngm/api": "^0.1.1",
26
+ "@yinuo-ngm/core": "^0.1.4",
27
+ "@yinuo-ngm/sprite": "^0.1.2",
28
+ "fastify": "^5.6.2",
29
+ "fastify-plugin": "^5.1.0",
30
+ "launch-editor": "^2.12.0",
31
+ "pino-pretty": "^13.1.3",
32
+ "rss-parser": "^3.13.0"
33
+ },
34
+ "devDependencies": {
35
+ "tsx": "^4.21.0"
36
+ },
37
+ "gitHead": "ebfaab3c1457d597f904b5d121292f5a84486609"
38
+ }