Public: anyone can read this; the crew can change it.
The app says out loud when the forge has not told it who it is: a boot check for identity, address and data #61
Sign in to join this conversation.
Public: anyone can read this; the crew can change it.
Intent. A missing environment variable should be a sentence in the log at boot, not a game nobody can play — today both of the settings this app cannot work without fail silently.
Read
src/env.tsagainstsrc/who.tsandsrc/http.ts: withFORGE_APP_IDENTITY_KEYunset,who()returnsanonfor every request, so every visitor is a guest, nobody can open a table or take a seat, and nothing anywhere says why — the app looks merely unwelcoming. WithFORGE_APP_URLunset,publicOriginishttp://localhost, so every absolute link the app prints points at localhost (pull #56 adds exactly such a field to copy),Securecomes off the notice cookie, HSTS comes off the floor, and any client that sends anOriginheader is answered 403.Done looks like
src/env.tsgainssettings(env = process.env): pure, environment in, a list of{ name, level: "fatal" | "warn", said }out, sorted, with no I/O — so it is testable without a process.productionandpreview, a missingFORGE_APP_IDENTITY_KEYorFORGE_APP_URLis fatal; locally each is a warning that says what will happen ("everyone is a guest: nobody can open a table", "links will say http://localhost"). AFORGE_APP_URLthat does not parse is fatal everywhere. An unsetFORGE_APP_DATAis a warning naming./data. An unsetFORGE_APP_SSHis a warning that the terminal is off — never fatal, and never a guessed command.src/server.ts'simport.meta.mainblock prints each finding on its own line before it listens and exits1if any is fatal.serve()itself is untouched, so every test that calls it with its own options keeps working.src/env.test.ts(new): one per rule over a plain object, and one child-process test that aproductionboot without an identity key exits non-zero and says which variable is missing, while the same boot with it listens and answers/.README.md's environment section marks which variables are required in production and what each one being absent does.Files
src/env.ts,src/server.ts,src/env.test.ts(new),README.md.Risks Do not make an optional setting fatal — the terminal being off is a fact to print, not an error, and a preview that refuses to boot helps nobody if the reason is cosmetic.
settings()must not read files or the network; it is a pure function of the environment so the test can be the forge.Brief that fits @mason to build, @sentinel to review what is fatal and what is printed. (A person assigns.)