hostinger-api-mcp 4.2.1 → 4.4.0
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/CHANGELOG.md +13 -0
- package/gemini-extension.json +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
- package/skills/headless/SKILL.md +14 -7
- package/skills/headless/VERSION +3 -3
- package/skills/headless/run-log.mjs +3 -5
- package/skills/headless/steps/01-check-state/SKILL.md +16 -5
- package/skills/headless/steps/02-refine/SKILL.md +56 -29
- package/skills/headless/steps/03-provision/SKILL.md +20 -25
- package/skills/headless/steps/03-provision/pocketbase/SKILL.md +190 -0
- package/skills/headless/steps/04-content-model/SKILL.md +12 -12
- package/skills/headless/steps/04-content-model/pocketbase/SKILL.md +90 -0
- package/skills/headless/steps/04-content-model/pocketbase/auth.md +52 -0
- package/skills/headless/steps/04-content-model/pocketbase/frontend.md +130 -0
- package/skills/headless/steps/04-content-model/pocketbase/patterns.md +286 -0
- package/skills/headless/steps/04-content-model/pocketbase/rules.md +66 -0
- package/skills/headless/steps/04-content-model/pocketbase/schema.example.json +65 -0
- package/skills/headless/steps/04-content-model/pocketbase/schema.md +78 -0
- package/skills/headless/steps/04-content-model/pocketbase/scripts/pb-apply-schema.mjs +245 -0
- package/skills/headless/steps/04-content-model/pocketbase/scripts/pb-lib.mjs +120 -0
- package/skills/headless/steps/04-content-model/pocketbase/scripts/pb-verify.mjs +127 -0
- package/skills/headless/steps/04-content-model/pocketbase/troubleshooting.md +55 -0
- package/skills/headless/steps/06-frontend/SKILL.md +32 -33
- package/skills/headless/steps/07-validate/SKILL.md +8 -2
- package/skills/headless/steps/08-deploy/SKILL.md +32 -17
- package/skills/headless/steps/09-done/SKILL.md +20 -3
- package/skills/headless/wait.mjs +19 -9
- package/src/core/runtime.js +1 -1
- package/src/core/runtime.ts +1 -1
- package/src/core/skills.js +114 -37
- package/src/core/skills.ts +114 -37
- package/src/servers/agency-hosting.js +1 -1
- package/src/servers/agency-hosting.ts +1 -1
- package/src/servers/agent-readiness.js +1 -1
- package/src/servers/agent-readiness.ts +1 -1
- package/src/servers/all.js +1 -1
- package/src/servers/all.ts +1 -1
- package/src/servers/billing.js +1 -1
- package/src/servers/billing.ts +1 -1
- package/src/servers/dns.js +1 -1
- package/src/servers/dns.ts +1 -1
- package/src/servers/domains.js +1 -1
- package/src/servers/domains.ts +1 -1
- package/src/servers/ecommerce.js +1 -1
- package/src/servers/ecommerce.ts +1 -1
- package/src/servers/gpu.js +1 -1
- package/src/servers/gpu.ts +1 -1
- package/src/servers/horizons.js +1 -1
- package/src/servers/horizons.ts +1 -1
- package/src/servers/hosting.js +1 -1
- package/src/servers/hosting.ts +1 -1
- package/src/servers/mail.js +1 -1
- package/src/servers/mail.ts +1 -1
- package/src/servers/reach.js +1 -1
- package/src/servers/reach.ts +1 -1
- package/src/servers/vps.js +1 -1
- package/src/servers/vps.ts +1 -1
- package/src/servers/wordpress.js +1 -1
- package/src/servers/wordpress.ts +1 -1
- package/skills/headless/steps/03-provision/webapp/SKILL.md +0 -164
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import {
|
|
2
|
+
baseUrlFrom,
|
|
3
|
+
describeError,
|
|
4
|
+
fail,
|
|
5
|
+
listCollections,
|
|
6
|
+
mergeRateLimitRules,
|
|
7
|
+
readCredentials,
|
|
8
|
+
readJson,
|
|
9
|
+
request,
|
|
10
|
+
superuserToken,
|
|
11
|
+
wakeUp,
|
|
12
|
+
} from "./pb-lib.mjs"
|
|
13
|
+
|
|
14
|
+
const args = process.argv.slice(2)
|
|
15
|
+
const checkOnly = args.includes("--check")
|
|
16
|
+
const [schemaPath, credsPath] = args.filter((arg) => arg !== "--check")
|
|
17
|
+
if (!schemaPath || (!credsPath && !checkOnly)) {
|
|
18
|
+
fail("Usage: node pb-apply-schema.mjs <schema.json> <credentials.json> or node pb-apply-schema.mjs --check <schema.json>")
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const RULE_KEYS = {
|
|
22
|
+
list: "listRule",
|
|
23
|
+
view: "viewRule",
|
|
24
|
+
create: "createRule",
|
|
25
|
+
update: "updateRule",
|
|
26
|
+
delete: "deleteRule",
|
|
27
|
+
auth: "authRule",
|
|
28
|
+
manage: "manageRule",
|
|
29
|
+
}
|
|
30
|
+
const AUTH_ONLY_RULE_KEYS = new Set(["auth", "manage"])
|
|
31
|
+
const COLLECTION_KEYS = new Set(["name", "type", "rules", "fields", "indexes", "authOptions", "timestamps", "viewQuery", "seed"])
|
|
32
|
+
const COLLECTION_TYPES = new Set(["base", "auth", "view"])
|
|
33
|
+
const FIELD_TYPES = new Set(["text", "editor", "number", "bool", "email", "url", "date", "autodate", "select", "file", "relation", "json", "geoPoint"])
|
|
34
|
+
const INDEX_NAME = /INDEX\s+(?:IF\s+NOT\s+EXISTS\s+)?[`"]?(\w+)[`"]?/i
|
|
35
|
+
const TIMESTAMPS = [
|
|
36
|
+
{ name: "created", type: "autodate", onCreate: true, onUpdate: false },
|
|
37
|
+
{ name: "updated", type: "autodate", onCreate: true, onUpdate: true },
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
const schema = readJson(schemaPath)
|
|
41
|
+
const wanted = Array.isArray(schema.collections) ? schema.collections : fail('schema.json needs a top-level "collections" array')
|
|
42
|
+
validateSchema()
|
|
43
|
+
if (checkOnly) {
|
|
44
|
+
console.log(`OK ${schemaPath} is valid (${wanted.length} collections). Relation targets outside the file are checked when applied.`)
|
|
45
|
+
process.exit(0)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const creds = readCredentials(credsPath)
|
|
49
|
+
const base = baseUrlFrom(creds)
|
|
50
|
+
await wakeUp(base)
|
|
51
|
+
const token = await superuserToken(base, creds)
|
|
52
|
+
|
|
53
|
+
const isView = (collection) => (collection.type ?? "base") === "view"
|
|
54
|
+
let collections = await listCollections(base, token)
|
|
55
|
+
await createMissingCollections(wanted.filter((collection) => !isView(collection)))
|
|
56
|
+
collections = await listCollections(base, token)
|
|
57
|
+
await updateFieldsAndIndexes(wanted.filter((collection) => !isView(collection)))
|
|
58
|
+
await createMissingCollections(wanted.filter(isView))
|
|
59
|
+
collections = await listCollections(base, token)
|
|
60
|
+
await updateFieldsAndIndexes(wanted.filter(isView))
|
|
61
|
+
await applyRules()
|
|
62
|
+
await applyRateLimits()
|
|
63
|
+
await seedEmptyCollections()
|
|
64
|
+
console.log(`DONE schema applied to ${base}`)
|
|
65
|
+
|
|
66
|
+
function validateSchema() {
|
|
67
|
+
const problems = []
|
|
68
|
+
const names = new Set()
|
|
69
|
+
for (const collection of wanted) {
|
|
70
|
+
const label = collection.name ?? "(unnamed)"
|
|
71
|
+
if (!collection.name || !/^[a-z_][a-z0-9_]*$/i.test(collection.name)) problems.push(`invalid collection name "${collection.name}"`)
|
|
72
|
+
if (names.has(collection.name)) problems.push(`${label}: listed twice`)
|
|
73
|
+
names.add(collection.name)
|
|
74
|
+
for (const key of Object.keys(collection)) {
|
|
75
|
+
if (!COLLECTION_KEYS.has(key)) problems.push(`${label}: unknown key "${key}" (allowed: ${[...COLLECTION_KEYS].join(", ")})`)
|
|
76
|
+
}
|
|
77
|
+
const type = collection.type ?? "base"
|
|
78
|
+
if (!COLLECTION_TYPES.has(type)) problems.push(`${label}: type must be base, auth or view`)
|
|
79
|
+
if (type === "view" && !collection.viewQuery) problems.push(`${label}: view collections need "viewQuery"`)
|
|
80
|
+
if (type !== "view" && collection.viewQuery) problems.push(`${label}: "viewQuery" only applies to type "view"`)
|
|
81
|
+
for (const key of Object.keys(collection.rules ?? {})) {
|
|
82
|
+
if (!(key in RULE_KEYS)) problems.push(`${label}: unknown rule "${key}" (allowed: ${Object.keys(RULE_KEYS).join(", ")})`)
|
|
83
|
+
if (AUTH_ONLY_RULE_KEYS.has(key) && type !== "auth") problems.push(`${label}: rule "${key}" only applies to auth collections`)
|
|
84
|
+
const value = collection.rules[key]
|
|
85
|
+
if (value !== null && typeof value !== "string") problems.push(`${label}: rule "${key}" must be a string or null`)
|
|
86
|
+
}
|
|
87
|
+
if (type === "view" && collection.rules) {
|
|
88
|
+
for (const key of ["create", "update", "delete"]) {
|
|
89
|
+
if (key in collection.rules) problems.push(`${label}: view collections are read-only; remove the "${key}" rule`)
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
for (const field of collection.fields ?? []) {
|
|
93
|
+
if (!field.name) problems.push(`${label}: a field has no name`)
|
|
94
|
+
if (!FIELD_TYPES.has(field.type)) problems.push(`${label}.${field.name}: unknown field type "${field.type}"`)
|
|
95
|
+
if (field.type === "relation" && !field.collection) problems.push(`${label}.${field.name}: relation fields need "collection" (the target collection name)`)
|
|
96
|
+
if (field.type === "select" && !(Array.isArray(field.values) && field.values.length)) problems.push(`${label}.${field.name}: select fields need a "values" array`)
|
|
97
|
+
}
|
|
98
|
+
if (type === "view" && collection.fields?.length) problems.push(`${label}: view collections take their fields from viewQuery; remove "fields"`)
|
|
99
|
+
if (collection.seed !== undefined && !Array.isArray(collection.seed)) problems.push(`${label}: "seed" must be an array of records`)
|
|
100
|
+
}
|
|
101
|
+
if (schema.rateLimits !== undefined && !Array.isArray(schema.rateLimits)) problems.push('"rateLimits" must be an array')
|
|
102
|
+
for (const rule of Array.isArray(schema.rateLimits) ? schema.rateLimits : []) {
|
|
103
|
+
if (!rule?.label || !(rule.maxRequests > 0) || !(rule.duration > 0)) {
|
|
104
|
+
problems.push(`each rateLimits entry needs "label", "maxRequests" and "duration" (seconds): ${JSON.stringify(rule)}`)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (problems.length) fail(`schema.json has ${problems.length} problem(s):\n - ${problems.join("\n - ")}`)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function toApiField(field) {
|
|
111
|
+
const { collection, ...rest } = field
|
|
112
|
+
if (field.type !== "relation") return rest
|
|
113
|
+
const collectionId = collections.get(collection)?.id
|
|
114
|
+
if (!collectionId) fail(`Relation target "${collection}" does not exist. Add it to schema.json or fix the name.`)
|
|
115
|
+
return { maxSelect: 1, cascadeDelete: false, ...rest, collectionId }
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function mergeFields(existing, desired) {
|
|
119
|
+
const byName = new Map((existing?.fields ?? []).map((field) => [field.name, field]))
|
|
120
|
+
const merged = desired.map((field) => {
|
|
121
|
+
const current = byName.get(field.name)
|
|
122
|
+
if (current && current.type !== field.type) {
|
|
123
|
+
fail(`Field "${field.name}" exists with type ${current.type}; changing it to ${field.type} would drop data. Use a new field name instead.`)
|
|
124
|
+
}
|
|
125
|
+
return current ? { ...current, ...field, id: current.id } : field
|
|
126
|
+
})
|
|
127
|
+
const desiredNames = new Set(desired.map((field) => field.name))
|
|
128
|
+
const kept = (existing?.fields ?? []).filter((field) => !desiredNames.has(field.name))
|
|
129
|
+
return [...kept.filter((field) => field.system), ...merged, ...kept.filter((field) => !field.system)]
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function indexName(sql) {
|
|
133
|
+
return INDEX_NAME.exec(sql)?.[1]
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function indexDefinition(sql) {
|
|
137
|
+
return sql.replace(INDEX_NAME, "INDEX").replace(/[`"]/g, "").replace(/\s+/g, " ").trim().toLowerCase()
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function mergeIndexes(existing, desired) {
|
|
141
|
+
if (!desired) return existing ?? []
|
|
142
|
+
const names = new Set(desired.map(indexName))
|
|
143
|
+
const definitions = new Set(desired.map(indexDefinition))
|
|
144
|
+
const kept = (existing ?? []).filter((sql) => !names.has(indexName(sql)) && !definitions.has(indexDefinition(sql)))
|
|
145
|
+
return [...kept, ...desired]
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function withTimestamps(collection, fields, existingFields = []) {
|
|
149
|
+
if (collection.timestamps === false) return fields
|
|
150
|
+
const present = (name) => fields.some((field) => field.name === name) || existingFields.some((field) => field.name === name)
|
|
151
|
+
return [...fields, ...TIMESTAMPS.filter((timestamp) => !present(timestamp.name))]
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
async function createMissingCollections(group) {
|
|
155
|
+
for (const collection of group) {
|
|
156
|
+
if (collections.has(collection.name)) continue
|
|
157
|
+
const type = collection.type ?? "base"
|
|
158
|
+
const body = { name: collection.name, type }
|
|
159
|
+
if (type === "view") {
|
|
160
|
+
body.viewQuery = collection.viewQuery
|
|
161
|
+
} else {
|
|
162
|
+
const plainFields = (collection.fields ?? []).filter((field) => field.type !== "relation")
|
|
163
|
+
body.fields = withTimestamps(collection, plainFields)
|
|
164
|
+
}
|
|
165
|
+
const res = await request(base, "/api/collections", { method: "POST", token, body })
|
|
166
|
+
if (res.status !== 200) fail(`Cannot create ${collection.name}: ${describeError(res)}`)
|
|
167
|
+
console.log(`NEW ${collection.name}`)
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
async function updateFieldsAndIndexes(group) {
|
|
172
|
+
for (const collection of group) {
|
|
173
|
+
const existing = collections.get(collection.name)
|
|
174
|
+
const body = {}
|
|
175
|
+
if (existing.type === "view") {
|
|
176
|
+
if (collection.viewQuery && collection.viewQuery !== existing.viewQuery) body.viewQuery = collection.viewQuery
|
|
177
|
+
} else {
|
|
178
|
+
const desired = withTimestamps(collection, (collection.fields ?? []).map(toApiField), existing.fields)
|
|
179
|
+
body.fields = mergeFields(existing, desired)
|
|
180
|
+
body.indexes = mergeIndexes(existing.indexes, collection.indexes)
|
|
181
|
+
}
|
|
182
|
+
if (collection.authOptions) Object.assign(body, collection.authOptions)
|
|
183
|
+
if (!Object.keys(body).length) continue
|
|
184
|
+
const res = await request(base, `/api/collections/${existing.id}`, { method: "PATCH", token, body })
|
|
185
|
+
if (res.status !== 200) fail(`Cannot update ${collection.name}: ${describeError(res)}`)
|
|
186
|
+
console.log(`SYNC ${collection.name} (${res.data.fields.length} fields, ${res.data.indexes.length} indexes)`)
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
async function applyRules() {
|
|
191
|
+
for (const collection of wanted) {
|
|
192
|
+
if (!collection.rules) continue
|
|
193
|
+
const body = {}
|
|
194
|
+
for (const [key, apiKey] of Object.entries(RULE_KEYS)) {
|
|
195
|
+
if (key in collection.rules) body[apiKey] = collection.rules[key]
|
|
196
|
+
}
|
|
197
|
+
const res = await request(base, `/api/collections/${collections.get(collection.name).id}`, { method: "PATCH", token, body })
|
|
198
|
+
if (res.status !== 200) fail(`Cannot set rules on ${collection.name}: ${describeError(res)}`)
|
|
199
|
+
console.log(`RULES ${collection.name}`)
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
async function applyRateLimits() {
|
|
204
|
+
if (!schema.rateLimits?.length) return
|
|
205
|
+
const settings = await request(base, "/api/settings", { token })
|
|
206
|
+
if (settings.status !== 200) fail(`Cannot read settings: ${describeError(settings)}`)
|
|
207
|
+
const current = settings.data.rateLimits ?? { enabled: true, rules: [] }
|
|
208
|
+
const rules = mergeRateLimitRules(current.rules ?? [], schema.rateLimits)
|
|
209
|
+
const res = await request(base, "/api/settings", { method: "PATCH", token, body: { rateLimits: { ...current, enabled: true, rules } } })
|
|
210
|
+
if (res.status !== 200) fail(`Cannot set rate limits: ${describeError(res)}`)
|
|
211
|
+
console.log(`LIMIT ${schema.rateLimits.map((rule) => rule.label).join(", ")}`)
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
async function seedEmptyCollections() {
|
|
215
|
+
for (const collection of wanted) {
|
|
216
|
+
if (!collection.seed?.length) continue
|
|
217
|
+
const recordsPath = `/api/collections/${collection.name}/records`
|
|
218
|
+
const count = await request(base, `${recordsPath}?perPage=1&skipTotal=0`, { token })
|
|
219
|
+
if (count.status !== 200) fail(`Cannot read ${collection.name}: ${describeError(count)}`)
|
|
220
|
+
if (count.data.totalItems > 0) {
|
|
221
|
+
console.log(`SEED ${collection.name} skipped (already has ${count.data.totalItems} records)`)
|
|
222
|
+
continue
|
|
223
|
+
}
|
|
224
|
+
const inserted = []
|
|
225
|
+
for (const record of collection.seed) {
|
|
226
|
+
const res = await request(base, recordsPath, { method: "POST", token, body: record })
|
|
227
|
+
if (res.status === 200) {
|
|
228
|
+
inserted.push(res.data.id)
|
|
229
|
+
continue
|
|
230
|
+
}
|
|
231
|
+
await removeRecords(recordsPath, inserted)
|
|
232
|
+
const after = await request(base, `${recordsPath}?perPage=1&skipTotal=0`, { token })
|
|
233
|
+
const left = after.status === 200 ? after.data.totalItems : null
|
|
234
|
+
const cleanup = left === 0
|
|
235
|
+
? ""
|
|
236
|
+
: ` ${left ?? "Some"} record(s) are still in ${collection.name} (a request that failed may still have been saved); delete them in the dashboard, or the next run skips this collection's seed.`
|
|
237
|
+
fail(`Cannot seed ${collection.name} with ${JSON.stringify(record)}: ${describeError(res)}.${cleanup}`)
|
|
238
|
+
}
|
|
239
|
+
console.log(`SEED ${collection.name} (${collection.seed.length} records)`)
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
async function removeRecords(recordsPath, ids) {
|
|
244
|
+
for (const id of ids) await request(base, `${recordsPath}/${id}`, { method: "DELETE", token })
|
|
245
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import fs from "node:fs"
|
|
2
|
+
|
|
3
|
+
const REQUEST_TIMEOUT_MS = 20000
|
|
4
|
+
const WAKE_UP_RETRY_DELAY_MS = 3000
|
|
5
|
+
const RETRYABLE_STATUSES = new Set([502, 503, 504])
|
|
6
|
+
const RETRYABLE_STATUSES_FOR_WRITES = new Set([503])
|
|
7
|
+
const SAFE_METHODS = new Set(["GET", "HEAD"])
|
|
8
|
+
|
|
9
|
+
export function readJson(path) {
|
|
10
|
+
try {
|
|
11
|
+
return JSON.parse(fs.readFileSync(path, "utf8"))
|
|
12
|
+
} catch (error) {
|
|
13
|
+
fail(`Cannot read ${path}: ${error.message}`)
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function readCredentials(path) {
|
|
18
|
+
const creds = readJson(path)
|
|
19
|
+
const mode = fs.statSync(path).mode
|
|
20
|
+
const readableByOthers = (mode & 0o077) !== 0
|
|
21
|
+
if (readableByOthers && process.platform !== "win32") {
|
|
22
|
+
console.warn(`WARN ${path} is readable by other users; run: chmod 600 ${path}`)
|
|
23
|
+
}
|
|
24
|
+
return creds
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function fail(message) {
|
|
28
|
+
console.error(`ERROR ${message}`)
|
|
29
|
+
process.exit(1)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function baseUrlFrom(creds) {
|
|
33
|
+
const raw = creds.api_url ?? (creds.domain ? `https://${creds.domain}` : null)
|
|
34
|
+
if (!raw) fail("The credentials file has no domain or api_url. Save the full hosting_pocketbase_create-backend response.")
|
|
35
|
+
const withScheme = /^https?:\/\//i.test(raw) ? raw : `https://${raw}`
|
|
36
|
+
return withScheme.replace(/\/+$/, "").replace(/\/api$/i, "")
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms))
|
|
40
|
+
|
|
41
|
+
export async function request(base, path, { method = "GET", token, body, retries = 2 } = {}) {
|
|
42
|
+
const canRetryNetworkErrors = SAFE_METHODS.has(method)
|
|
43
|
+
const retryableStatuses = SAFE_METHODS.has(method) ? RETRYABLE_STATUSES : RETRYABLE_STATUSES_FOR_WRITES
|
|
44
|
+
let lastError
|
|
45
|
+
for (let attempt = 0; attempt <= retries; attempt++) {
|
|
46
|
+
const isLastAttempt = attempt === retries
|
|
47
|
+
try {
|
|
48
|
+
const response = await fetch(`${base}${path}`, {
|
|
49
|
+
method,
|
|
50
|
+
headers: {
|
|
51
|
+
Accept: "application/json",
|
|
52
|
+
...(body ? { "Content-Type": "application/json" } : {}),
|
|
53
|
+
...(token ? { Authorization: token } : {}),
|
|
54
|
+
},
|
|
55
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
56
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
|
|
57
|
+
})
|
|
58
|
+
if (retryableStatuses.has(response.status) && !isLastAttempt) {
|
|
59
|
+
await sleep(WAKE_UP_RETRY_DELAY_MS)
|
|
60
|
+
continue
|
|
61
|
+
}
|
|
62
|
+
const text = await response.text()
|
|
63
|
+
let data = null
|
|
64
|
+
try {
|
|
65
|
+
data = text ? JSON.parse(text) : null
|
|
66
|
+
} catch {
|
|
67
|
+
data = text
|
|
68
|
+
}
|
|
69
|
+
return { status: response.status, data }
|
|
70
|
+
} catch (error) {
|
|
71
|
+
lastError = error
|
|
72
|
+
if (!canRetryNetworkErrors || isLastAttempt) break
|
|
73
|
+
await sleep(WAKE_UP_RETRY_DELAY_MS)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return { status: 0, data: { message: lastError?.message ?? "request failed" } }
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export async function wakeUp(base) {
|
|
80
|
+
const health = await request(base, "/api/health", { retries: 5 })
|
|
81
|
+
if (health.status !== 200) {
|
|
82
|
+
fail(`${base}/api/health returned ${health.status} (${health.data?.message ?? "no message"}). Check the domain and that the backend exists (hosting_pocketbase_backend).`)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export async function superuserToken(base, creds) {
|
|
87
|
+
const email = creds.superuser_email
|
|
88
|
+
const password = creds.superuser_password
|
|
89
|
+
if (!email || !password) fail("The credentials file has no superuser_email or superuser_password.")
|
|
90
|
+
const res = await request(base, "/api/collections/_superusers/auth-with-password", {
|
|
91
|
+
method: "POST",
|
|
92
|
+
body: { identity: email, password },
|
|
93
|
+
retries: 4,
|
|
94
|
+
})
|
|
95
|
+
if (res.status !== 200) {
|
|
96
|
+
fail(
|
|
97
|
+
`Superuser sign-in failed (${res.status}: ${res.data?.message ?? "no message"}). ` +
|
|
98
|
+
"If the password was lost, rotate it with hosting_pocketbase_set-superuser and save the response.",
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
return res.data.token
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export async function listCollections(base, token) {
|
|
105
|
+
const res = await request(base, "/api/collections?perPage=1000", { token })
|
|
106
|
+
if (res.status !== 200) fail(`Cannot list collections: ${describeError(res)}`)
|
|
107
|
+
return new Map(res.data.items.map((item) => [item.name, item]))
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export function describeError(res) {
|
|
111
|
+
const details = res.data?.data && Object.keys(res.data.data).length ? JSON.stringify(res.data.data) : ""
|
|
112
|
+
return `${res.status} ${res.data?.message ?? ""} ${details}`.trim()
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function mergeRateLimitRules(current, desired) {
|
|
116
|
+
const keyOf = (rule) => `${rule.label}|${rule.audience ?? ""}`
|
|
117
|
+
const desiredKeys = new Set(desired.map(keyOf))
|
|
118
|
+
const normalized = desired.map((rule) => ({ audience: "", ...rule }))
|
|
119
|
+
return [...current.filter((rule) => !desiredKeys.has(keyOf(rule))), ...normalized]
|
|
120
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process"
|
|
2
|
+
import { baseUrlFrom, listCollections, readCredentials, readJson, request, superuserToken } from "./pb-lib.mjs"
|
|
3
|
+
|
|
4
|
+
const REALTIME_PROBE_SECONDS = "8"
|
|
5
|
+
const PAGE_TIMEOUT_MS = 15000
|
|
6
|
+
|
|
7
|
+
const [credsPath, schemaPath] = process.argv.slice(2)
|
|
8
|
+
if (!credsPath) {
|
|
9
|
+
console.error("Usage: node pb-verify.mjs <credentials.json> [schema.json]")
|
|
10
|
+
process.exit(1)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const creds = readCredentials(credsPath)
|
|
14
|
+
const schema = schemaPath ? readJson(schemaPath) : { collections: [] }
|
|
15
|
+
const base = baseUrlFrom(creds)
|
|
16
|
+
let failures = 0
|
|
17
|
+
let warnings = 0
|
|
18
|
+
|
|
19
|
+
const pass = (message) => console.log(`PASS ${message}`)
|
|
20
|
+
const warn = (message) => {
|
|
21
|
+
warnings++
|
|
22
|
+
console.log(`WARN ${message}`)
|
|
23
|
+
}
|
|
24
|
+
const bad = (message) => {
|
|
25
|
+
failures++
|
|
26
|
+
console.log(`FAIL ${message}`)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const health = await request(base, "/api/health", { retries: 5 })
|
|
30
|
+
if (health.status !== 200) {
|
|
31
|
+
bad(`/api/health returned ${health.status}; the backend is missing or still waking up. Retry in 10 s, then check hosting_pocketbase_backend.`)
|
|
32
|
+
finish()
|
|
33
|
+
}
|
|
34
|
+
pass("API is healthy")
|
|
35
|
+
|
|
36
|
+
const token = await superuserToken(base, creds)
|
|
37
|
+
pass("superuser sign-in works")
|
|
38
|
+
|
|
39
|
+
const byName = await listCollections(base, token)
|
|
40
|
+
|
|
41
|
+
for (const collection of schema.collections ?? []) {
|
|
42
|
+
const live = byName.get(collection.name)
|
|
43
|
+
if (!live) {
|
|
44
|
+
bad(`collection ${collection.name} is missing; run pb-apply-schema.mjs`)
|
|
45
|
+
continue
|
|
46
|
+
}
|
|
47
|
+
const missing = (collection.fields ?? []).filter((field) => !live.fields.some((f) => f.name === field.name)).map((f) => f.name)
|
|
48
|
+
if (missing.length) bad(`${collection.name} is missing fields: ${missing.join(", ")}`)
|
|
49
|
+
else if (live.type !== "view") pass(`${collection.name} has all ${collection.fields?.length ?? 0} declared fields`)
|
|
50
|
+
|
|
51
|
+
const timestampsWanted = collection.timestamps !== false && live.type !== "view"
|
|
52
|
+
if (timestampsWanted && !live.fields.some((field) => field.name === "created")) {
|
|
53
|
+
warn(`${collection.name} has no "created" field, so sort: "-created" fails; re-run pb-apply-schema.mjs`)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const recordsPath = `/api/collections/${collection.name}/records`
|
|
57
|
+
const anonList = await request(base, `${recordsPath}?perPage=1`)
|
|
58
|
+
if (live.listRule === null) {
|
|
59
|
+
anonList.status === 403
|
|
60
|
+
? pass(`${collection.name}: visitors cannot list (superusers only)`)
|
|
61
|
+
: bad(`${collection.name}: listRule is null but an anonymous list returned ${anonList.status}`)
|
|
62
|
+
} else if (anonList.status === 200) {
|
|
63
|
+
const scope = live.listRule === "" ? "everyone" : `rule "${live.listRule}"`
|
|
64
|
+
pass(`${collection.name}: listing works, filtered by ${scope}`)
|
|
65
|
+
} else {
|
|
66
|
+
bad(`${collection.name}: anonymous list returned ${anonList.status} ${anonList.data?.message ?? ""}`)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (live.type !== "view" && live.createRule === null) {
|
|
70
|
+
const anonCreate = await request(base, recordsPath, { method: "POST", body: {} })
|
|
71
|
+
anonCreate.status === 403
|
|
72
|
+
? pass(`${collection.name}: visitors cannot create`)
|
|
73
|
+
: bad(`${collection.name}: createRule is null but an anonymous create returned ${anonCreate.status}`)
|
|
74
|
+
}
|
|
75
|
+
if (live.createRule === "" && live.type === "base") warn(`${collection.name}: anyone can create records; fine for a public form, otherwise tighten it`)
|
|
76
|
+
if (live.updateRule === "" || live.deleteRule === "") warn(`${collection.name}: anyone can update or delete any record; this is almost never intended`)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const settings = await request(base, "/api/settings", { token })
|
|
80
|
+
const limits = settings.data?.rateLimits
|
|
81
|
+
if (limits?.enabled) {
|
|
82
|
+
const summary = (limits.rules ?? []).map((rule) => `${rule.label}${rule.audience ? ` ${rule.audience}` : ""} ${rule.maxRequests}/${rule.duration}s`).join(", ")
|
|
83
|
+
pass(`rate limits per IP: ${summary}`)
|
|
84
|
+
}
|
|
85
|
+
if (settings.data?.smtp && !settings.data.smtp.enabled) {
|
|
86
|
+
console.log("INFO outgoing mail (SMTP) is off: verification and password-reset emails are not sent")
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function probeRealtime(protocol) {
|
|
90
|
+
try {
|
|
91
|
+
const out = execFileSync("curl", ["-sS", "-N", protocol, "--max-time", REALTIME_PROBE_SECONDS, "-H", "Accept: text/event-stream", `${base}/api/realtime`], {
|
|
92
|
+
encoding: "utf8",
|
|
93
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
94
|
+
})
|
|
95
|
+
return out.includes("PB_CONNECT") ? "ok" : "no-event"
|
|
96
|
+
} catch (error) {
|
|
97
|
+
if (error.code === "ENOENT") return "no-curl"
|
|
98
|
+
return String(error.stdout ?? "").includes("PB_CONNECT") ? "ok" : "no-event"
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const http2 = probeRealtime("--http2")
|
|
103
|
+
if (http2 === "no-curl") {
|
|
104
|
+
warn("curl is not installed, so realtime was not checked; open the site in two tabs and check a change appears in both")
|
|
105
|
+
} else {
|
|
106
|
+
http2 === "ok" ? pass("realtime connects over HTTP/2 (browsers)") : bad("realtime does not connect over HTTP/2; see troubleshooting.md")
|
|
107
|
+
probeRealtime("--http1.1") === "ok"
|
|
108
|
+
? pass("realtime connects over HTTP/1.1 (Node.js clients, dev proxies)")
|
|
109
|
+
: warn("realtime does not connect over HTTP/1.1: browsers are fine, Node.js subscribers need the workaround in troubleshooting.md")
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const dashboard = await fetch(`${base}/_/`, { signal: AbortSignal.timeout(PAGE_TIMEOUT_MS) }).catch(() => null)
|
|
113
|
+
dashboard?.status === 200 ? pass(`dashboard is at ${base}/_/`) : bad(`dashboard returned ${dashboard?.status ?? "no response"}`)
|
|
114
|
+
|
|
115
|
+
const home = await fetch(`${base}/`, { signal: AbortSignal.timeout(PAGE_TIMEOUT_MS) }).catch(() => null)
|
|
116
|
+
const homeText = home ? await home.text() : ""
|
|
117
|
+
if (!home || home.status >= 400) bad(`the website itself returned ${home?.status ?? "no response"}; deploy the frontend`)
|
|
118
|
+
else if (/<title>\s*Coming soon\s*<\/title>/i.test(homeText)) {
|
|
119
|
+
warn("the website still shows Hostinger's placeholder page; deploy the frontend")
|
|
120
|
+
} else pass("the website is serving the app")
|
|
121
|
+
|
|
122
|
+
finish()
|
|
123
|
+
|
|
124
|
+
function finish() {
|
|
125
|
+
console.log(`\n${failures ? "NOT READY" : "READY"}: ${failures} failed, ${warnings} warnings`)
|
|
126
|
+
process.exit(failures ? 1 : 0)
|
|
127
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Troubleshooting
|
|
2
|
+
|
|
3
|
+
| Symptom | Cause | Fix |
|
|
4
|
+
| --- | --- | --- |
|
|
5
|
+
| Create returns `state: null` | The state was not read yet; the backend usually works | `GET https://<domain>/api/health` should return 200 |
|
|
6
|
+
| Create returns 422 | A backend already exists, or PocketBase isn't enabled on this account yet (it rolls out gradually), or the site is headless WordPress or a parked domain | Read the message. Existing backend: `hosting_pocketbase_backend`; use the saved credentials, or rotate the superuser (`../../03-provision/pocketbase/SKILL.md`, Step 3). Not enabled yet: tell the user and stop |
|
|
7
|
+
| `hosting_pocketbase_backend` returns `state: failed` | The last start did not succeed (often `failure_reason: process_limit`: no free process slots on the account) | Hostinger starts it again after `retry_after_seconds`; wait and read again. The data is intact, never delete the backend |
|
|
8
|
+
| `hosting_pocketbase_backend` returns `state: missing` | The instance files are gone from the server | `hosting_pocketbase_create-backend` sets up a new, empty one; re-run `pb-apply-schema.mjs` |
|
|
9
|
+
| First request takes several seconds or returns 503 | The instance was asleep (after about 5 minutes idle) | Retry once; keep client timeouts at 10 s or more. The scripts retry on their own |
|
|
10
|
+
| Superuser sign-in fails | Wrong or lost password | `hosting_pocketbase_set-superuser`, then save the new response |
|
|
11
|
+
| `pb-apply-schema.mjs` reports an invalid rule | A field in the rule does not exist, a typo, or `:length` on a text field | The message names the field. Limit text length with the field's `max` |
|
|
12
|
+
| "The index name is already used" | Index names are unique across the whole database | Name indexes `idx_<collection>_<columns>` |
|
|
13
|
+
| Create returns 400 "Failed to create record." with empty `data` | The create rule rejected it | Compare the request body with the rule (`rules.md`, How a rejected request looks) |
|
|
14
|
+
| Update or delete returns 404 for a record that exists | The update or delete rule rejected it | Same as above |
|
|
15
|
+
| 429 Too Many Requests | Per-IP rate limit (default `/api` 200 per 5 minutes) | Fewer requests (subscribe instead of polling), or raise it with `rateLimits` in `schema.json` |
|
|
16
|
+
| Records do not appear for visitors | The list or view rule is `null` or too strict | `null` is superusers only; check with `rules.md` |
|
|
17
|
+
| Anyone can edit or delete | A rule is `""` | `pb-verify.mjs` warns about this; tighten it |
|
|
18
|
+
| Parallel requests fail with "The request was aborted" | SDK auto-cancellation | `pb.autoCancellation(false)` |
|
|
19
|
+
| A hidden or unpublished item stays on other screens | No realtime event is sent for records the viewer can no longer see | Delete instead of hiding for live views (`rules.md`, Realtime) |
|
|
20
|
+
| Totals from a view collection do not update live | View collections send no realtime events | Subscribe to the source collection and refetch the view |
|
|
21
|
+
| Sorting by `-created` fails | The collection has no `created` field | Re-run `pb-apply-schema.mjs`; it adds timestamps |
|
|
22
|
+
| `expand` returns nothing | The caller may not view the related record | Store the needed value (a display name) on the record itself, or loosen the related view rule |
|
|
23
|
+
| No password-reset or verification email arrives | SMTP is off on a new backend | The owner sets it in the dashboard, Settings > Mail settings |
|
|
24
|
+
| The app's own `/api/...` routes return PocketBase errors | PocketBase owns `/api` and `/_` | Move the app's routes to another prefix |
|
|
25
|
+
| History-routed pages 404 on refresh | No SPA fallback on static hosting | `.htaccess` from `frontend.md` |
|
|
26
|
+
| `hosting_deploy` fails while uploading | Temporary file-upload service error | Wait a minute and run the same deploy once more; otherwise deploy from Git (`deploy-to-hosting`) |
|
|
27
|
+
| Realtime stays "Connecting" in local dev | The dev-server proxy uses HTTP/1.1 | Point the SDK at the deployed domain in dev (`frontend.md`) |
|
|
28
|
+
|
|
29
|
+
## Realtime over HTTP/1.1
|
|
30
|
+
|
|
31
|
+
`pb-verify.mjs` tests the realtime stream (`/api/realtime`) over both HTTP/2 and HTTP/1.1 on every run. If HTTP/1.1 fails:
|
|
32
|
+
|
|
33
|
+
- **Browsers** use HTTP/2 and are fine.
|
|
34
|
+
- **Node.js** subscriptions (`EventSource` and `fetch` speak HTTP/1.1) need an HTTP/2 client:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm install eventsource undici
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
```js
|
|
41
|
+
import { EventSource } from "eventsource"
|
|
42
|
+
import { Agent, fetch as undiciFetch } from "undici"
|
|
43
|
+
|
|
44
|
+
const dispatcher = new Agent({ allowH2: true })
|
|
45
|
+
globalThis.EventSource = class extends EventSource {
|
|
46
|
+
constructor(url, init) {
|
|
47
|
+
super(url, { ...init, fetch: (input, options) => undiciFetch(input, { ...options, dispatcher }) })
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Run this before creating the PocketBase client. Setting undici's global dispatcher is not enough: Node's built-in `EventSource` ignores it.
|
|
53
|
+
- **Dev proxies:** connect the SDK straight to the deployed domain.
|
|
54
|
+
|
|
55
|
+
To check by hand: `curl -N --http1.1 --max-time 8 https://<domain>/api/realtime` should print `event:PB_CONNECT` within a second.
|
|
@@ -15,26 +15,13 @@ workspace `~/.hostinger/<domain>/src/`.
|
|
|
15
15
|
> When it is **Bring your own frontend**, follow [`bring-your-own-frontend.md`](bring-your-own-frontend.md): wire the user's own project to the
|
|
16
16
|
> backend instead of scaffolding one. When it is **Agent designs and builds**, proceed normally.
|
|
17
17
|
|
|
18
|
-
>
|
|
19
|
-
>
|
|
20
|
-
>
|
|
21
|
-
>
|
|
22
|
-
>
|
|
23
|
-
>
|
|
24
|
-
>
|
|
25
|
-
> UI. **Do not scaffold a new project, and do not re-implement `design.md` over it** (so **the design
|
|
26
|
-
> step does not apply** to an app that brings its own UI). Your job is only to make it deployable: set
|
|
27
|
-
> `engines.node` to `22`, remove any `.htaccess`, wire its data/env, then hand off to deploy. **Skip the
|
|
28
|
-
> Step 2 design pass**, and ignore the `content-model.md` requirement in Step 3.
|
|
29
|
-
> - **A new app built from the brief.** Scaffold and build it from `brief.md` (and `design.md` if the
|
|
30
|
-
> design step produced one — design *does* run for a from-scratch app). Its data is owned by the app, so
|
|
31
|
-
> there is still **no `content-model.md`** to bind against. An existing app under **Build mode "Agent
|
|
32
|
-
> designs and builds"** takes this shape too, but starts from its source: copy the project at
|
|
33
|
-
> `brief.md` → **Existing project** into `~/.hostinger/<domain>/src/`, keep its framework, screens,
|
|
34
|
-
> features and data wiring, and rebuild its UI to `design.md` instead of scaffolding a new project.
|
|
35
|
-
>
|
|
36
|
-
> Framework choice (Step 1), the build, and hand-off (Step 4) apply to both. The per-backend bullets in
|
|
37
|
-
> Step 3 are **WordPress / WooCommerce / Ecommerce only** — for a webapp follow the Webapp bullet there.
|
|
18
|
+
> **PocketBase backend?** A `pocketbase` brief has **no CMS/store**: the app's data lives in the
|
|
19
|
+
> PocketBase backend recorded in `site.json → pocketbase`, its collections in `pocketbase/schema.json`
|
|
20
|
+
> (and the `## Data` section of `content-model.md`), and its fixed copy in `content-model.md`. A new
|
|
21
|
+
> app is scaffolded from `brief.md` and `design.md` and binds its forms and views to the collections
|
|
22
|
+
> in `pocketbase/schema.json`; an existing app under **Agent designs and builds** starts from its
|
|
23
|
+
> source, keeps its screens and features, wires its data to the backend and rebuilds its UI to
|
|
24
|
+
> `design.md`. In Step 3 follow the PocketBase bullet.
|
|
38
25
|
|
|
39
26
|
## Step 1 — Pick the framework (guess → default → confirm)
|
|
40
27
|
|
|
@@ -45,10 +32,13 @@ it, and the backend constraint:
|
|
|
45
32
|
Next.js is the default, not a requirement (Express, Nuxt, SvelteKit, etc. are all fine).
|
|
46
33
|
- **WordPress + WooCommerce → SSR required** (same reason — cart/checkout need per-request rendering).
|
|
47
34
|
- **WordPress → SSG (Astro)** when the brief says SSG, otherwise **SSR (Next.js default)**.
|
|
48
|
-
- **
|
|
35
|
+
- **PocketBase → the app's own stack.** An **existing app** keeps its current framework (don't impose one), including
|
|
49
36
|
one rebuilt under **Agent designs and builds**; a
|
|
50
37
|
**new app** uses whatever fits the brief (SSR or SPA). Either way it deploys as a Node.js app (Step 8) —
|
|
51
|
-
an SSR app runs a server, a SPA builds to static output.
|
|
38
|
+
an SSR app runs a server, a SPA builds to static output. The app must not serve anything under
|
|
39
|
+
`/api` or `/_`: PocketBase owns those paths on this domain, so server routes go under another prefix
|
|
40
|
+
(`/server`): Next.js `app/server/…` never `app/api/…`, and likewise no Nuxt `server/api/`, SvelteKit
|
|
41
|
+
`src/routes/api/` or Astro `src/pages/api/`.
|
|
52
42
|
- Map rendering → framework: **`ssr` → Next.js**, **`ssg` → Astro** — unless the brief/prompt explicitly
|
|
53
43
|
names another supported framework, in which case use that.
|
|
54
44
|
|
|
@@ -114,10 +104,20 @@ Read the backend from `site.json`:
|
|
|
114
104
|
`false`, a graceful disabled-checkout state, no `/checkout` call, not a build error). **Never embed a
|
|
115
105
|
consumer key client-side.**
|
|
116
106
|
- **Ecommerce** → the public Hostinger Storefront Core V2 API: follow [`ecommerce.md`](ecommerce.md).
|
|
117
|
-
- **
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
107
|
+
- **PocketBase** → the `pocketbase` SDK against the backend on the same domain, following
|
|
108
|
+
[`../04-content-model/pocketbase/frontend.md`](../04-content-model/pocketbase/frontend.md) (skip its
|
|
109
|
+
static `.htaccess` section: a headless site deploys as Node.js and keeps no `.htaccess`). In the one
|
|
110
|
+
data module: `new PocketBase(<origin>)` where the origin is `window.location.origin` in the browser
|
|
111
|
+
and `site.json → urls.site` in local dev and on the server, then `pb.autoCancellation(false)` once.
|
|
112
|
+
Build filters with `pb.filter()`, load a list then subscribe to it for live views, and unsubscribe on
|
|
113
|
+
unmount. Build each form and view against the fields in `pocketbase/schema.json`, and show a rule
|
|
114
|
+
rejection (a 400 with no field errors, a 404 on update) as a normal "not allowed" state. Add the
|
|
115
|
+
sign-in form only when the schema has an auth collection visitors use
|
|
116
|
+
([`../04-content-model/pocketbase/auth.md`](../04-content-model/pocketbase/auth.md)). A public form
|
|
117
|
+
includes its recipe's honeypot field, empty and hidden. **The superuser password never reaches the
|
|
118
|
+
frontend**; server-side superuser work reads `PB_URL`, `PB_SUPERUSER_EMAIL` and
|
|
119
|
+
`PB_SUPERUSER_PASSWORD` from the app's environment variables (`frontend.md`, Node.js apps). For an
|
|
120
|
+
existing app, keep its screens and swap its data calls to the backend.
|
|
121
121
|
|
|
122
122
|
Guidelines (framework-agnostic):
|
|
123
123
|
|
|
@@ -125,10 +125,10 @@ Guidelines (framework-agnostic):
|
|
|
125
125
|
to inspect, one base URL to switch. Keep it swappable so the shell can build against stubs first.
|
|
126
126
|
- **Fetch at request time for SSR** (fresh content, no rebuild); a static build fetches at build time.
|
|
127
127
|
- **A failed or incomplete fetch is an error, not a silent empty/placeholder.** Planned content missing
|
|
128
|
-
from the API is a build error too — a site that builds with holes ships with holes. *(
|
|
129
|
-
|
|
130
|
-
- **`content-model.md` is the source for what should exist** (pages, nav, collections mapping) —
|
|
131
|
-
|
|
128
|
+
from the API is a build error too — a site that builds with holes ships with holes. *(On PocketBase
|
|
129
|
+
the planned content is the fixed pages plus the seed records.)*
|
|
130
|
+
- **`content-model.md` is the source for what should exist** (pages, nav, collections mapping) — on
|
|
131
|
+
every backend; on PocketBase it also carries the `## Data` section.
|
|
132
132
|
- **No `.htaccess`** in the project (deploy would overwrite the live one); don't commit `node_modules`
|
|
133
133
|
or build output.
|
|
134
134
|
- Set `engines.node` to `22` (the deploy builds on Node 22).
|
|
@@ -158,6 +158,5 @@ won't size a window below ~500 px, so a phone-width window comes back cropped: s
|
|
|
158
158
|
both widths in one image. The live site runs this same build, so it needs no screenshots; deploy checks
|
|
159
159
|
that it serves.
|
|
160
160
|
|
|
161
|
-
> **
|
|
162
|
-
>
|
|
163
|
-
> (`127.0.0.1` is server-only), so its data layer is verified **after** deploy, not here.
|
|
161
|
+
> **PocketBase:** the app reaches the live backend from local dev (`frontend.md`, Local development),
|
|
162
|
+
> so check one list and one create against it here, then delete the test records before handing over.
|