@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.
- package/package.json +16 -16
- package/template/.env.example +20 -13
- package/template/AGENTS.md +699 -0
- package/template/package.json +3 -0
- package/template/src/config/app.ts +26 -24
- package/template/src/config/winsetup.ts +93 -91
- package/template/src/core/api/binding-error.ts +57 -0
- package/template/src/core/api/bindings.generated.ts +2 -0
- package/template/src/core/api/generate.manifest.ts +84 -80
- package/template/src/core/api/registry.ts +58 -48
- package/template/src/core/config.ts +101 -99
- package/template/src/core/database/aggregate.ts +89 -85
- package/template/src/core/database/config.ts +50 -48
- package/template/src/core/database/connection.ts +116 -114
- package/template/src/core/database/migrate-hooks.ts +86 -84
- package/template/src/core/database/paginate.ts +226 -224
- package/template/src/core/database/reset.ts +21 -19
- package/template/src/core/database/seed.ts +169 -167
- package/template/src/core/database/status.ts +37 -35
- package/template/src/core/env.ts +108 -106
- package/template/src/core/facade.ts +63 -61
- package/template/src/core/maker/db/fresh.ts +10 -8
- package/template/src/core/maker/db/generate.ts +13 -11
- package/template/src/core/maker/db/helpers.ts +92 -96
- package/template/src/core/maker/db/migrate.ts +37 -35
- package/template/src/core/maker/db/mod.ts +93 -91
- package/template/src/core/maker/db/module-migrate.ts +56 -54
- package/template/src/core/maker/db/push.ts +23 -21
- package/template/src/core/maker/db/reset.ts +8 -6
- package/template/src/core/maker/db/seed.ts +9 -7
- package/template/src/core/maker/db/status.ts +8 -6
- package/template/src/core/maker/help.ts +59 -57
- package/template/src/core/maker/make/controller.ts +25 -22
- package/template/src/core/maker/make/helpers.ts +97 -91
- package/template/src/core/maker/make/mod.ts +69 -67
- package/template/src/core/maker/make/model.ts +16 -14
- package/template/src/core/maker/make/module.ts +53 -39
- package/template/src/core/maker/make/seeder.ts +23 -21
- package/template/src/core/maker/make/test.ts +33 -30
- package/template/src/core/maker/mod.ts +85 -83
- package/template/src/core/maker/run/mod.ts +134 -132
- package/template/src/core/maker/stub.ts +26 -24
- package/template/src/core/maker/stubs/controller/controller.controller.stub +57 -55
- package/template/src/core/maker/stubs/controller/controller.schema.stub +18 -13
- package/template/src/core/maker/stubs/facade/facade.stub +21 -0
- package/template/src/core/maker/stubs/model/model.stub +10 -8
- package/template/src/core/maker/stubs/seeder/seeder.stub +18 -16
- package/template/src/core/maker/stubs/test/test.stub +9 -7
- package/template/src/core/maker/sync-config.ts +93 -94
- package/template/src/core/utils/password.ts +29 -27
- package/template/src/core/utils/playwright.ts +123 -121
- package/template/src/core/utils/queue.ts +68 -66
- package/template/src/core/utils/scheduler.ts +62 -60
- package/template/src/core/utils/storage.ts +3 -1
- package/template/src/core/utils/validation.ts +37 -35
- package/template/src/database/schema.ts +2 -0
- package/template/src/main.ts +120 -118
- package/template/src/modules/app/__tests__/demo.controller.test.ts +75 -0
- package/template/src/modules/app/__tests__/net.controller.test.ts +65 -0
- package/template/src/modules/app/__tests__/playwright.controller.test.ts +50 -0
- package/template/src/modules/app/__tests__/storage.controller.test.ts +114 -0
- package/template/src/modules/app/__tests__/window.controller.test.ts +98 -0
- package/template/src/modules/app/controllers/demo.controller.ts +120 -118
- package/template/src/modules/app/controllers/net.controller.ts +50 -48
- package/template/src/modules/app/controllers/playwright.controller.ts +142 -140
- package/template/src/modules/app/controllers/storage.controller.ts +231 -229
- package/template/src/modules/app/controllers/window.controller.ts +2 -0
- package/template/src/modules/app/facade.ts +21 -0
- package/template/src/preload.ts +25 -2
- package/template/src/ui/src/App.vue +4 -2
- package/template/src/ui/src/app.ts +38 -23
- package/template/src/ui/src/bindings.d.ts +18 -16
- package/template/src/ui/src/components/Button.vue +34 -32
- package/template/src/ui/src/components/Checkbox.vue +26 -29
- package/template/src/ui/src/components/Input.vue +221 -227
- package/template/src/ui/src/components/InputGroup.vue +141 -0
- package/template/src/ui/src/components/InputPasswordToggle.vue +204 -0
- package/template/src/ui/src/components/Modal.vue +65 -55
- package/template/src/ui/src/components/Spinner.vue +44 -42
- package/template/src/ui/src/components/Switch.vue +62 -65
- package/template/src/ui/src/components/TextArea.vue +108 -121
- package/template/src/ui/src/components/Toast.vue +55 -56
- package/template/src/ui/src/components/datatable/DataTableSkeleton.vue +100 -98
- package/template/src/ui/src/components/datatable/Pagination.vue +153 -125
- package/template/src/ui/src/components/datatable/SelectOpption.vue +36 -35
- package/template/src/ui/src/components/datatable/index.vue +336 -258
- package/template/src/ui/src/env.d.ts +16 -13
- package/template/src/ui/src/global.d.ts +21 -2
- package/template/src/ui/src/helpers/nformatter.ts +12 -10
- package/template/src/ui/src/pages/dashboard/index.vue +690 -687
- package/template/src/ui/src/plugins/browserDetect.ts +57 -0
- package/template/src/ui/src/plugins/gum.ts +576 -549
- package/template/src/ui/src/plugins/pulse.ts +181 -147
- package/template/src/ui/src/plugins/routeProgress.ts +89 -0
- package/template/src/ui/src/router/index.ts +44 -25
- package/template/src/ui/src/stores/example.ts +2 -0
- package/template/src/ui/vite.config.ts +40 -38
- package/template/src/window/app-menu.ts +89 -87
- package/template/src/window/config.ts +14 -12
- package/template/src/window/context-menu.ts +23 -21
- package/template/src/window/dialogs.ts +92 -90
- package/template/src/window/manager.ts +2 -0
- package/template/src/window/native.ts +47 -45
- package/template/src/window/tray.ts +132 -130
|
@@ -1,132 +1,134 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
*
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
*
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
*
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
*
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
]
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
+
});
|