Migrate backend from PocketBase to Directus
Full cutover: auth, users, collection and friendships now run on Directus via @directus/sdk, with owner/visibility rules enforced by Directus permissions. - middleware: Directus session (directus_auth cookie) with token refresh - /login is Directus (email normalized to lowercase), new /register page (first/last name, username) backed by public registration - collection, friends and profile pages + all API endpoints ported; ownership and addressee-only accept/decline enforced by permissions - display names use first_name/last_name everywhere (nav, friends, profile) - PocketBase SDK, POCKETBASE_URL and pb_schema.json removed - README and compose updated for DIRECTUS_URL
This commit is contained in:
@@ -8,7 +8,8 @@ collection with Cardmarket price valuations, and share collections with friends.
|
||||
|
||||
- [Astro](https://astro.build) (SSR, Node standalone adapter) — no UI framework
|
||||
- [Tailwind CSS v4](https://tailwindcss.com) + [basecoat-css](https://basecoatui.com)
|
||||
- [PocketBase](https://pocketbase.io) for database and authentication
|
||||
- [Directus](https://directus.io) for database, authentication and permissions
|
||||
(via [`@directus/sdk`](https://www.npmjs.com/package/@directus/sdk))
|
||||
- [TCGdex API](https://api.tcgdex.net) (French locale) for card data, with an
|
||||
in-memory server-side cache (`src/lib/tcgdex-cache.ts`)
|
||||
|
||||
@@ -26,43 +27,41 @@ Node >= 22.12.
|
||||
|
||||
## Environment variables
|
||||
|
||||
| Variable | Description | Default |
|
||||
| ---------------- | -------------------------------------------- | ------------------------------------ |
|
||||
| `POCKETBASE_URL` | URL of the PocketBase backend (auth + data) | `https://pokeshare.namarusaja.me` |
|
||||
| Variable | Description | Default |
|
||||
| -------------- | ------------------------------------------- | -------------------------------- |
|
||||
| `DIRECTUS_URL` | URL of the Directus backend (auth + data) | `https://directus.namarusaja.me` |
|
||||
|
||||
Read at **runtime** (`process.env`), so the same Docker image can be deployed
|
||||
against different PocketBase instances. For local dev, copy `.env.example` to
|
||||
against different Directus instances. For local dev, copy `.env.example` to
|
||||
`.env`. `HOST` and `PORT` are also honored by the standalone server.
|
||||
|
||||
## Docker
|
||||
|
||||
Single container (external PocketBase):
|
||||
Single container (external Directus):
|
||||
|
||||
```sh
|
||||
docker build -t pokeshare .
|
||||
docker run -p 4321:4321 -e POCKETBASE_URL=https://pb.example.com pokeshare
|
||||
docker run -p 4321:4321 -e DIRECTUS_URL=https://directus.example.com pokeshare
|
||||
```
|
||||
|
||||
## Full stack (app + PocketBase)
|
||||
|
||||
`docker-compose.yml` runs just the app; it expects an external PocketBase
|
||||
instance referenced by `POCKETBASE_URL` (see above). A schema export of the
|
||||
expected collections is kept at `pb_schema.json` for reference when setting
|
||||
up a new PocketBase instance (admin UI → Settings → Import collections).
|
||||
Or with the compose file:
|
||||
|
||||
```sh
|
||||
POCKETBASE_URL=https://pb.example.com docker compose up --build
|
||||
DIRECTUS_URL=https://directus.example.com docker compose up --build
|
||||
```
|
||||
|
||||
- The app listens on `4321`; expose it on your domain (Coolify: expose the
|
||||
`app` service, or use the plain Dockerfile build pack).
|
||||
- Accounts are managed from the PocketBase admin UI (`/_/`).
|
||||
- Collections, roles and permissions are managed from the Directus Data
|
||||
Studio; public registration is enabled with the "App User" role.
|
||||
|
||||
## Structure
|
||||
|
||||
- `src/pages/` — routes (`/`, `/search`, `/mycards`, `/card/[id]`,
|
||||
`/series/[id]`, `/sets/[id]`, `/friends`, `/profile`) and JSON API endpoints
|
||||
under `src/pages/api/`
|
||||
- `src/middleware.ts` — per-request PocketBase client + `pb_auth` cookie auth
|
||||
- `src/lib/` — TCGdex cache, collection pricing helpers, type theming
|
||||
`/series/[id]`, `/sets/[id]`, `/friends`, `/profile`, `/login`, `/register`)
|
||||
and JSON API endpoints under `src/pages/api/`
|
||||
- `src/middleware.ts` — Directus session (`directus_auth` cookie) with token
|
||||
refresh, exposes `locals.directus` and `locals.user`
|
||||
- `src/lib/` — Directus client + types, TCGdex cache, collection pricing,
|
||||
auth helper, type theming
|
||||
- `src/layouts/`, `src/components/` — base layout and nav
|
||||
|
||||
Reference in New Issue
Block a user