create-guren-app 1.7.1 → 1.7.2
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 +1 -1
- package/templates/api-only/bin/serve.ts +6 -36
- package/templates/api-only/package.json +4 -4
- package/templates/blog/app/Http/Validators/LoginValidator.ts +2 -2
- package/templates/blog/app/Http/Validators/ProfileValidator.ts +2 -2
- package/templates/blog/app/Http/Validators/RegisterValidator.ts +2 -2
- package/templates/blog/app/Models/User.ts +3 -5
- package/templates/default/bin/serve.ts +6 -36
- package/templates/default/package.json +4 -4
package/package.json
CHANGED
|
@@ -9,41 +9,11 @@ try {
|
|
|
9
9
|
|
|
10
10
|
// `PORT=0` means "any free port", so this tests for a number, not truthiness.
|
|
11
11
|
const parsedPort = Number.parseInt(process.env.PORT ?? '', 10)
|
|
12
|
-
const
|
|
12
|
+
const port = Number.isInteger(parsedPort) ? parsedPort : 3333
|
|
13
13
|
const hostname = process.env.HOST ?? '0.0.0.0'
|
|
14
14
|
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const attempts = canWalkPorts ? 20 : 1
|
|
21
|
-
|
|
22
|
-
// This file owns the retry, so the framework must not retry underneath it —
|
|
23
|
-
// newer framework versions walk inside listen() themselves, and the two loops
|
|
24
|
-
// would nest into a much wider search reported against the wrong ports.
|
|
25
|
-
process.env.GUREN_STRICT_PORT = '1'
|
|
26
|
-
|
|
27
|
-
for (let offset = 0; offset < attempts; offset += 1) {
|
|
28
|
-
const port = requestedPort + offset
|
|
29
|
-
|
|
30
|
-
try {
|
|
31
|
-
await app.listen({ port, hostname })
|
|
32
|
-
break
|
|
33
|
-
} catch (error) {
|
|
34
|
-
if (!isAddressInUse(error) || offset === attempts - 1) {
|
|
35
|
-
throw error
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
console.warn(`Port ${port} is in use, trying ${port + 1}...`)
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function isAddressInUse(error: unknown): boolean {
|
|
43
|
-
return Boolean(
|
|
44
|
-
error &&
|
|
45
|
-
typeof error === 'object' &&
|
|
46
|
-
'code' in error &&
|
|
47
|
-
(error as { code?: unknown }).code === 'EADDRINUSE',
|
|
48
|
-
)
|
|
49
|
-
}
|
|
15
|
+
// The walk past a busy port lives in listen() now, which is also the only
|
|
16
|
+
// place that can report which port it ended up on. Set GUREN_STRICT_PORT=1 to
|
|
17
|
+
// fail fast instead — what an automated consumer wants when it has to know
|
|
18
|
+
// the app under test is the one answering.
|
|
19
|
+
await app.listen({ port, hostname })
|
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
"test": "bun test"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@guren/cli": "^2.
|
|
22
|
-
"@guren/core": "^1.
|
|
23
|
-
"@guren/orm": "^2.
|
|
21
|
+
"@guren/cli": "^2.4.0",
|
|
22
|
+
"@guren/core": "^1.6.0",
|
|
23
|
+
"@guren/orm": "^2.3.0",
|
|
24
24
|
"drizzle-orm": "1.0.0-rc.4"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@guren/testing": "^1.
|
|
27
|
+
"@guren/testing": "^1.5.0",
|
|
28
28
|
"bun-types": "^1.3.1",
|
|
29
29
|
"drizzle-kit": "1.0.0-rc.4",
|
|
30
30
|
"typescript": "^5.4.0"
|
|
@@ -7,8 +7,8 @@ export const LoginSchema = z.object({
|
|
|
7
7
|
.string()
|
|
8
8
|
.trim()
|
|
9
9
|
.min(1, 'Email is required.')
|
|
10
|
-
.
|
|
11
|
-
.
|
|
10
|
+
.toLowerCase()
|
|
11
|
+
.pipe(z.email('The email address is badly formatted.')),
|
|
12
12
|
password: z
|
|
13
13
|
.string()
|
|
14
14
|
.min(1, 'Password is required.'),
|
|
@@ -10,8 +10,8 @@ export const ProfileUpdateSchema = z.object({
|
|
|
10
10
|
.string()
|
|
11
11
|
.trim()
|
|
12
12
|
.min(1, 'Email is required.')
|
|
13
|
-
.
|
|
14
|
-
.
|
|
13
|
+
.toLowerCase()
|
|
14
|
+
.pipe(z.email('Enter a valid email address.')),
|
|
15
15
|
password: z
|
|
16
16
|
.string()
|
|
17
17
|
.trim()
|
|
@@ -14,8 +14,8 @@ export const RegisterSchema = z
|
|
|
14
14
|
.string()
|
|
15
15
|
.trim()
|
|
16
16
|
.min(1, 'Email is required.')
|
|
17
|
-
.
|
|
18
|
-
.
|
|
17
|
+
.toLowerCase()
|
|
18
|
+
.pipe(z.email('The email address is badly formatted.')),
|
|
19
19
|
password: z
|
|
20
20
|
.string()
|
|
21
21
|
.min(8, 'Password must be at least 8 characters.'),
|
|
@@ -9,16 +9,14 @@ export class User extends defineModel(users, {
|
|
|
9
9
|
// Derived from the plain `password`, so callers never set it directly
|
|
10
10
|
optionalOnCreate: ['passwordHash'],
|
|
11
11
|
requireOnCreate: ['password'],
|
|
12
|
-
}) {
|
|
13
12
|
// passwordHash and rememberToken are denied from mass assignment by
|
|
14
13
|
// AuthenticatableModel itself. `name` and `email` are the only remaining
|
|
15
14
|
// columns, so this fillable list matches what would be mass-assignable
|
|
16
15
|
// anyway — it stays explicit so a later column addition needs an opt-in.
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
fillable: ['name', 'email', 'password'],
|
|
19
17
|
// Never serialized by Model.serialize() and stripped from auth.user()
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
hidden: ['passwordHash', 'rememberToken'],
|
|
19
|
+
}) {
|
|
22
20
|
static override relationTypes: { posts: HasManyRecord<PostRecord> } = {
|
|
23
21
|
posts: [],
|
|
24
22
|
}
|
|
@@ -9,41 +9,11 @@ try {
|
|
|
9
9
|
|
|
10
10
|
// `PORT=0` means "any free port", so this tests for a number, not truthiness.
|
|
11
11
|
const parsedPort = Number.parseInt(process.env.PORT ?? '', 10)
|
|
12
|
-
const
|
|
12
|
+
const port = Number.isInteger(parsedPort) ? parsedPort : 3333
|
|
13
13
|
const hostname = process.env.HOST ?? '0.0.0.0'
|
|
14
14
|
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const attempts = canWalkPorts ? 20 : 1
|
|
21
|
-
|
|
22
|
-
// This file owns the retry, so the framework must not retry underneath it —
|
|
23
|
-
// newer framework versions walk inside listen() themselves, and the two loops
|
|
24
|
-
// would nest into a much wider search reported against the wrong ports.
|
|
25
|
-
process.env.GUREN_STRICT_PORT = '1'
|
|
26
|
-
|
|
27
|
-
for (let offset = 0; offset < attempts; offset += 1) {
|
|
28
|
-
const port = requestedPort + offset
|
|
29
|
-
|
|
30
|
-
try {
|
|
31
|
-
await app.listen({ port, hostname })
|
|
32
|
-
break
|
|
33
|
-
} catch (error) {
|
|
34
|
-
if (!isAddressInUse(error) || offset === attempts - 1) {
|
|
35
|
-
throw error
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
console.warn(`Port ${port} is in use, trying ${port + 1}...`)
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function isAddressInUse(error: unknown): boolean {
|
|
43
|
-
return Boolean(
|
|
44
|
-
error &&
|
|
45
|
-
typeof error === 'object' &&
|
|
46
|
-
'code' in error &&
|
|
47
|
-
(error as { code?: unknown }).code === 'EADDRINUSE',
|
|
48
|
-
)
|
|
49
|
-
}
|
|
15
|
+
// The walk past a busy port lives in listen() now, which is also the only
|
|
16
|
+
// place that can report which port it ended up on. Set GUREN_STRICT_PORT=1 to
|
|
17
|
+
// fail fast instead — what an automated consumer wants when it has to know
|
|
18
|
+
// the app under test is the one answering.
|
|
19
|
+
await app.listen({ port, hostname })
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
"db:seed": "bunx guren db:seed"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@guren/cli": "^2.
|
|
23
|
-
"@guren/core": "^1.
|
|
22
|
+
"@guren/cli": "^2.4.0",
|
|
23
|
+
"@guren/core": "^1.6.0",
|
|
24
24
|
"@guren/inertia-client": "^1.1.0",
|
|
25
|
-
"@guren/orm": "^2.
|
|
25
|
+
"@guren/orm": "^2.3.0",
|
|
26
26
|
"@inertiajs/react": "^3.6.1",
|
|
27
27
|
"drizzle-orm": "1.0.0-rc.4",
|
|
28
28
|
"react": "^19.0.0",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"zod": "^4.4.3"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@guren/testing": "^1.
|
|
33
|
+
"@guren/testing": "^1.5.0",
|
|
34
34
|
"@tailwindcss/vite": "^4.2.2",
|
|
35
35
|
"@types/react": "^19.0.0",
|
|
36
36
|
"@types/react-dom": "^19.0.0",
|