befly-api 3.25.1 → 3.25.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/apis/_apis.js ADDED
@@ -0,0 +1,4 @@
1
+ export function buildHelloMessage(name) {
2
+ const safeName = typeof name === "string" && name ? name : "Befly";
3
+ return `Hello, ${safeName}!`;
4
+ }
package/apis/test/hi.js CHANGED
@@ -1,20 +1,22 @@
1
- import { buildHelloMessage } from "../../utils/util.js";
1
+ import { buildHelloMessage } from "../_apis.js";
2
2
 
3
3
  export default {
4
4
  name: "测试接口",
5
5
  method: "POST",
6
6
  body: "none",
7
7
  auth: false,
8
- fields: {},
9
- required: [],
10
- handler: async (befly, ctx) => {
11
- if (!ctx.body) {
12
- ctx.body = {};
8
+ fields: {
9
+ name: {
10
+ name: "名称",
11
+ input: "string",
12
+ max: 100
13
13
  }
14
- const name = ctx.input && ctx.input.name ? String(ctx.input.name) : "";
15
- ctx.body.msg = buildHelloMessage(name);
16
- ctx.body.data = {
14
+ },
15
+ required: [],
16
+ handler: (befly, ctx) => {
17
+ return befly.tool.Yes("操作成功", {
18
+ msg: buildHelloMessage(ctx.body.name),
17
19
  timestamp: Date.now()
18
- };
20
+ });
19
21
  }
20
22
  };
package/jsconfig.json CHANGED
@@ -19,7 +19,10 @@
19
19
  "forceConsistentCasingInFileNames": true,
20
20
  "resolveJsonModule": true,
21
21
  "allowImportingTsExtensions": false,
22
- "allowJs": true
22
+ "allowJs": true,
23
+ "paths": {
24
+ "#root/*": ["./*"]
25
+ }
23
26
  },
24
27
  "include": ["**/*.js"],
25
28
  "exclude": ["node_modules", "data", "logs", "tests"]
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "befly-api",
3
- "version": "3.25.1",
4
- "gitHead": "5ec9cbeeba3aed39c52f227785c729eab34d7db5",
3
+ "version": "3.25.3",
4
+ "gitHead": "c14b3572a265a384993be0d375d023f82cdd9ffd",
5
5
  "private": false,
6
6
  "description": "Befly 3.0 API Template",
7
7
  "files": [
@@ -14,9 +14,13 @@
14
14
  "jsconfig.json",
15
15
  "apis/",
16
16
  "configs/",
17
+ "utils/",
17
18
  "tables/"
18
19
  ],
19
20
  "type": "module",
21
+ "imports": {
22
+ "#root/*": "./*"
23
+ },
20
24
  "publishConfig": {
21
25
  "access": "public",
22
26
  "registry": "https://registry.npmjs.org"
@@ -28,7 +32,7 @@
28
32
  "db": "bun run scripts/syncDb.js"
29
33
  },
30
34
  "dependencies": {
31
- "befly": "^3.24.1"
35
+ "befly": "^3.24.3"
32
36
  },
33
37
  "engines": {
34
38
  "bun": ">=1.3.0"