@jayfong/x-utils 1.0.0-202408101439 → 1.0.0-202408290922

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.
@@ -31,6 +31,7 @@ __export(http_server_exports, {
31
31
  XHttpServer: () => XHttpServer
32
32
  });
33
33
  module.exports = __toCommonJS(http_server_exports);
34
+ var import_cookie = __toESM(require("@fastify/cookie"), 1);
34
35
  var import_cors = __toESM(require("@fastify/cors"), 1);
35
36
  var import_fastify = __toESM(require("fastify"), 1);
36
37
  class XHttpServer {
@@ -42,8 +43,14 @@ class XHttpServer {
42
43
  logger: true
43
44
  });
44
45
  await fastify.register(import_cors.default);
46
+ await fastify.register(import_cookie.default, {
47
+ secret: "cm0elm25o000094rlctgk6a7w"
48
+ });
45
49
  Object.keys(this.options.handlers).forEach((name) => {
46
- fastify.post(`/${name}`, (req) => this.options.handlers[name](req.body));
50
+ fastify.post(
51
+ `/${name}`,
52
+ (req, rep) => this.options.handlers[name](req.body, req, rep)
53
+ );
47
54
  });
48
55
  await fastify.listen({
49
56
  host: "0.0.0.0",
package/http_server.d.ts CHANGED
@@ -1,6 +1,7 @@
1
+ import { FastifyReply, FastifyRequest } from 'fastify';
1
2
  export type XHttpServerOptions = {
2
3
  port: number;
3
- handlers: Record<string, (data: any) => any>;
4
+ handlers: Record<string, (data: any, req: FastifyRequest, rep: FastifyReply) => any>;
4
5
  };
5
6
  export declare class XHttpServer {
6
7
  private options;
package/http_server.js CHANGED
@@ -1,3 +1,4 @@
1
+ import cookie from "@fastify/cookie";
1
2
  import cors from "@fastify/cors";
2
3
  import Fastify from "fastify";
3
4
  class XHttpServer {
@@ -9,8 +10,14 @@ class XHttpServer {
9
10
  logger: true
10
11
  });
11
12
  await fastify.register(cors);
13
+ await fastify.register(cookie, {
14
+ secret: "cm0elm25o000094rlctgk6a7w"
15
+ });
12
16
  Object.keys(this.options.handlers).forEach((name) => {
13
- fastify.post(`/${name}`, (req) => this.options.handlers[name](req.body));
17
+ fastify.post(
18
+ `/${name}`,
19
+ (req, rep) => this.options.handlers[name](req.body, req, rep)
20
+ );
14
21
  });
15
22
  await fastify.listen({
16
23
  host: "0.0.0.0",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jayfong/x-utils",
3
3
  "description": "123456",
4
- "version": "1.0.0-202408101439",
4
+ "version": "1.0.0-202408290922",
5
5
  "type": "module",
6
6
  "dependencies": {
7
7
  "vtils": "^4.115.0",
@@ -22,6 +22,7 @@
22
22
  "@types/probe-image-size": "^7.2.5",
23
23
  "docx": "^8.5.0",
24
24
  "image-dimensions": "^2.3.0",
25
+ "@fastify/cookie": "^9.4.0",
25
26
  "@fastify/cors": "^9.0.1",
26
27
  "fastify": "^4.26.0",
27
28
  "nzh": "^1.0.12",