create-nexwire 4.1.2 → 4.2.1
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/express/gitignore-stub +31 -24
- package/express/package.json +2 -2
- package/express/src/database/migrations/sqlite/meta/0000_snapshot.json +411 -411
- package/express/src/database/migrations/sqlite/meta/_journal.json +12 -12
- package/express/src/framework/http/router.ts +16 -2
- package/express/src/framework/maker-cli/db/index.mjs +1 -1
- package/express/src/framework/maker-cli/deploy/core.mjs +0 -1
- package/express/src/framework/maker-cli/index.mjs +13 -3
- package/express/src/framework/maker-cli/module/core.mjs +121 -43
- package/express/src/framework/maker-cli/runtime/core.mjs +26 -7
- package/express/src/framework/maker-cli/runtime/index.mjs +120 -104
- package/express/src/framework/maker-cli/stubs/controller/openapi.ts.stub +6 -6
- package/express/src/framework/maker-cli/stubs/controller/plain.ts.stub +6 -6
- package/express/src/framework/maker-cli/stubs/helper/name.ts.stub +1 -1
- package/express/src/framework/maker-cli/stubs/seeder/name.ts.stub +17 -19
- package/express/src/framework/maker-cli/stubs/seeder/standalone.ts.stub +22 -0
- package/express/src/framework/maker-cli/stubs/service/name.plain.ts.stub +2 -2
- package/express/src/framework/maker-cli/stubs/service/name.ts.stub +1 -1
- package/express/src/framework/maker-cli/utils/help.mjs +374 -50
- package/express/src/framework/maker-cli/utils/naming.mjs +83 -20
- package/express/src/framework/maker-cli/utils/project-commands.mjs +140 -0
- package/express/src/framework/queue/queue.ts +402 -342
- package/express/src/modules/auth/database/seeders/role.ts +18 -18
- package/express/src/modules/auth/database/seeders/user.ts +35 -35
- package/express/vitest.config.ts +38 -23
- package/hono/gitignore-stub +31 -24
- package/hono/package.json +2 -2
- package/hono/src/database/migrations/sqlite/meta/0000_snapshot.json +411 -411
- package/hono/src/database/migrations/sqlite/meta/_journal.json +12 -12
- package/hono/src/framework/database/paginate.ts +253 -253
- package/hono/src/framework/http/router.ts +35 -14
- package/hono/src/framework/maker-cli/db/index.mjs +1 -1
- package/hono/src/framework/maker-cli/deploy/core.mjs +0 -1
- package/hono/src/framework/maker-cli/index.mjs +13 -3
- package/hono/src/framework/maker-cli/module/core.mjs +116 -38
- package/hono/src/framework/maker-cli/runtime/core.mjs +24 -6
- package/hono/src/framework/maker-cli/runtime/index.mjs +120 -104
- package/hono/src/framework/maker-cli/stubs/controller/openapi.ts.stub +6 -6
- package/hono/src/framework/maker-cli/stubs/controller/plain.ts.stub +6 -6
- package/hono/src/framework/maker-cli/stubs/helper/name.ts.stub +1 -1
- package/hono/src/framework/maker-cli/stubs/seeder/name.ts.stub +17 -19
- package/hono/src/framework/maker-cli/stubs/seeder/standalone.ts.stub +22 -0
- package/hono/src/framework/maker-cli/stubs/service/name.plain.ts.stub +2 -2
- package/hono/src/framework/maker-cli/stubs/service/name.ts.stub +1 -1
- package/hono/src/framework/maker-cli/utils/help.mjs +374 -50
- package/hono/src/framework/maker-cli/utils/naming.mjs +83 -20
- package/hono/src/framework/maker-cli/utils/project-commands.mjs +140 -0
- package/hono/src/framework/queue/queue.ts +402 -342
- package/hono/src/modules/auth/database/seeders/role.ts +18 -18
- package/hono/src/modules/auth/database/seeders/user.ts +35 -35
- package/hono/vitest.config.ts +38 -23
- package/package.json +1 -1
- package/express/src/framework/maker-cli/stubs/controller/openapi.with-model.ts.stub +0 -73
- package/hono/src/framework/maker-cli/stubs/controller/openapi.with-model.ts.stub +0 -69
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { eq } from "drizzle-orm";
|
|
2
|
-
import { db } from "@/framework/facade.js";
|
|
3
|
-
import { roles } from "@/modules/auth/database/models/role.js";
|
|
4
|
-
|
|
5
|
-
export const table = roles;
|
|
6
|
-
|
|
7
|
-
export default async function RoleSeeder() {
|
|
8
|
-
const rows = [{ name: "admin" }, { name: "user" }];
|
|
9
|
-
|
|
10
|
-
for (const row of rows) {
|
|
11
|
-
const existing = await db.query.roles.findFirst({ where: eq(roles.name, row.name) });
|
|
12
|
-
if (!existing) {
|
|
13
|
-
await db.insert(roles).values({ name: row.name });
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
console.log("Role seeder completed");
|
|
18
|
-
}
|
|
1
|
+
import { eq } from "drizzle-orm";
|
|
2
|
+
import { db } from "@/framework/facade.js";
|
|
3
|
+
import { roles } from "@/modules/auth/database/models/role.js";
|
|
4
|
+
|
|
5
|
+
export const table = roles;
|
|
6
|
+
|
|
7
|
+
export default async function RoleSeeder() {
|
|
8
|
+
const rows = [{ name: "admin" }, { name: "user" }];
|
|
9
|
+
|
|
10
|
+
for (const row of rows) {
|
|
11
|
+
const existing = await db.query.roles.findFirst({ where: eq(roles.name, row.name) });
|
|
12
|
+
if (!existing) {
|
|
13
|
+
await db.insert(roles).values({ name: row.name });
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
console.log("Role seeder completed");
|
|
18
|
+
}
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { eq } from "drizzle-orm";
|
|
2
|
-
import { db, password } from "@/framework/facade.js";
|
|
3
|
-
import { roles } from "@/modules/auth/database/models/role.js";
|
|
4
|
-
import { users } from "@/modules/auth/database/models/user.js";
|
|
5
|
-
|
|
6
|
-
export const table = users;
|
|
7
|
-
|
|
8
|
-
export default async function UserSeeder() {
|
|
9
|
-
const adminRole = await db.query.roles.findFirst({ where: eq(roles.name, "admin") });
|
|
10
|
-
const userRole = await db.query.roles.findFirst({ where: eq(roles.name, "user") });
|
|
11
|
-
|
|
12
|
-
const rows = [
|
|
13
|
-
{
|
|
14
|
-
name: "Admin",
|
|
15
|
-
email: "admin@example.com",
|
|
16
|
-
password: await password.hashPassword("Password@123"),
|
|
17
|
-
roleId: adminRole?.id ?? null
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
name: "User One",
|
|
21
|
-
email: "user1@example.com",
|
|
22
|
-
password: await password.hashPassword("Password@123"),
|
|
23
|
-
roleId: userRole?.id ?? null
|
|
24
|
-
}
|
|
25
|
-
];
|
|
26
|
-
|
|
27
|
-
for (const row of rows) {
|
|
28
|
-
const existing = await db.query.users.findFirst({ where: eq(users.email, row.email) });
|
|
29
|
-
if (!existing) {
|
|
30
|
-
await db.insert(users).values(row);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
console.log("User seeder completed");
|
|
35
|
-
}
|
|
1
|
+
import { eq } from "drizzle-orm";
|
|
2
|
+
import { db, password } from "@/framework/facade.js";
|
|
3
|
+
import { roles } from "@/modules/auth/database/models/role.js";
|
|
4
|
+
import { users } from "@/modules/auth/database/models/user.js";
|
|
5
|
+
|
|
6
|
+
export const table = users;
|
|
7
|
+
|
|
8
|
+
export default async function UserSeeder() {
|
|
9
|
+
const adminRole = await db.query.roles.findFirst({ where: eq(roles.name, "admin") });
|
|
10
|
+
const userRole = await db.query.roles.findFirst({ where: eq(roles.name, "user") });
|
|
11
|
+
|
|
12
|
+
const rows = [
|
|
13
|
+
{
|
|
14
|
+
name: "Admin",
|
|
15
|
+
email: "admin@example.com",
|
|
16
|
+
password: await password.hashPassword("Password@123"),
|
|
17
|
+
roleId: adminRole?.id ?? null
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: "User One",
|
|
21
|
+
email: "user1@example.com",
|
|
22
|
+
password: await password.hashPassword("Password@123"),
|
|
23
|
+
roleId: userRole?.id ?? null
|
|
24
|
+
}
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
for (const row of rows) {
|
|
28
|
+
const existing = await db.query.users.findFirst({ where: eq(users.email, row.email) });
|
|
29
|
+
if (!existing) {
|
|
30
|
+
await db.insert(users).values(row);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
console.log("User seeder completed");
|
|
35
|
+
}
|
package/hono/vitest.config.ts
CHANGED
|
@@ -1,23 +1,38 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
import { fileURLToPath } from "node:url";
|
|
2
|
+
import { defineConfig } from "vitest/config";
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
resolve: {
|
|
6
|
+
alias: {
|
|
7
|
+
"@": fileURLToPath(new URL("./src", import.meta.url))
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
test: {
|
|
11
|
+
globals: true,
|
|
12
|
+
include: ["src/**/*.test.ts", "src/**/*.spec.ts"],
|
|
13
|
+
exclude: ["src/resources/**", "src/storage/**", "node_modules/**", "dist/**"],
|
|
14
|
+
environment: "node",
|
|
15
|
+
coverage: {
|
|
16
|
+
provider: "v8",
|
|
17
|
+
reporter: ["text", "json", "html"],
|
|
18
|
+
include: ["src/**/*.ts"],
|
|
19
|
+
exclude: ["src/resources/**", "src/storage/**", "src/framework/maker-cli/**", "src/**/*.d.ts", "src/**/*.test.ts", "src/**/*.spec.ts"]
|
|
20
|
+
// No `thresholds` here on purpose.
|
|
21
|
+
//
|
|
22
|
+
// This file is published inside the package, so any floor written here also
|
|
23
|
+
// becomes every scaffolded project's floor - and it would fail them on the
|
|
24
|
+
// first run. A new project ships with only the auth module's tests: the
|
|
25
|
+
// framework's own tests under `src/framework/**/__tests__/` are not
|
|
26
|
+
// published, because they test the framework rather than the application.
|
|
27
|
+
// That measures 8.49% statements, so a floor calibrated for this repository
|
|
28
|
+
// reports a failure for a developer who has done nothing wrong and whose
|
|
29
|
+
// 56 tests all pass.
|
|
30
|
+
//
|
|
31
|
+
// The floor is a guard on this repository, not on yours, so it is passed on
|
|
32
|
+
// the command line when the framework's own suite is run - it is never read
|
|
33
|
+
// from this file. That keeps this file byte-identical across both engines,
|
|
34
|
+
// keeps it free of a number that would be meaningless in someone else's
|
|
35
|
+
// project, and still fails when untested code is added here.
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
});
|
package/package.json
CHANGED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import type { Request, Response } from "express";
|
|
2
|
-
import { HttpStatusCodes } from "@/framework/facade.js";
|
|
3
|
-
import { {{controller}}Service } from "@/modules/{{module}}/services/{{controller}}.js";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Why: Returns every {{controller}} row for list screens.
|
|
7
|
-
* When: Used by GET list endpoint.
|
|
8
|
-
* Where: GET /{{controller}} route.
|
|
9
|
-
*/
|
|
10
|
-
export const index = async (_req: Request, res: Response) => {
|
|
11
|
-
const data = await {{controller}}Service.list();
|
|
12
|
-
|
|
13
|
-
res.json({ message: "{{controller}} list fetched successfully", data });
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Why: Returns one {{controller}} row by validated route id.
|
|
18
|
-
* When: Used by detail screens or fetch-by-id calls.
|
|
19
|
-
* Where: GET /{{controller}}/{id} route.
|
|
20
|
-
*/
|
|
21
|
-
export const show = async (req: Request, res: Response) => {
|
|
22
|
-
const data = await {{controller}}Service.findOne(Number(req.params.id));
|
|
23
|
-
|
|
24
|
-
if (!data) {
|
|
25
|
-
res.status(HttpStatusCodes.NOT_FOUND).json({ message: "{{controller}} not found" });
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
res.json({ message: "{{controller}} fetched successfully", data });
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Why: Creates a new {{controller}} row from a validated request body.
|
|
34
|
-
* When: Used by create form submissions.
|
|
35
|
-
* Where: POST /{{controller}} route.
|
|
36
|
-
*/
|
|
37
|
-
export const store = async (req: Request, res: Response) => {
|
|
38
|
-
const data = await {{controller}}Service.create(req.body);
|
|
39
|
-
|
|
40
|
-
res.status(HttpStatusCodes.CREATED).json({ message: "{{controller}} created successfully", data });
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Why: Updates an existing {{controller}} row using id + body validation.
|
|
45
|
-
* When: Used by edit/update form submissions.
|
|
46
|
-
* Where: PUT/PATCH /{{controller}}/{id} route.
|
|
47
|
-
*/
|
|
48
|
-
export const update = async (req: Request, res: Response) => {
|
|
49
|
-
const data = await {{controller}}Service.update(Number(req.params.id), req.body);
|
|
50
|
-
|
|
51
|
-
if (!data) {
|
|
52
|
-
res.status(HttpStatusCodes.NOT_FOUND).json({ message: "{{controller}} not found" });
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
res.json({ message: "{{controller}} updated successfully", data });
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Why: Deletes one {{controller}} row by validated route id.
|
|
61
|
-
* When: Used by delete actions.
|
|
62
|
-
* Where: DELETE /{{controller}}/{id} route.
|
|
63
|
-
*/
|
|
64
|
-
export const destroy = async (req: Request, res: Response) => {
|
|
65
|
-
const data = await {{controller}}Service.remove(Number(req.params.id));
|
|
66
|
-
|
|
67
|
-
if (!data) {
|
|
68
|
-
res.status(HttpStatusCodes.NOT_FOUND).json({ message: "{{controller}} not found" });
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
res.json({ message: "{{controller}} deleted successfully", data });
|
|
73
|
-
};
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import type { Handler } from "hono";
|
|
2
|
-
import { HttpStatusCodes } from "@/framework/facade.js";
|
|
3
|
-
import { {{controller}}Service } from "@/modules/{{module}}/services/{{controller}}.js";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Why: Returns every {{controller}} row for list screens.
|
|
7
|
-
* When: Used by GET list endpoint.
|
|
8
|
-
* Where: GET /{{controller}} route.
|
|
9
|
-
*/
|
|
10
|
-
export const index: Handler = async (c: any) => {
|
|
11
|
-
const data = await {{controller}}Service.list();
|
|
12
|
-
|
|
13
|
-
return c.json({ message: "{{controller}} list fetched successfully", data });
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Why: Returns one {{controller}} row by validated route id.
|
|
18
|
-
* When: Used by detail screens or fetch-by-id calls.
|
|
19
|
-
* Where: GET /{{controller}}/{id} route.
|
|
20
|
-
*/
|
|
21
|
-
export const show: Handler = async (c: any) => {
|
|
22
|
-
const { id } = c.req.valid("param");
|
|
23
|
-
const data = await {{controller}}Service.findOne(id);
|
|
24
|
-
|
|
25
|
-
if (!data) return c.json({ message: "{{controller}} not found" }, HttpStatusCodes.NOT_FOUND);
|
|
26
|
-
|
|
27
|
-
return c.json({ message: "{{controller}} fetched successfully", data });
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Why: Creates a new {{controller}} row from a validated request body.
|
|
32
|
-
* When: Used by create form submissions.
|
|
33
|
-
* Where: POST /{{controller}} route.
|
|
34
|
-
*/
|
|
35
|
-
export const store: Handler = async (c: any) => {
|
|
36
|
-
const body = c.req.valid("json");
|
|
37
|
-
const data = await {{controller}}Service.create(body);
|
|
38
|
-
|
|
39
|
-
return c.json({ message: "{{controller}} created successfully", data }, HttpStatusCodes.CREATED);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Why: Updates an existing {{controller}} row using id + body validation.
|
|
44
|
-
* When: Used by edit/update form submissions.
|
|
45
|
-
* Where: PUT/PATCH /{{controller}}/{id} route.
|
|
46
|
-
*/
|
|
47
|
-
export const update: Handler = async (c: any) => {
|
|
48
|
-
const { id } = c.req.valid("param");
|
|
49
|
-
const body = c.req.valid("json");
|
|
50
|
-
const data = await {{controller}}Service.update(id, body);
|
|
51
|
-
|
|
52
|
-
if (!data) return c.json({ message: "{{controller}} not found" }, HttpStatusCodes.NOT_FOUND);
|
|
53
|
-
|
|
54
|
-
return c.json({ message: "{{controller}} updated successfully", data });
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Why: Deletes one {{controller}} row by validated route id.
|
|
59
|
-
* When: Used by delete actions.
|
|
60
|
-
* Where: DELETE /{{controller}}/{id} route.
|
|
61
|
-
*/
|
|
62
|
-
export const destroy: Handler = async (c: any) => {
|
|
63
|
-
const { id } = c.req.valid("param");
|
|
64
|
-
const data = await {{controller}}Service.remove(id);
|
|
65
|
-
|
|
66
|
-
if (!data) return c.json({ message: "{{controller}} not found" }, HttpStatusCodes.NOT_FOUND);
|
|
67
|
-
|
|
68
|
-
return c.json({ message: "{{controller}} deleted successfully", data });
|
|
69
|
-
};
|