Skip to content

bootleq/feeders

Repository files navigation

Feeders

Source code of feeders.pages.dev.

A website dedicated to ending the suffering of free-roaming / stray dogs.

Getting Started

Initial pnpm install.

Prepare env file by copy .env.sample to .env.development.

Prepare database, run pnpm db:tables && pnpm db:migrate.

Prepare CMS, see Setup section in directus/README.md.

Then run the development server:

pnpm dev

Open http://localhost:3000 with your browser to see the result.

Prepare to preview:

pnpm lint
pnpm pages:build
pnpm cms:build-local
pnpm preview

cms:build-local prepares local CMS data to be uploaded to external storage, our built application fetches them instead of hitting CMS again.

Production deployment:

pnpm pages:build:prod
pnpm env:push:prod
pnpm run deploy

The env:push:prod loads variables in .env.production and uploads them as Pages secrets. This is to avoid exposing them in wrangler.toml.

Database

Currently, local Pages dev doesn't support --remote D1, so we use local sqlite db during development.

When everything is ready, run the drizzle migrations on remote D1.

  • List tables, can also be used to establish local db first time

    pnpm db:tables
    
  • Migrations with drizzle-kit (locally)

    pnpm db:migrate:gen
    pnpm db:migrate:drop
    pnpm db:migrate
    
  • Remove local db + drizzle meta, then reset with migrations (DANGER)

    pnpm db:delete
    pnpm db:delete && pnpm db:tables && pnpm db:migrate:gen && pnpm db:migrate
    
  • Directly execute commands on local D1

    pnpm wrangler d1 execute feeders --command 'PRAGMA table_list'
    pnpm wrangler d1 execute feeders --command 'INSERT INTO users (id, email) VALUES ("foo001", "[email protected]")'
    PRAGMA table_xinfo(TABLE_NAME)
    PRAGMA defer_foreign_keys = (on|off)
    SELECT name, sql FROM sqlite_master
    
  • Run migrations on remote D1

    pnpm wrangler d1 list
    pnpm wrangler d1 migrations apply feeders --remote
    

Authentication

Directus CMS

http://localhost:8044/admin

First time setup will create default admin user, see cms-log to get username/password.

pnpm cms
pnpm cms-log
pnpm cms-stop
pnpm cms-restart

See directus/README.md for more details.

Build with Bundle Analyzer

ANALYZE=true pnpm build

Test

Still lacking.

Admin Tasks

  • Inactive user

    pnpm tsx scripts/admin_activate_user.mjs {USER_ID} inactive --remote
    
  • Drop spot, or followup

    pnpm tsx scripts/admin_drop_spot.mjs {ID} dropped --remote
    pnpm tsx scripts/admin_drop_followup.mjs {ID} dropped --remote
    

About

Source code of feeders.pages.dev

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published