@niyamulahsan/create-deskapp 1.2.4 → 1.2.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 (104) hide show
  1. package/package.json +16 -16
  2. package/template/.env.example +20 -13
  3. package/template/AGENTS.md +699 -0
  4. package/template/package.json +3 -0
  5. package/template/src/config/app.ts +26 -24
  6. package/template/src/config/winsetup.ts +93 -91
  7. package/template/src/core/api/binding-error.ts +57 -0
  8. package/template/src/core/api/bindings.generated.ts +2 -0
  9. package/template/src/core/api/generate.manifest.ts +84 -80
  10. package/template/src/core/api/registry.ts +58 -48
  11. package/template/src/core/config.ts +101 -99
  12. package/template/src/core/database/aggregate.ts +89 -85
  13. package/template/src/core/database/config.ts +50 -48
  14. package/template/src/core/database/connection.ts +116 -114
  15. package/template/src/core/database/migrate-hooks.ts +86 -84
  16. package/template/src/core/database/paginate.ts +226 -224
  17. package/template/src/core/database/reset.ts +21 -19
  18. package/template/src/core/database/seed.ts +169 -167
  19. package/template/src/core/database/status.ts +37 -35
  20. package/template/src/core/env.ts +108 -106
  21. package/template/src/core/facade.ts +63 -61
  22. package/template/src/core/maker/db/fresh.ts +10 -8
  23. package/template/src/core/maker/db/generate.ts +13 -11
  24. package/template/src/core/maker/db/helpers.ts +92 -96
  25. package/template/src/core/maker/db/migrate.ts +37 -35
  26. package/template/src/core/maker/db/mod.ts +93 -91
  27. package/template/src/core/maker/db/module-migrate.ts +56 -54
  28. package/template/src/core/maker/db/push.ts +23 -21
  29. package/template/src/core/maker/db/reset.ts +8 -6
  30. package/template/src/core/maker/db/seed.ts +9 -7
  31. package/template/src/core/maker/db/status.ts +8 -6
  32. package/template/src/core/maker/help.ts +59 -57
  33. package/template/src/core/maker/make/controller.ts +25 -22
  34. package/template/src/core/maker/make/helpers.ts +97 -91
  35. package/template/src/core/maker/make/mod.ts +69 -67
  36. package/template/src/core/maker/make/model.ts +16 -14
  37. package/template/src/core/maker/make/module.ts +53 -39
  38. package/template/src/core/maker/make/seeder.ts +23 -21
  39. package/template/src/core/maker/make/test.ts +33 -30
  40. package/template/src/core/maker/mod.ts +85 -83
  41. package/template/src/core/maker/run/mod.ts +134 -132
  42. package/template/src/core/maker/stub.ts +26 -24
  43. package/template/src/core/maker/stubs/controller/controller.controller.stub +57 -55
  44. package/template/src/core/maker/stubs/controller/controller.schema.stub +18 -13
  45. package/template/src/core/maker/stubs/facade/facade.stub +21 -0
  46. package/template/src/core/maker/stubs/model/model.stub +10 -8
  47. package/template/src/core/maker/stubs/seeder/seeder.stub +18 -16
  48. package/template/src/core/maker/stubs/test/test.stub +9 -7
  49. package/template/src/core/maker/sync-config.ts +93 -94
  50. package/template/src/core/utils/password.ts +29 -27
  51. package/template/src/core/utils/playwright.ts +123 -121
  52. package/template/src/core/utils/queue.ts +68 -66
  53. package/template/src/core/utils/scheduler.ts +62 -60
  54. package/template/src/core/utils/storage.ts +3 -1
  55. package/template/src/core/utils/validation.ts +37 -35
  56. package/template/src/database/schema.ts +2 -0
  57. package/template/src/main.ts +120 -118
  58. package/template/src/modules/app/__tests__/demo.controller.test.ts +75 -0
  59. package/template/src/modules/app/__tests__/net.controller.test.ts +65 -0
  60. package/template/src/modules/app/__tests__/playwright.controller.test.ts +50 -0
  61. package/template/src/modules/app/__tests__/storage.controller.test.ts +114 -0
  62. package/template/src/modules/app/__tests__/window.controller.test.ts +98 -0
  63. package/template/src/modules/app/controllers/demo.controller.ts +120 -118
  64. package/template/src/modules/app/controllers/net.controller.ts +50 -48
  65. package/template/src/modules/app/controllers/playwright.controller.ts +142 -140
  66. package/template/src/modules/app/controllers/storage.controller.ts +231 -229
  67. package/template/src/modules/app/controllers/window.controller.ts +2 -0
  68. package/template/src/modules/app/facade.ts +21 -0
  69. package/template/src/preload.ts +25 -2
  70. package/template/src/ui/src/App.vue +4 -2
  71. package/template/src/ui/src/app.ts +38 -23
  72. package/template/src/ui/src/bindings.d.ts +18 -16
  73. package/template/src/ui/src/components/Button.vue +34 -32
  74. package/template/src/ui/src/components/Checkbox.vue +26 -29
  75. package/template/src/ui/src/components/Input.vue +221 -227
  76. package/template/src/ui/src/components/InputGroup.vue +141 -0
  77. package/template/src/ui/src/components/InputPasswordToggle.vue +204 -0
  78. package/template/src/ui/src/components/Modal.vue +65 -55
  79. package/template/src/ui/src/components/Spinner.vue +44 -42
  80. package/template/src/ui/src/components/Switch.vue +62 -65
  81. package/template/src/ui/src/components/TextArea.vue +108 -121
  82. package/template/src/ui/src/components/Toast.vue +55 -56
  83. package/template/src/ui/src/components/datatable/DataTableSkeleton.vue +100 -98
  84. package/template/src/ui/src/components/datatable/Pagination.vue +153 -125
  85. package/template/src/ui/src/components/datatable/SelectOpption.vue +36 -35
  86. package/template/src/ui/src/components/datatable/index.vue +336 -258
  87. package/template/src/ui/src/env.d.ts +16 -13
  88. package/template/src/ui/src/global.d.ts +21 -2
  89. package/template/src/ui/src/helpers/nformatter.ts +12 -10
  90. package/template/src/ui/src/pages/dashboard/index.vue +690 -687
  91. package/template/src/ui/src/plugins/browserDetect.ts +57 -0
  92. package/template/src/ui/src/plugins/gum.ts +576 -549
  93. package/template/src/ui/src/plugins/pulse.ts +181 -147
  94. package/template/src/ui/src/plugins/routeProgress.ts +89 -0
  95. package/template/src/ui/src/router/index.ts +44 -25
  96. package/template/src/ui/src/stores/example.ts +2 -0
  97. package/template/src/ui/vite.config.ts +40 -38
  98. package/template/src/window/app-menu.ts +89 -87
  99. package/template/src/window/config.ts +14 -12
  100. package/template/src/window/context-menu.ts +23 -21
  101. package/template/src/window/dialogs.ts +92 -90
  102. package/template/src/window/manager.ts +2 -0
  103. package/template/src/window/native.ts +47 -45
  104. package/template/src/window/tray.ts +132 -130
