@kanjijs/cli 0.2.0-beta.19 → 0.2.0-beta.20
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/index.js +8 -6
- package/package.json +2 -2
- package/templates/starter/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -20214,19 +20214,19 @@ ${serviceMethods}
|
|
|
20214
20214
|
`;
|
|
20215
20215
|
await import_fs_extra.default.writeFile(path2.join(targetDir, `${lowerName}.service.ts`), serviceTpl);
|
|
20216
20216
|
console.log(import_picocolors2.default.white(`CREATE ${lowerName}.service.ts`));
|
|
20217
|
-
const controllerTpl = `import { Controller, Get, Post, Patch, Delete } from "@kanjijs/core";
|
|
20217
|
+
const controllerTpl = `import { Controller, Get, Post, Patch, Delete, Contract } from "@kanjijs/core";
|
|
20218
20218
|
import { type Context } from "hono";
|
|
20219
20219
|
import { ${className}Service } from "./${lowerName}.service";
|
|
20220
|
-
import { Contract } from "@kanjijs/contracts";
|
|
20220
|
+
import { Contract as ApiContract } from "@kanjijs/contracts";
|
|
20221
20221
|
import { z } from "zod";
|
|
20222
20222
|
|
|
20223
|
-
const Create${className}Contract =
|
|
20223
|
+
const Create${className}Contract = ApiContract.json({
|
|
20224
20224
|
body: z.object({
|
|
20225
20225
|
name: z.string(),
|
|
20226
20226
|
})
|
|
20227
20227
|
});
|
|
20228
20228
|
|
|
20229
|
-
const Update${className}Contract =
|
|
20229
|
+
const Update${className}Contract = ApiContract.json({
|
|
20230
20230
|
body: z.object({
|
|
20231
20231
|
name: z.string().optional(),
|
|
20232
20232
|
})
|
|
@@ -20247,14 +20247,16 @@ export class ${className}Controller {
|
|
|
20247
20247
|
return c.json(this.service.findOne(id));
|
|
20248
20248
|
}
|
|
20249
20249
|
|
|
20250
|
-
@Post("/"
|
|
20250
|
+
@Post("/")
|
|
20251
|
+
@Contract(Create${className}Contract)
|
|
20251
20252
|
create(c: Context) {
|
|
20252
20253
|
// Infer keys from contract (Contract-first)
|
|
20253
20254
|
const body = c.get("kanji.validated.body");
|
|
20254
20255
|
return c.json(this.service.create(body));
|
|
20255
20256
|
}
|
|
20256
20257
|
|
|
20257
|
-
@Patch("/:id"
|
|
20258
|
+
@Patch("/:id")
|
|
20259
|
+
@Contract(Update${className}Contract)
|
|
20258
20260
|
update(c: Context) {
|
|
20259
20261
|
const id = Number(c.req.param("id"));
|
|
20260
20262
|
const body = c.get("kanji.validated.body");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kanjijs/cli",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.20",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"kanji": "./dist/index.js"
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"fs-extra": "^11.3.3",
|
|
22
22
|
"picocolors": "^1.1.1",
|
|
23
23
|
"openapi-typescript-codegen": "^0.25.0",
|
|
24
|
-
"@kanjijs/openapi": "^0.2.0-beta.
|
|
24
|
+
"@kanjijs/openapi": "^0.2.0-beta.20"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/fs-extra": "^11.0.4"
|
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
"start": "bun run src/main.ts"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@kanjijs/core": "^0.2.0-beta.
|
|
11
|
-
"@kanjijs/platform-bun": "^0.2.0-beta.
|
|
12
|
-
"@kanjijs/platform-hono": "^0.2.0-beta.
|
|
13
|
-
"@kanjijs/auth": "^0.2.0-beta.
|
|
14
|
-
"@kanjijs/logger": "^0.2.0-beta.
|
|
15
|
-
"@kanjijs/throttler": "^0.2.0-beta.
|
|
10
|
+
"@kanjijs/core": "^0.2.0-beta.20",
|
|
11
|
+
"@kanjijs/platform-bun": "^0.2.0-beta.20",
|
|
12
|
+
"@kanjijs/platform-hono": "^0.2.0-beta.20",
|
|
13
|
+
"@kanjijs/auth": "^0.2.0-beta.20",
|
|
14
|
+
"@kanjijs/logger": "^0.2.0-beta.20",
|
|
15
|
+
"@kanjijs/throttler": "^0.2.0-beta.20",
|
|
16
16
|
"hono": "^4.0.0",
|
|
17
17
|
"reflect-metadata": "^0.2.0",
|
|
18
18
|
"zod": "^3.0.0"
|