@farm.js/create-app 0.1.51-beta.2 → 0.1.60
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/_renderers/preact/package.json +4 -4
- package/templates/_renderers/solid/package.json +4 -4
- package/templates/_renderers/svelte/package.json +4 -4
- package/templates/_renderers/vue/package.json +4 -4
- package/templates/auth/package.json +7 -7
- package/templates/basic/package.json +6 -6
- package/templates/better-auth/.env.example +2 -1
- package/templates/better-auth/README.md +7 -1
- package/templates/better-auth/package.json +7 -7
- package/templates/better-auth/src/lib/auth.ts +28 -4
- package/templates/react-compiler/package.json +7 -7
package/package.json
CHANGED
|
@@ -11,16 +11,16 @@
|
|
|
11
11
|
"type-check": "tsc --noEmit"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@farm.js/core": "0.1.
|
|
15
|
-
"@farm.js/preact": "0.1.0-beta.
|
|
14
|
+
"@farm.js/core": "0.1.60",
|
|
15
|
+
"@farm.js/preact": "0.1.0-beta.37",
|
|
16
16
|
"@fontsource-variable/geist": "5.3.0",
|
|
17
17
|
"@fontsource-variable/geist-mono": "5.3.0",
|
|
18
18
|
"preact": "10.29.8",
|
|
19
19
|
"zod": "4.6.7"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@farm.js/cli": "0.1.
|
|
23
|
-
"@farm.js/devtools": "0.1.
|
|
22
|
+
"@farm.js/cli": "0.1.60",
|
|
23
|
+
"@farm.js/devtools": "0.1.60",
|
|
24
24
|
"@tailwindcss/vite": "^4.3.3",
|
|
25
25
|
"tailwindcss": "^4.0.0",
|
|
26
26
|
"typescript": "^5.3.3"
|
|
@@ -10,16 +10,16 @@
|
|
|
10
10
|
"type-check": "tsc --noEmit"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@farm.js/core": "0.1.
|
|
14
|
-
"@farm.js/solid": "0.1.0-beta.
|
|
13
|
+
"@farm.js/core": "0.1.60",
|
|
14
|
+
"@farm.js/solid": "0.1.0-beta.34",
|
|
15
15
|
"@fontsource-variable/geist": "5.3.0",
|
|
16
16
|
"@fontsource-variable/geist-mono": "5.3.0",
|
|
17
17
|
"solid-js": "1.9.18",
|
|
18
18
|
"zod": "4.6.7"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@farm.js/cli": "0.1.
|
|
22
|
-
"@farm.js/devtools": "0.1.
|
|
21
|
+
"@farm.js/cli": "0.1.60",
|
|
22
|
+
"@farm.js/devtools": "0.1.60",
|
|
23
23
|
"@tailwindcss/vite": "^4.3.3",
|
|
24
24
|
"tailwindcss": "^4.0.0",
|
|
25
25
|
"typescript": "^5.3.3"
|
|
@@ -11,16 +11,16 @@
|
|
|
11
11
|
"type-check": "svelte-check --tsconfig ./tsconfig.json"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@farm.js/core": "0.1.
|
|
15
|
-
"@farm.js/svelte": "0.1.0-beta.
|
|
14
|
+
"@farm.js/core": "0.1.60",
|
|
15
|
+
"@farm.js/svelte": "0.1.0-beta.36",
|
|
16
16
|
"@fontsource-variable/geist": "5.3.0",
|
|
17
17
|
"@fontsource-variable/geist-mono": "5.3.0",
|
|
18
18
|
"svelte": "5.56.8",
|
|
19
19
|
"zod": "4.6.7"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@farm.js/cli": "0.1.
|
|
23
|
-
"@farm.js/devtools": "0.1.
|
|
22
|
+
"@farm.js/cli": "0.1.60",
|
|
23
|
+
"@farm.js/devtools": "0.1.60",
|
|
24
24
|
"@tailwindcss/vite": "^4.3.3",
|
|
25
25
|
"svelte-check": "4.7.5",
|
|
26
26
|
"tailwindcss": "^4.0.0",
|
|
@@ -10,16 +10,16 @@
|
|
|
10
10
|
"type-check": "vue-tsc --noEmit"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@farm.js/core": "0.1.
|
|
14
|
-
"@farm.js/vue": "0.1.0-beta.
|
|
13
|
+
"@farm.js/core": "0.1.60",
|
|
14
|
+
"@farm.js/vue": "0.1.0-beta.34",
|
|
15
15
|
"@fontsource-variable/geist": "5.3.0",
|
|
16
16
|
"@fontsource-variable/geist-mono": "5.3.0",
|
|
17
17
|
"vue": "3.5.44",
|
|
18
18
|
"zod": "4.6.7"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@farm.js/cli": "0.1.
|
|
22
|
-
"@farm.js/devtools": "0.1.
|
|
21
|
+
"@farm.js/cli": "0.1.60",
|
|
22
|
+
"@farm.js/devtools": "0.1.60",
|
|
23
23
|
"@tailwindcss/vite": "^4.3.3",
|
|
24
24
|
"tailwindcss": "^4.0.0",
|
|
25
25
|
"typescript": "^5.3.3",
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
"type-check": "tsc --noEmit"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@farm.js/auth": "0.1.
|
|
16
|
-
"@farm.js/core": "0.1.
|
|
17
|
-
"@farming-labs/docs": "0.2.
|
|
18
|
-
"@farming-labs/farmjs": "0.2.
|
|
19
|
-
"@farming-labs/theme": "0.2.
|
|
15
|
+
"@farm.js/auth": "0.1.60",
|
|
16
|
+
"@farm.js/core": "0.1.60",
|
|
17
|
+
"@farming-labs/docs": "0.2.143",
|
|
18
|
+
"@farming-labs/farmjs": "0.2.143",
|
|
19
|
+
"@farming-labs/theme": "0.2.143",
|
|
20
20
|
"@fontsource-variable/geist": "5.3.0",
|
|
21
21
|
"@fontsource-variable/geist-mono": "5.3.0",
|
|
22
22
|
"better-call": "1.3.2",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"react-dom": "^19.0.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@farm.js/cli": "0.1.
|
|
28
|
-
"@farm.js/devtools": "0.1.
|
|
27
|
+
"@farm.js/cli": "0.1.60",
|
|
28
|
+
"@farm.js/devtools": "0.1.60",
|
|
29
29
|
"@tailwindcss/vite": "^4.3.3",
|
|
30
30
|
"@types/node": "22.20.1",
|
|
31
31
|
"@types/react": "^19.0.0",
|
|
@@ -10,18 +10,18 @@
|
|
|
10
10
|
"type-check": "tsc --noEmit"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@farm.js/core": "0.1.
|
|
14
|
-
"@farming-labs/docs": "0.2.
|
|
15
|
-
"@farming-labs/farmjs": "0.2.
|
|
16
|
-
"@farming-labs/theme": "0.2.
|
|
13
|
+
"@farm.js/core": "0.1.60",
|
|
14
|
+
"@farming-labs/docs": "0.2.143",
|
|
15
|
+
"@farming-labs/farmjs": "0.2.143",
|
|
16
|
+
"@farming-labs/theme": "0.2.143",
|
|
17
17
|
"@fontsource-variable/geist": "5.3.0",
|
|
18
18
|
"@fontsource-variable/geist-mono": "5.3.0",
|
|
19
19
|
"react": "^19.0.0",
|
|
20
20
|
"react-dom": "^19.0.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@farm.js/cli": "0.1.
|
|
24
|
-
"@farm.js/devtools": "0.1.
|
|
23
|
+
"@farm.js/cli": "0.1.60",
|
|
24
|
+
"@farm.js/devtools": "0.1.60",
|
|
25
25
|
"@tailwindcss/vite": "^4.3.3",
|
|
26
26
|
"@types/react": "^19.0.0",
|
|
27
27
|
"@types/react-dom": "^19.0.0",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
# Required in production. Leave unset in development to sign in from any dev port or device.
|
|
2
|
+
# BETTER_AUTH_URL=https://app.example.com
|
|
2
3
|
# Generate with: openssl rand -base64 32
|
|
3
4
|
BETTER_AUTH_SECRET=
|
|
4
5
|
DATABASE_URL=postgresql://user:password@your-neon-pooler-host/database?sslmode=require
|
|
@@ -62,10 +62,16 @@ FARMJS owns the catch-all integration route, so the starter does not need a manu
|
|
|
62
62
|
|
|
63
63
|
| Variable | Purpose |
|
|
64
64
|
| -------------------- | ----------------------------------------- |
|
|
65
|
-
| `BETTER_AUTH_URL` | Public origin
|
|
65
|
+
| `BETTER_AUTH_URL` | Public origin, required in production |
|
|
66
66
|
| `BETTER_AUTH_SECRET` | Secret used to sign and encrypt auth data |
|
|
67
67
|
| `DATABASE_URL` | Pooled Postgres connection string |
|
|
68
68
|
|
|
69
|
+
Without `BETTER_AUTH_URL`, `farm dev` trusts the origin it is serving the request on when the host
|
|
70
|
+
is `localhost`, `*.localhost`, or an IP address, so another port, the Android emulator's
|
|
71
|
+
`http://10.0.2.2:<port>`, and LAN devices under `farm dev --host` can sign in. A page on another
|
|
72
|
+
origin is still rejected. Set `BETTER_AUTH_URL` for a custom dev hostname; production trusts only
|
|
73
|
+
that origin.
|
|
74
|
+
|
|
69
75
|
Never commit `.env.local` or expose the database connection string.
|
|
70
76
|
|
|
71
77
|
## Deployment note
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
"type-check": "tsc --noEmit"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@farm.js/better-auth": "0.1.
|
|
16
|
-
"@farm.js/core": "0.1.
|
|
17
|
-
"@farming-labs/docs": "0.2.
|
|
18
|
-
"@farming-labs/farmjs": "0.2.
|
|
19
|
-
"@farming-labs/theme": "0.2.
|
|
15
|
+
"@farm.js/better-auth": "0.1.60",
|
|
16
|
+
"@farm.js/core": "0.1.60",
|
|
17
|
+
"@farming-labs/docs": "0.2.143",
|
|
18
|
+
"@farming-labs/farmjs": "0.2.143",
|
|
19
|
+
"@farming-labs/theme": "0.2.143",
|
|
20
20
|
"@fontsource-variable/geist": "5.3.0",
|
|
21
21
|
"@fontsource-variable/geist-mono": "5.3.0",
|
|
22
22
|
"better-auth": "1.7.14",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"react-dom": "^19.0.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@farm.js/cli": "0.1.
|
|
30
|
-
"@farm.js/devtools": "0.1.
|
|
29
|
+
"@farm.js/cli": "0.1.60",
|
|
30
|
+
"@farm.js/devtools": "0.1.60",
|
|
31
31
|
"@tailwindcss/vite": "^4.3.3",
|
|
32
32
|
"@types/node": "22.20.1",
|
|
33
33
|
"@types/pg": "8.20.0",
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
+
import { isIP } from "node:net";
|
|
1
2
|
import { betterAuth } from "better-auth";
|
|
2
3
|
import { Pool, type PoolConfig } from "pg";
|
|
3
4
|
|
|
4
|
-
const
|
|
5
|
+
const isProduction = process.env.NODE_ENV === "production";
|
|
6
|
+
const authBaseUrl = process.env.BETTER_AUTH_URL;
|
|
5
7
|
const databaseUrl = process.env.DATABASE_URL;
|
|
6
8
|
const secret = process.env.BETTER_AUTH_SECRET;
|
|
7
9
|
|
|
10
|
+
if (isProduction && !authBaseUrl) {
|
|
11
|
+
throw new Error(
|
|
12
|
+
"BETTER_AUTH_URL is required in production. Set it to the app's public origin, such as https://app.example.com.",
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
|
|
8
16
|
if (!databaseUrl) {
|
|
9
17
|
throw new Error("DATABASE_URL is required. Add your pooled Postgres connection string.");
|
|
10
18
|
}
|
|
@@ -25,7 +33,7 @@ if (databaseConnection.searchParams.get("sslmode") === "require") {
|
|
|
25
33
|
const poolConfig: PoolConfig & { enableChannelBinding: boolean } = {
|
|
26
34
|
connectionString: databaseConnection.toString(),
|
|
27
35
|
enableChannelBinding,
|
|
28
|
-
max:
|
|
36
|
+
max: isProduction ? 5 : 2,
|
|
29
37
|
idleTimeoutMillis: 30_000,
|
|
30
38
|
connectionTimeoutMillis: 10_000,
|
|
31
39
|
allowExitOnIdle: true,
|
|
@@ -33,14 +41,30 @@ const poolConfig: PoolConfig & { enableChannelBinding: boolean } = {
|
|
|
33
41
|
|
|
34
42
|
export const authDatabase = new Pool(poolConfig);
|
|
35
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Without BETTER_AUTH_URL, `farm dev` trusts the origin it is serving the
|
|
46
|
+
* request on, so another port, the Android emulator's 10.0.2.2, or a LAN
|
|
47
|
+
* device under `farm dev --host` can sign in. Only localhost, *.localhost, and
|
|
48
|
+
* IP addresses qualify, so a DNS-rebinding hostname is never trusted, and a
|
|
49
|
+
* page on another origin is still rejected.
|
|
50
|
+
*/
|
|
51
|
+
export function devServerOrigin(request?: Request): string[] {
|
|
52
|
+
if (!request) return [];
|
|
53
|
+
const url = new URL(request.url);
|
|
54
|
+
const hostname = url.hostname.replace(/^\[|\]$/g, "");
|
|
55
|
+
const local = hostname === "localhost" || hostname.endsWith(".localhost") || isIP(hostname) !== 0;
|
|
56
|
+
return local ? [url.origin] : [];
|
|
57
|
+
}
|
|
58
|
+
|
|
36
59
|
export const auth = betterAuth({
|
|
37
60
|
appName: "FARMJS Better Auth Starter",
|
|
38
|
-
|
|
61
|
+
// Development without BETTER_AUTH_URL uses the port farm.config.ts pins.
|
|
62
|
+
baseURL: authBaseUrl ?? "http://localhost:3000",
|
|
39
63
|
database: authDatabase,
|
|
40
64
|
emailAndPassword: {
|
|
41
65
|
enabled: true,
|
|
42
66
|
minPasswordLength: 8,
|
|
43
67
|
},
|
|
44
68
|
secret,
|
|
45
|
-
trustedOrigins: [new URL(authBaseUrl).origin],
|
|
69
|
+
trustedOrigins: authBaseUrl ? [new URL(authBaseUrl).origin] : devServerOrigin,
|
|
46
70
|
});
|
|
@@ -11,19 +11,19 @@
|
|
|
11
11
|
"type-check": "tsc --noEmit"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@farm.js/core": "0.1.
|
|
15
|
-
"@farm.js/react": "0.1.0-beta.
|
|
16
|
-
"@farming-labs/docs": "0.2.
|
|
17
|
-
"@farming-labs/farmjs": "0.2.
|
|
18
|
-
"@farming-labs/theme": "0.2.
|
|
14
|
+
"@farm.js/core": "0.1.60",
|
|
15
|
+
"@farm.js/react": "0.1.0-beta.37",
|
|
16
|
+
"@farming-labs/docs": "0.2.143",
|
|
17
|
+
"@farming-labs/farmjs": "0.2.143",
|
|
18
|
+
"@farming-labs/theme": "0.2.143",
|
|
19
19
|
"@fontsource-variable/geist": "5.3.0",
|
|
20
20
|
"@fontsource-variable/geist-mono": "5.3.0",
|
|
21
21
|
"react": "19.2.8",
|
|
22
22
|
"react-dom": "19.2.8"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@farm.js/cli": "0.1.
|
|
26
|
-
"@farm.js/devtools": "0.1.
|
|
25
|
+
"@farm.js/cli": "0.1.60",
|
|
26
|
+
"@farm.js/devtools": "0.1.60",
|
|
27
27
|
"@playwright/test": "^1.52.0",
|
|
28
28
|
"@tailwindcss/vite": "^4.3.3",
|
|
29
29
|
"@types/node": "22.20.1",
|