spfn 0.2.0-beta.52 → 0.2.0-beta.56
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/README.md +49 -7
- package/bin/spfn.js +10 -3
- package/dist/index.js +1763 -692
- package/dist/templates/README.md +81 -0
- package/package.json +19 -12
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# {{projectName}}
|
|
2
|
+
|
|
3
|
+
A full-stack app built with [SPFN](https://github.com/spfn/spfn) — a typed SPFN
|
|
4
|
+
backend running alongside Next.js.
|
|
5
|
+
|
|
6
|
+
## Getting started
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
# 1. Start PostgreSQL + Redis
|
|
10
|
+
docker compose up -d
|
|
11
|
+
|
|
12
|
+
# 2. The env files are generated for you:
|
|
13
|
+
# .env.local — Next.js-facing values (gitignored)
|
|
14
|
+
# .env.server — server secrets: DB, cache (gitignored, never loaded by Next.js)
|
|
15
|
+
# Review them and adjust as needed.
|
|
16
|
+
|
|
17
|
+
# 3. Start the dev server (Next.js :3790 + SPFN API :8790)
|
|
18
|
+
{{pmRun}} spfn:dev
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Then open:
|
|
22
|
+
|
|
23
|
+
- Next.js — http://localhost:3790
|
|
24
|
+
- API health — http://localhost:8790/health
|
|
25
|
+
|
|
26
|
+
## Project structure
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
src/
|
|
30
|
+
app/ Next.js App Router
|
|
31
|
+
server/ SPFN backend (entities, repositories, routes, router)
|
|
32
|
+
generated/ codegen output (route map) — do not edit by hand
|
|
33
|
+
.env.local Next.js-facing env (gitignored)
|
|
34
|
+
.env.server server secrets (gitignored)
|
|
35
|
+
.env.example committed reference — keys only, placeholder values
|
|
36
|
+
.spfnrc.ts codegen configuration
|
|
37
|
+
spfn.config.js deployment config
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
A feature is a vertical slice: `Entity` (Drizzle table) → `Repository` →
|
|
41
|
+
`Route` (TypeBox validation) → `Router` → `{{pmRun}} codegen` → typed client.
|
|
42
|
+
|
|
43
|
+
## Common commands
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
{{pmRun}} spfn:dev # dev: Next.js + SPFN API (add --watch to restart on changes)
|
|
47
|
+
{{pmRun}} spfn:build # production build
|
|
48
|
+
{{pmRun}} spfn:start # run the production build
|
|
49
|
+
{{pm}} spfn db generate # create a migration from schema changes
|
|
50
|
+
{{pm}} spfn db migrate # apply pending migrations
|
|
51
|
+
{{pm}} spfn env check # check .env files against the schema
|
|
52
|
+
{{pm}} spfn secret set DB_URL # store a secret (keychain locally, SOPS for deploys)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Environment & secrets
|
|
56
|
+
|
|
57
|
+
`.env.server` holds server-only secrets and is gitignored — Next.js never loads it.
|
|
58
|
+
For a managed workflow use `spfn secret`: local values go to the OS keychain (only a
|
|
59
|
+
`secret:keychain:` reference lands in `.env.server`), and deployed secrets are stored
|
|
60
|
+
in encrypted SOPS files. See the [SPFN CLI docs](https://github.com/spfn/spfn).
|
|
61
|
+
|
|
62
|
+
<!-- {{#auth}} -->
|
|
63
|
+
## Authentication
|
|
64
|
+
|
|
65
|
+
This project includes `@spfn/auth`. Configure providers and session settings in your
|
|
66
|
+
server setup, and read `@spfn/auth`'s README for the full Entity → Repository →
|
|
67
|
+
Service → Route flow and the typed `authApi` client.
|
|
68
|
+
<!-- {{/auth}} -->
|
|
69
|
+
|
|
70
|
+
## Deployment
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# Build + run locally
|
|
74
|
+
{{pmRun}} spfn:build && {{pmRun}} spfn:start
|
|
75
|
+
|
|
76
|
+
# Or with Docker
|
|
77
|
+
docker compose -f docker-compose.production.yml up --build -d
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Never commit real secrets. `.env.server` is gitignored; inject secrets in your
|
|
81
|
+
CI/CD pipeline or via `spfn secret` + your GitOps decryption step.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spfn",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.56",
|
|
4
4
|
"description": "Superfunction CLI - Add SPFN to your Next.js project",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -11,6 +11,15 @@
|
|
|
11
11
|
"dist",
|
|
12
12
|
"bin"
|
|
13
13
|
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsup && node scripts/copy-templates.js",
|
|
16
|
+
"prepack": "node -e \"require('fs').copyFileSync('../../LICENSE','LICENSE')\"",
|
|
17
|
+
"dev": "tsup --watch",
|
|
18
|
+
"type-check": "tsc --noEmit",
|
|
19
|
+
"publish:alpha": "npm publish --access public --tag alpha",
|
|
20
|
+
"publish:beta": "npm publish --access public --tag beta",
|
|
21
|
+
"publish:latest": "npm publish --access public"
|
|
22
|
+
},
|
|
14
23
|
"keywords": [
|
|
15
24
|
"spfn",
|
|
16
25
|
"cli",
|
|
@@ -36,8 +45,7 @@
|
|
|
36
45
|
},
|
|
37
46
|
"publishConfig": {
|
|
38
47
|
"access": "public",
|
|
39
|
-
"tag": "
|
|
40
|
-
"registry": "https://registry.npmjs.org"
|
|
48
|
+
"tag": "beta"
|
|
41
49
|
},
|
|
42
50
|
"bugs": {
|
|
43
51
|
"url": "https://github.com/spfn/spfn/issues"
|
|
@@ -68,21 +76,20 @@
|
|
|
68
76
|
"pg": "^8.16.3",
|
|
69
77
|
"postgres": "^3.4.0",
|
|
70
78
|
"prompts": "^2.4.2",
|
|
71
|
-
"tsup": "^8.5.0"
|
|
79
|
+
"tsup": "^8.5.0",
|
|
80
|
+
"yaml": "^2.5.0"
|
|
81
|
+
},
|
|
82
|
+
"optionalDependencies": {
|
|
83
|
+
"@napi-rs/keyring": "^1.1.0"
|
|
72
84
|
},
|
|
73
85
|
"devDependencies": {
|
|
86
|
+
"@spfn/core": "workspace:*",
|
|
74
87
|
"@types/fs-extra": "^11.0.4",
|
|
75
88
|
"@types/node": "^20.11.0",
|
|
76
89
|
"@types/pg": "^8.10.9",
|
|
77
90
|
"@types/prompts": "^2.4.9",
|
|
78
91
|
"concurrently": "^9.2.1",
|
|
79
92
|
"tsx": "^4.20.6",
|
|
80
|
-
"typescript": "^5.3.3"
|
|
81
|
-
"@spfn/core": "0.2.0-beta.56"
|
|
82
|
-
},
|
|
83
|
-
"scripts": {
|
|
84
|
-
"build": "tsup && node scripts/copy-templates.js",
|
|
85
|
-
"dev": "tsup --watch",
|
|
86
|
-
"type-check": "tsc --noEmit"
|
|
93
|
+
"typescript": "^5.3.3"
|
|
87
94
|
}
|
|
88
|
-
}
|
|
95
|
+
}
|