Skip to Content
DocsPlayground

Playground

apps/playground in the repository  is a Next.js app that uses @quickben/core, @quickben/next, @quickben/admin and @quickben/db-drizzle. It needs no external services.

Playground admin: posts list

Run it

git clone https://github.com/vialabs-net/quickben.git cd quickben pnpm install pnpm dev

pnpm dev builds the packages first, then starts http://localhost:3000 . An empty database is seeded on start.

PathWhat
/Public page: published posts, read with the local API.
/adminAdmin UI.
/api/_metaREST API. Also /api/posts, /api/posts/:id, …

What it shows

FeatureWhere
Four collectionsauthors, tags, posts, settings in quickben.config.ts
Relations, one and manyposts.author, posts.tags
Custom validationposts.slug (validate)
Field widthsposts.status, posts.author, posts.publishedAt (third)
JSON fieldsettings.value
Access rule that returns a filterAnonymous users read published posts only
Modules in the sidebar“Content” and “System”, from a plugin
Seed on startPlugin onInit hook (lib/seed.ts)
Local API in a server componentapp/page.tsx
Route handlersapp/api/[...quickben]/route.ts
Admin page and server functionapp/admin/[[...segments]]/page.tsx
One database client per processsingleton in lib/db.ts

Roles

Pick a role in the bar at the top of each page. It sets a cookie that the auth adapter turns into a devAuth() user. Without the cookie you are admin.

RoleCan
adminEverything, including settings
editorCreate and edit authors, tags and posts
viewerRead
anonymousRead published posts, authors and tags

devAuth() trusts the client. Do not deploy the playground.

Database

QUICKBEN_DBStorage
pglite (default)PGlite in ./.pglite. Tables are created on start.
memoryIn memory. Resets on restart.
CommandEffect
pnpm --filter @quickben/playground seedSeed an empty database.
pnpm --filter @quickben/playground db:resetDelete ./.pglite.

Tests

pnpm --filter @quickben/playground build CI=1 pnpm --filter @quickben/playground test:e2e

Playwright runs against next start. Without CI, the tests start next dev or reuse a server on port 3300.

TestChecks
List, create, edit and delete a postAdmin forms and the server function.
The role switcher changes what the admin showsAccess rules in the sidebar and forms.
The public page and the API read through access rulesFilters for anonymous users, REST responses.
Last updated on