- TypeScript 88.9%
- CSS 9.8%
- JavaScript 1.3%
|
|
||
|---|---|---|
| .cursor/rules | ||
| .forgejo/workflows | ||
| migrations | ||
| src | ||
| tests | ||
| .dockerignore | ||
| .gitignore | ||
| .npmrc | ||
| CLAUDE.md | ||
| components.json | ||
| Dockerfile | ||
| drizzle.config.ts | ||
| next.config.ts | ||
| package-lock.json | ||
| package.json | ||
| postcss.config.mjs | ||
| README.md | ||
| spark.yaml | ||
| tsconfig.json | ||
| vitest.config.ts | ||
Leave
This repository is also the
fullstack-tsreference Spark. It is deployed and smoke-tested like any other Spark on every change, which is what stops the blueprint rotting (ADR-0013). If its pipeline is red, the blueprint is broken and every new Spark inherits it - that is the signal to watch. A Spark created withforge newgets this file with the paragraph removed.
Request and approve leave. Everyone sees their own requests; anyone in
octoforge-approvers sees all of them and can decide the ones that are not their own.
Running it
npm install
forge dev
npm install first: a clone has no node_modules. Every dependency here is public, so it needs
nothing configured. forge itself is installed once per machine - the portal prints that line
with the platform's registry address already in it.
forge stop takes the local database down again. forge dev leaves it running on purpose, so
the next start is quick.
Making it yours
This started as the fullstack-ts blueprint, and the leave example is here to show the shape of a
feature - not because your Spark needs it.
To replace it, delete what belongs to it and point the homepage somewhere else:
src/app/leave/ the pages, the form, the server actions
src/data/leave.ts the data facade, and where authorisation is decided
src/db/schema/leave.ts
tests/leave.test.ts
src/app/jobs/expire-old-leave/ the example of recurring work - a route the platform calls
src/app/page.tsx the home page, which links to the example
src/db/seed.ts the sample rows - it imports the schema above, so `npm test`
stops compiling if you delete the schema and leave this
That last line was missing, and following this list exactly used to break the build - found by somebody doing precisely what it said.
Delete the jobs: entry in spark.yaml with the route, or forge doctor will point out that a
declared job has nothing to call.
Then create your own:
forge add entity Booking
which writes the same five files, with the permission check already in place.
What it actually writes, because you cannot judge a generator you have not seen. One table
with a name column, and the layers around it:
// src/db/schema/booking.ts
export const bookings = pgTable('bookings', {
id: uuid('id').primaryKey().defaultRandom(),
name: text('name').notNull(),
createdBy: text('created_by').notNull(), // the row's owner
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
})
// src/data/booking.ts - the part worth having written for you
export async function removeBooking(actor: Actor, id: string): Promise<Result<void>> {
const [existing] = await db.select().from(bookings).where(eq(bookings.id, id)).limit(1)
if (!existing || existing.createdBy !== actor.user) {
return problem('booking.not-found', 'That booking does not exist.')
}
...
}
Then you add your own columns. The first author on this blueprint wrote all six files by hand
because they could not tell from the documentation whether a generator meant for one name column
was a sensible start for three tables with their own types - it is, and the ready-made ownership
check is the reason.
forge add dataset Project is the other shape: table, facade and test, no page, no createdBy,
and a replaceAll that is whole-table, transactional and batched.
Migrations. npm run db:generate names them itself - 0000_wakeful_flatman.sql - and the name
does not matter to anything. Renaming one means hand-editing migrations/meta/_journal.json, which
is not worth doing. A Spark that has never been published may delete migrations/ entirely and
regenerate, which is cleaner than shipping a first migration full of DROP TABLE for tables nobody
ever had; once it is published, never edit or delete one, because the database has a record of
what it already ran.
What you do not have to build
Authentication is not in this repository and must not be added. The platform signs people in before
a request arrives, and hands this Spark four headers - src/lib/identity.ts is the only file that
reads them. There is no login page, no session, and no password anywhere.
The database is not configured here either. needs.postgres: true in spark.yaml is the whole
declaration; the platform creates the database, the role and the credential, and injects
DATABASE_URL. Nobody types a password and none exists in this repository.
If you build this with Claude or Cursor
CLAUDE.md and .cursor/rules/ in this repository are the rules for doing that: what the platform
already provides, what must never be added, where code goes, and which command runs what. Both are
generated from one source in the blueprint, so they cannot disagree, and forge update keeps them
current. Do not edit them here - the change belongs in the blueprint.
Where things go
src/app/ |
Pages, and server actions. Never talks to the database directly |
src/data/ |
The only place that queries the database, and where "who may see this" is decided |
src/db/ |
Connection and schema. One file per table |
src/lib/ |
Identity, errors, logging |
Why it is arranged this way: docs/adr/0026-data-access-is-a-server-only-facade.md in the platform
repository. The short version is that a permission check needs one place to live, so a generator can
write it and a reviewer can find it.
The second example: a dataset
leave shows a person's own records. Most applications brought to OctoForge are the other shape -
something outside is fetched on a schedule, kept in a table nobody owns, and shown on a page. That
one is here too, end to end:
src/app/jobs/refresh-rates/route.ts the scheduled fetch, through @/lib/source
src/data/exchange-rate.ts replaceAll: whole-table, one transaction, batched
src/db/schema/exchange-rate.ts no createdBy - nobody owns a row from outside
src/app/rates/page.tsx what it shows, and both kinds of empty
tests/source.test.ts is not part of the example and does not go with it. It covers
src/lib/source.ts, which is platform code every Spark keeps: the four ways a hand-written fetch
goes wrong, a rate limit waited out rather than treated as a failure, and a missing credential told
apart from a broken one. Deleting it removes the cover and leaves the code.
Its manifest entries are the refresh-rates job and the egress.allow line beside it. The source
needs no credential, which is deliberate: it shows auth: 'none', and a blueprint that declared a
secret would not start until somebody entered a value for it.
Delete all four when you no longer need the example.