create-cellsweb-rpc-api 1.0.9 → 1.0.11
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/bin/create.js +8 -1
- package/package.json +1 -1
- package/template/scripts/create-function.ts +7 -7
- package/template/scripts/create-middleware.ts +10 -6
- package/template/src/functions/public/hello/constants.ts +2 -2
- package/template/src/middlewares/auth/constants.ts +1 -1
- package/template/src/middlewares/rateLimit/constants.ts +1 -1
package/bin/create.js
CHANGED
|
@@ -130,7 +130,7 @@ async function main() {
|
|
|
130
130
|
"create:middleware": "tsx scripts/create-middleware.ts",
|
|
131
131
|
},
|
|
132
132
|
dependencies: {
|
|
133
|
-
"@cellsweb/rpc-core": "^1.0.
|
|
133
|
+
"@cellsweb/rpc-core": "^1.0.5",
|
|
134
134
|
"@aws-sdk/client-s3": "^3.700.0",
|
|
135
135
|
"@paralleldrive/cuid2": "^2.2.2",
|
|
136
136
|
"@sentry/node": "^8.40.0",
|
|
@@ -210,6 +210,13 @@ async function main() {
|
|
|
210
210
|
const giPath = path.join(targetDir, ".gitignore");
|
|
211
211
|
if (!fs.existsSync(giPath)) fs.writeFileSync(giPath, gitignore);
|
|
212
212
|
|
|
213
|
+
// ── 7.5 Copy .env.example -> .env ────────────────────────────────────────
|
|
214
|
+
const envExamplePath = path.join(targetDir, ".env.example");
|
|
215
|
+
const envPath = path.join(targetDir, ".env");
|
|
216
|
+
if (fs.existsSync(envExamplePath) && !fs.existsSync(envPath)) {
|
|
217
|
+
fs.copyFileSync(envExamplePath, envPath);
|
|
218
|
+
}
|
|
219
|
+
|
|
213
220
|
// ── 8. Install ────────────────────────────────────────────────────────────
|
|
214
221
|
console.log(` ${dim("Installing dependencies with")} ${bold(pm)} ...\n`);
|
|
215
222
|
try {
|
package/package.json
CHANGED
|
@@ -93,9 +93,9 @@ export const inputSchema = Type.Object({
|
|
|
93
93
|
});
|
|
94
94
|
|
|
95
95
|
export const outputSchema = Type.Object({
|
|
96
|
-
fileName: Type.String(),
|
|
97
|
-
fileSize: Type.Number(),
|
|
98
|
-
extraFiles: Type.Number(),
|
|
96
|
+
fileName: Type.String({ description: "Original file name" }),
|
|
97
|
+
fileSize: Type.Number({ description: "Size of uploaded file in bytes" }),
|
|
98
|
+
extraFiles: Type.Number({ description: "Count of additional attached files" }),
|
|
99
99
|
});
|
|
100
100
|
`;
|
|
101
101
|
}
|
|
@@ -108,8 +108,8 @@ export const outputSchema = Type.Object({
|
|
|
108
108
|
* WHAT TO TOUCH:
|
|
109
109
|
* - metadata: Description, public access, tags.
|
|
110
110
|
* - contentType: "application/json" (default).
|
|
111
|
-
* - inputSchema: Define fields expected in req.body.data.
|
|
112
|
-
* - outputSchema: Define structure returned by run().
|
|
111
|
+
* - inputSchema: Define fields expected in req.body.data. Include description in Type properties!
|
|
112
|
+
* - outputSchema: Define structure returned by run(). Include description in Type properties!
|
|
113
113
|
*/
|
|
114
114
|
|
|
115
115
|
import { Type } from "@sinclair/typebox";
|
|
@@ -126,11 +126,11 @@ export const contentType = "application/json" as const;
|
|
|
126
126
|
export const headersSchema = Type.Object({}, { additionalProperties: true });
|
|
127
127
|
|
|
128
128
|
export const inputSchema = Type.Object({
|
|
129
|
-
example: Type.String({ minLength: 1, description: "Example string input" }),
|
|
129
|
+
example: Type.String({ minLength: 1, description: "Example string input parameter" }),
|
|
130
130
|
});
|
|
131
131
|
|
|
132
132
|
export const outputSchema = Type.Object({
|
|
133
|
-
result: Type.String(),
|
|
133
|
+
result: Type.String({ description: "Operation status or execution result message" }),
|
|
134
134
|
});
|
|
135
135
|
`;
|
|
136
136
|
}
|
|
@@ -23,21 +23,25 @@ function tplConstants(name: string): string {
|
|
|
23
23
|
* MIDDLEWARE CONTRACT & METADATA
|
|
24
24
|
*
|
|
25
25
|
* WHAT TO TOUCH:
|
|
26
|
-
* - metadata:
|
|
27
|
-
* - headersSchema: Optional headers this middleware requires/reads.
|
|
28
|
-
* - optionsSchema: Config options passed in function middlewares.ts.
|
|
26
|
+
* - metadata: Human-readable description displayed in /docs.
|
|
27
|
+
* - headersSchema: Optional headers this middleware requires/reads. Include description in Type properties!
|
|
28
|
+
* - optionsSchema: Config options passed in function middlewares.ts. Include description & default in Type properties!
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
31
|
import { Type } from "@sinclair/typebox";
|
|
32
32
|
|
|
33
33
|
export const metadata = {
|
|
34
34
|
name: "${name}",
|
|
35
|
-
description: "
|
|
35
|
+
description: "Enforces security policies or request transformations for ${name}",
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
export const headersSchema = Type.Object({
|
|
38
|
+
export const headersSchema = Type.Object({
|
|
39
|
+
// e.g. "x-${name}-token": Type.String({ description: "Authentication token for ${name}" })
|
|
40
|
+
}, { additionalProperties: true });
|
|
39
41
|
|
|
40
|
-
export const optionsSchema = Type.Object({
|
|
42
|
+
export const optionsSchema = Type.Object({
|
|
43
|
+
// e.g. enabled: Type.Boolean({ default: true, description: "Enable ${name} middleware processing" })
|
|
44
|
+
}, { additionalProperties: false });
|
|
41
45
|
`;
|
|
42
46
|
}
|
|
43
47
|
|
|
@@ -18,9 +18,9 @@ export const contentType = "application/json" as const;
|
|
|
18
18
|
export const headersSchema = Type.Object({}, { additionalProperties: true });
|
|
19
19
|
|
|
20
20
|
export const inputSchema = Type.Object({
|
|
21
|
-
name: Type.String({ minLength: 1, description: "Your name" }),
|
|
21
|
+
name: Type.String({ minLength: 1, description: "Your full name for personalized greeting" }),
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
export const outputSchema = Type.Object({
|
|
25
|
-
greeting: Type.String(),
|
|
25
|
+
greeting: Type.String({ description: "Personalized greeting response message" }),
|
|
26
26
|
});
|
|
@@ -4,7 +4,7 @@ export type UserRole = "user" | "admin" | "staff" | "vendor" | "dev";
|
|
|
4
4
|
|
|
5
5
|
export const metadata = {
|
|
6
6
|
name: "auth",
|
|
7
|
-
description: "Validates bearer token and enforces
|
|
7
|
+
description: "Validates bearer token and enforces role-based access control",
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
export const headersSchema = Type.Object({
|
|
@@ -2,7 +2,7 @@ import { Type } from "@sinclair/typebox";
|
|
|
2
2
|
|
|
3
3
|
export const metadata = {
|
|
4
4
|
name: "rateLimit",
|
|
5
|
-
description: "Enforces per-function rate
|
|
5
|
+
description: "Enforces per-function rate limits keyed on IP + namespace + functionName",
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
export const optionsSchema = Type.Object({
|