@@ -1,132 +1,134 @@
1
- import { spawnSync } from "node:child_process";
2
- import fs from "node:fs";
3
- import path from "node:path";
4
- import { fileURLToPath } from "node:url";
5
- import type { CommandDef } from "@/core/maker/help";
6
-
7
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
8
- const ROOT = path.resolve(__dirname, "..", "..", "..", "..");
9
-
10
- function run(cmd: string, args: string[], opts: { cwd?: string; label?: string } = {}): void {
11
- console.log(`== ${opts.label ?? cmd} ==`);
12
- const isWin = process.platform === "win32";
13
- const r = spawnSync(isWin ? "cmd.exe" : cmd, isWin ? ["/d", "/s", "/c", cmd, ...args] : args, {
14
- cwd: opts.cwd ?? ROOT,
15
- stdio: "inherit",
16
- shell: false,
17
- env: process.env
18
- });
19
- if (r.error) throw r.error;
20
- if (r.status !== 0) process.exit(r.status ?? 1);
21
- }
22
-
23
- function tsxScript(script: string, label: string): void {
24
- run("npx", ["--yes", "tsx", "--tsconfig", "tsconfig.json", script], { label });
25
- }
26
-
27
- function configSync(): void {
28
- tsxScript("src/core/maker/sync-config.ts", "config:sync");
29
- }
30
-
31
- function schemaAndBindings(): void {
32
- configSync();
33
- tsxScript("src/core/database/aggregate.ts", "schema (db:schema)");
34
- tsxScript("src/core/api/generate.manifest.ts", "bindings (bindings:gen)");
35
- }
36
-
37
- export function registerRunCommands(register: (cmd: CommandDef) => void): void {
38
- register({
39
- name: "dev",
40
- group: "Getting started",
41
- description: "Start Electron + Vite UI (HMR) + esbuild watch for main/preload",
42
- action: () => {
43
- schemaAndBindings();
44
- run("npm", ["run", "dev"], { label: "dev" });
45
- }
46
- });
47
-
48
- register({
49
- name: "ui",
50
- group: "Getting started",
51
- description: "Start Vite dev server for the renderer only (no Electron bindings)",
52
- action: () => run("npx", ["vite", "--config", "src/ui/vite.config.ts"], { label: "vite dev", cwd: ROOT })
53
- });
54
-
55
- register({
56
- name: "start",
57
- group: "Getting started",
58
- description: "Run the built Electron app (loads src/ui/dist; requires build)",
59
- action: () => run("npm", ["run", "start"], { label: "start" })
60
- });
61
-
62
- register({
63
- name: "config:sync",
64
- group: "Build & codegen",
65
- description: "Sync src/config/app.ts -> package.json build/identity + scripts/installer.nsh",
66
- action: () => configSync()
67
- });
68
-
69
- register({
70
- name: "codegen",
71
- group: "Build & codegen",
72
- description: "Sync config + regenerate database schema + bindings manifest",
73
- action: () => schemaAndBindings()
74
- });
75
-
76
- register({
77
- name: "bindings:gen",
78
- group: "Build & codegen",
79
- description: "Regenerate src/core/api/bindings.generated.ts from controllers",
80
- action: () => tsxScript("src/core/api/generate.manifest.ts", "bindings:gen")
81
- });
82
-
83
- register({
84
- name: "build",
85
- group: "Build & codegen",
86
- description: "Build renderer UI + Electron main/preload bundles",
87
- action: () => {
88
- schemaAndBindings();
89
- run("npm", ["run", "build"], { label: "build", cwd: ROOT });
90
- }
91
- });
92
-
93
- register({
94
- name: "package",
95
- group: "Build & codegen",
96
- description: "Build and package installers with electron-builder",
97
- action: (flags) => {
98
- schemaAndBindings();
99
- run("npm", ["run", "build"], { label: "build" });
100
- const ebArgs = ["--yes", "electron-builder"];
101
- if (typeof flags.platform === "string") ebArgs.push(`--${flags.platform}`);
102
- if (typeof flags.target === "string") ebArgs.push(`--${flags.target}`);
103
- run("npx", ebArgs, { label: "electron-builder" });
104
- }
105
- });
106
-
107
- register({
108
- name: "serve",
109
- group: "Getting started",
110
- description: "Alias for dev (Electron)",
111
- action: () => run("npm", ["run", "dev"], { label: "dev" })
112
- });
113
-
114
- register({
115
- name: "test",
116
- group: "Testing",
117
- description: "Run Vitest unit tests (node environment)",
118
- action: () => run("npx", ["vitest", "run"], { label: "test" })
119
- });
120
- register({
121
- name: "test:watch",
122
- group: "Testing",
123
- description: "Run Vitest in watch mode",
124
- action: () => run("npx", ["vitest"], { label: "test:watch" })
125
- });
126
- register({
127
- name: "test:coverage",
128
- group: "Testing",
129
- description: "Run Vitest with V8 coverage",
130
- action: () => run("npx", ["vitest", "run", "--coverage"], { label: "test:coverage" })
131
- });
132
- }
1
+ // ./src/core/maker/run/mod.ts
2
+
3
+ import { spawnSync } from "node:child_process";
4
+ import fs from "node:fs";
5
+ import path from "node:path";
6
+ import { fileURLToPath } from "node:url";
7
+ import type { CommandDef } from "@/core/maker/help";
8
+
9
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
10
+ const ROOT = path.resolve(__dirname, "..", "..", "..", "..");
11
+
12
+ function run(cmd: string, args: string[], opts: { cwd?: string; label?: string } = {}): void {
13
+ console.log(`== ${opts.label ?? cmd} ==`);
14
+ const isWin = process.platform === "win32";
15
+ const r = spawnSync(isWin ? "cmd.exe" : cmd, isWin ? ["/d", "/s", "/c", cmd, ...args] : args, {
16
+ cwd: opts.cwd ?? ROOT,
17
+ stdio: "inherit",
18
+ shell: false,
19
+ env: process.env
20
+ });
21
+ if (r.error) throw r.error;
22
+ if (r.status !== 0) process.exit(r.status ?? 1);
23
+ }
24
+
25
+ function tsxScript(script: string, label: string): void {
26
+ run("npx", ["--yes", "tsx", "--tsconfig", "tsconfig.json", script], { label });
27
+ }
28
+
29
+ function configSync(): void {
30
+ tsxScript("src/core/maker/sync-config.ts", "config:sync");
31
+ }
32
+
33
+ function schemaAndBindings(): void {
34
+ configSync();
35
+ tsxScript("src/core/database/aggregate.ts", "schema (db:schema)");
36
+ tsxScript("src/core/api/generate.manifest.ts", "bindings (bindings:gen)");
37
+ }
38
+
39
+ export function registerRunCommands(register: (cmd: CommandDef) => void): void {
40
+ register({
41
+ name: "dev",
42
+ group: "Getting started",
43
+ description: "Start Electron + Vite UI (HMR) + esbuild watch for main/preload",
44
+ action: () => {
45
+ schemaAndBindings();
46
+ run("npm", ["run", "dev"], { label: "dev" });
47
+ }
48
+ });
49
+
50
+ register({
51
+ name: "ui",
52
+ group: "Getting started",
53
+ description: "Start Vite dev server for the renderer only (no Electron bindings)",
54
+ action: () => run("npx", ["vite", "--config", "src/ui/vite.config.ts"], { label: "vite dev", cwd: ROOT })
55
+ });
56
+
57
+ register({
58
+ name: "start",
59
+ group: "Getting started",
60
+ description: "Run the built Electron app (loads src/ui/dist; requires build)",
61
+ action: () => run("npm", ["run", "start"], { label: "start" })
62
+ });
63
+
64
+ register({
65
+ name: "config:sync",
66
+ group: "Build & codegen",
67
+ description: "Sync src/config/app.ts -> package.json build/identity + scripts/installer.nsh",
68
+ action: () => configSync()
69
+ });
70
+
71
+ register({
72
+ name: "codegen",
73
+ group: "Build & codegen",
74
+ description: "Sync config + regenerate database schema + bindings manifest",
75
+ action: () => schemaAndBindings()
76
+ });
77
+
78
+ register({
79
+ name: "bindings:gen",
80
+ group: "Build & codegen",
81
+ description: "Regenerate src/core/api/bindings.generated.ts from controllers",
82
+ action: () => tsxScript("src/core/api/generate.manifest.ts", "bindings:gen")
83
+ });
84
+
85
+ register({
86
+ name: "build",
87
+ group: "Build & codegen",
88
+ description: "Build renderer UI + Electron main/preload bundles",
89
+ action: () => {
90
+ schemaAndBindings();
91
+ run("npm", ["run", "build"], { label: "build", cwd: ROOT });
92
+ }
93
+ });
94
+
95
+ register({
96
+ name: "package",
97
+ group: "Build & codegen",
98
+ description: "Build and package installers with electron-builder",
99
+ action: (flags) => {
100
+ schemaAndBindings();
101
+ run("npm", ["run", "build"], { label: "build" });
102
+ const ebArgs = ["--yes", "electron-builder"];
103
+ if (typeof flags.platform === "string") ebArgs.push(`--${flags.platform}`);
104
+ if (typeof flags.target === "string") ebArgs.push(`--${flags.target}`);
105
+ run("npx", ebArgs, { label: "electron-builder" });
106
+ }
107
+ });
108
+
109
+ register({
110
+ name: "serve",
111
+ group: "Getting started",
112
+ description: "Alias for dev (Electron)",
113
+ action: () => run("npm", ["run", "dev"], { label: "dev" })
114
+ });
115
+
116
+ register({
117
+ name: "test",
118
+ group: "Testing",
119
+ description: "Run Vitest unit tests (node environment)",
120
+ action: () => run("npx", ["vitest", "run"], { label: "test" })
121
+ });
122
+ register({
123
+ name: "test:watch",
124
+ group: "Testing",
125
+ description: "Run Vitest in watch mode",
126
+ action: () => run("npx", ["vitest"], { label: "test:watch" })
127
+ });
128
+ register({
129
+ name: "test:coverage",
130
+ group: "Testing",
131
+ description: "Run Vitest with V8 coverage",
132
+ action: () => run("npx", ["vitest", "run", "--coverage"], { label: "test:coverage" })
133
+ });
134
+ }
@@ -1,24 +1,26 @@
1
- import fs from "node:fs";
2
- import { dirname, join } from "node:path";
3
- import { fileURLToPath } from "node:url";
4
-
5
- export interface StubValues {
6
- [key: string]: string;
7
- }
8
-
9
- const __filename = fileURLToPath(import.meta.url);
10
- const __dirname = dirname(__filename);
11
- const STUBS_ROOT = join(__dirname, "stubs");
12
-
13
- /**
14
- * Read a stub file and replace {{key}} placeholders, removing any that
15
- * remain unfilled.
16
- */
17
- export function loadStub(name: string, values: StubValues): string {
18
- const file = join(STUBS_ROOT, name);
19
- let content = fs.readFileSync(file, "utf8");
20
- for (const [key, value] of Object.entries(values)) {
21
- content = content.replaceAll(`{{${key}}}`, value);
22
- }
23
- return content.replace(/\{\{[A-Z0-9_]+\}\}/g, "");
24
- }
1
+ // ./src/core/maker/stub.ts
2
+
3
+ import fs from "node:fs";
4
+ import { dirname, join } from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+
7
+ export interface StubValues {
8
+ [key: string]: string;
9
+ }
10
+
11
+ const __filename = fileURLToPath(import.meta.url);
12
+ const __dirname = dirname(__filename);
13
+ const STUBS_ROOT = join(__dirname, "stubs");
14
+
15
+ /**
16
+ * Read a stub file and replace {{key}} placeholders, removing any that
17
+ * remain unfilled.
18
+ */
19
+ export function loadStub(name: string, values: StubValues): string {
20
+ const file = join(STUBS_ROOT, name);
21
+ let content = fs.readFileSync(file, "utf8");
22
+ for (const [key, value] of Object.entries(values)) {
23
+ content = content.replaceAll(`{{${key}}}`, value);
24
+ }
25
+ return content.replace(/\{\{[A-Z0-9_]+\}\}/g, "");
26
+ }
@@ -1,55 +1,57 @@
1
- import { validate } from "@/core/facade";
2
- import { Create{{ClassName}}Schema,Update{{ClassName}}Schema,{{ClassName}}IdParamsSchema } from "@/modules/{{module}}/controllers/{{controller}}.schema";
3
-
4
- /**
5
- * Why: Returns collection response shape for list pages.
6
- * When: Used by the frontend list view.
7
- * Where: bound as "{{module}}.{{controller}}.index".
8
- */
9
- export const index = async () => {
10
- return { message: "{{controller}} list fetched successfully", data: [] };
11
- };
12
-
13
- /**
14
- * Why: Returns one resource by validated id.
15
- * When: Used by detail screens or fetch-by-id calls.
16
- * Where: bound as "{{module}}.{{controller}}.show".
17
- */
18
- export const show = async (params: unknown) => {
19
- const { id } = await validate.run({{ClassName}}IdParamsSchema, params);
20
- return { message: "{{controller}} fetched successfully", data: { id, name: "" } };
21
- };
22
-
23
- /**
24
- * Why: Creates a new resource from validated input.
25
- * When: Used by create form submissions.
26
- * Where: bound as "{{module}}.{{controller}}.store".
27
- */
28
- export const store = async (body: unknown) => {
29
- await validate.run(Create{{ClassName}}Schema, body);
30
- return { message: "{{controller}} created successfully" };
31
- };
32
-
33
- /**
34
- * Why: Updates an existing resource using validated id + body.
35
- * When: Used by edit/update form submissions.
36
- * Where: bound as "{{module}}.{{controller}}.update".
37
- */
38
- export const update = async (input: { params: unknown; body: unknown }) => {
39
- await validate.run({{ClassName}}IdParamsSchema, input.params);
40
- await validate.run(Update{{ClassName}}Schema, input.body);
41
- return { message: "{{controller}} updated successfully" };
42
- };
43
-
44
- /**
45
- * Why: Deletes one resource by validated id.
46
- * When: Used by delete actions.
47
- * Where: bound as "{{module}}.{{controller}}.destroy".
48
- */
49
- export const destroy = async (params: unknown) => {
50
- await validate.run({{ClassName}}IdParamsSchema, params);
51
- return { message: "{{controller}} deleted successfully" };
52
- };
53
-
54
- /** Handlers exposed to the frontend via the bindings registry. */
55
- export const handlers = { index, show, store, update, destroy };
1
+ // ./src/modules/{{module}}/controllers/{{controller}}.controller.ts
2
+
3
+ import { validate } from "@/core/facade";
4
+ import { Create{{ClassName}}Schema,Update{{ClassName}}Schema,{{ClassName}}IdParamsSchema } from "@/modules/{{module}}/controllers/{{controller}}.schema";
5
+
6
+ /**
7
+ * Why: Returns collection response shape for list pages.
8
+ * When: Used by the frontend list view.
9
+ * Where: bound as "{{module}}.{{controller}}.index".
10
+ */
11
+ export const index = async () => {
12
+ return { message: "{{controller}} list fetched successfully", data: [] };
13
+ };
14
+
15
+ /**
16
+ * Why: Returns one resource by validated id.
17
+ * When: Used by detail screens or fetch-by-id calls.
18
+ * Where: bound as "{{module}}.{{controller}}.show".
19
+ */
20
+ export const show = async (params: unknown) => {
21
+ const { id } = await validate.run({{ClassName}}IdParamsSchema, params);
22
+ return { message: "{{controller}} fetched successfully", data: { id, name: "" } };
23
+ };
24
+
25
+ /**
26
+ * Why: Creates a new resource from validated input.
27
+ * When: Used by create form submissions.
28
+ * Where: bound as "{{module}}.{{controller}}.store".
29
+ */
30
+ export const store = async (body: unknown) => {
31
+ await validate.run(Create{{ClassName}}Schema, body);
32
+ return { message: "{{controller}} created successfully" };
33
+ };
34
+
35
+ /**
36
+ * Why: Updates an existing resource using validated id + body.
37
+ * When: Used by edit/update form submissions.
38
+ * Where: bound as "{{module}}.{{controller}}.update".
39
+ */
40
+ export const update = async (input: { params: unknown; body: unknown }) => {
41
+ await validate.run({{ClassName}}IdParamsSchema, input.params);
42
+ await validate.run(Update{{ClassName}}Schema, input.body);
43
+ return { message: "{{controller}} updated successfully" };
44
+ };
45
+
46
+ /**
47
+ * Why: Deletes one resource by validated id.
48
+ * When: Used by delete actions.
49
+ * Where: bound as "{{module}}.{{controller}}.destroy".
50
+ */
51
+ export const destroy = async (params: unknown) => {
52
+ await validate.run({{ClassName}}IdParamsSchema, params);
53
+ return { message: "{{controller}} deleted successfully" };
54
+ };
55
+
56
+ /** Handlers exposed to the frontend via the bindings registry. */
57
+ export const handlers = { index, show, store, update, destroy };
@@ -1,13 +1,18 @@
1
- import { z } from "zod";
2
-
3
- export const Create{{ClassName}}Schema = z.object({
4
- name: z.string().min(1),
5
- });
6
-
7
- export const Update{{ClassName}}Schema = z.object({
8
- name: z.string().min(1),
9
- });
10
-
11
- export const {{ClassName}}IdParamsSchema = z.object({
12
- id: z.coerce.number().int().positive(),
13
- });
1
+ // ./src/modules/{{module}}/controllers/{{controller}}.schema.ts
2
+
3
+ import { z } from "zod";
4
+
5
+ export const Create{{ClassName}}Schema = z.object({
6
+ name: z.string().min(1),
7
+ });
8
+ export type Create{{ClassName}}Type = z.input<typeof Create{{ClassName}}Schema>;
9
+
10
+ export const Update{{ClassName}}Schema = z.object({
11
+ name: z.string().min(1),
12
+ });
13
+ export type Update{{ClassName}}Type = z.input<typeof Update{{ClassName}}Schema>;
14
+
15
+ export const {{ClassName}}IdParamsSchema = z.object({
16
+ id: z.coerce.number().int().positive(),
17
+ });
18
+ export type {{ClassName}}IdParamsType = z.input<typeof {{ClassName}}IdParamsSchema>;
@@ -0,0 +1,21 @@
1
+ // ./src/modules/{{module}}/facade.ts
2
+
3
+ /**
4
+ * Public API for the {{module}} module.
5
+ *
6
+ * Other modules import from this file, never from controllers/ or database/
7
+ * directly. Each controller is re-exported under its own namespace, and the
8
+ * module's model(s) are re-exported directly:
9
+ *
10
+ * import { {{module}} } from "@/modules/{{module}}/facade";
11
+ * const rows = await {{module}}.index();
12
+ *
13
+ * Share another controller by adding a namespace line for it:
14
+ * export * as post from "./controllers/post.controller";
15
+ *
16
+ * Rules: a module never imports its own facade; a facade never imports another
17
+ * facade.
18
+ */
19
+
20
+ export * as {{module}} from "./controllers/{{module}}.controller";
21
+ export * from "./database/models/{{module}}.model";
@@ -1,8 +1,10 @@
1
- import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
2
-
3
- export const {{tableVariable}} = sqliteTable("{{tableName}}", {
4
- id: integer("id").primaryKey({ autoIncrement: true }),
5
- name: text("name").notNull(),
6
- createdAt: text("created_at").notNull().default("current_timestamp"),
7
- updatedAt: text("updated_at").notNull().default("current_timestamp"),
8
- });
1
+ // ./src/modules/{{module}}/database/models/{{name}}.model.ts
2
+
3
+ import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
4
+
5
+ export const {{tableVariable}} = sqliteTable("{{tableName}}", {
6
+ id: integer("id").primaryKey({ autoIncrement: true }),
7
+ name: text("name").notNull(),
8
+ createdAt: text("created_at").notNull().default("current_timestamp"),
9
+ updatedAt: text("updated_at").notNull().default("current_timestamp"),
10
+ });
@@ -1,16 +1,18 @@
1
- import { db } from "@/core/database/connection";
2
- import { {{tableVariable}} } from "@/modules/{{module}}/database/models/{{name}}.model";
3
-
4
- export const table = {{tableVariable}};
5
-
6
- export default async function {{ClassName}}Seeder() {
7
- const rows: (typeof {{tableVariable}}.$inferInsert)[] = [
8
- // Add your seed data here
9
- ];
10
-
11
- for (const row of rows) {
12
- await db.insert({{tableVariable}}).values(row);
13
- }
14
-
15
- console.log("{{ClassName}} seeder completed");
16
- }
1
+ // ./src/modules/{{module}}/database/seeders/{{name}}.seed.ts
2
+
3
+ import { db } from "@/core/database/connection";
4
+ import { {{tableVariable}} } from "@/modules/{{module}}/database/models/{{name}}.model";
5
+
6
+ export const table = {{tableVariable}};
7
+
8
+ export default async function {{ClassName}}Seeder() {
9
+ const rows: (typeof {{tableVariable}}.$inferInsert)[] = [
10
+ // Add your seed data here
11
+ ];
12
+
13
+ for (const row of rows) {
14
+ await db.insert({{tableVariable}}).values(row);
15
+ }
16
+
17
+ console.log("{{ClassName}} seeder completed");
18
+ }
@@ -1,7 +1,9 @@
1
- import { describe, expect, it } from "vitest";
2
-
3
- describe("{{module}} module{{#name}} - {{name}}{{/name}}", () => {
4
- it("works", () => {
5
- expect(true).toBe(true);
6
- });
7
- });
1
+ // ./src/modules/{{module}}/__tests__/{{file}}
2
+
3
+ import { describe, expect, it } from "vitest";
4
+
5
+ describe("{{module}} module{{#name}} - {{name}}{{/name}}", () => {
6
+ it("works", () => {
7
+ expect(true).toBe(true);
8
+ });
9
+ });