Phase 1: Monorepo scaffold, database, and dev environment

Turborepo monorepo with @forte/shared and @forte/backend workspaces.
Docker Compose dev env with PostgreSQL 16 + Valkey 8.
Fastify server with Pino JSON logging, request ID tracing, and
health endpoint. Drizzle ORM with company + location tables.

Includes:
- Root config (turbo, tsconfig, eslint, prettier)
- @forte/shared: types, schemas, currency/date utils
- @forte/backend: Fastify entry, plugins (database, redis, cors,
  error-handler, dev-auth), health route, Drizzle schema + migration
- Dev auth bypass via X-Dev-Company/Location/User headers
- Vitest integration test with clean DB per test (forte_test)
- Seed script for dev company + location
This commit is contained in:
Ryan Moon
2026-03-27 14:51:46 -05:00
parent 5f8726ee4e
commit c1cddd6b74
37 changed files with 1700 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
import postgres from 'postgres'
import { drizzle } from 'drizzle-orm/postgres-js'
import { companies, locations } from './schema/stores.js'
const DEV_COMPANY_ID = '00000000-0000-0000-0000-000000000001'
const DEV_LOCATION_ID = '00000000-0000-0000-0000-000000000010'
async function seed() {
const connectionString =
process.env.DATABASE_URL ?? 'postgresql://forte:forte@localhost:5432/forte'
const sql = postgres(connectionString)
const db = drizzle(sql)
console.log('Seeding database...')
await db
.insert(companies)
.values({
id: DEV_COMPANY_ID,
name: 'Dev Music Co.',
timezone: 'America/Chicago',
})
.onConflictDoNothing()
await db
.insert(locations)
.values({
id: DEV_LOCATION_ID,
companyId: DEV_COMPANY_ID,
name: 'Main Store',
address: {
street: '123 Main St',
city: 'Austin',
state: 'TX',
zip: '78701',
},
})
.onConflictDoNothing()
console.log(`Seeded dev company: ${DEV_COMPANY_ID}`)
console.log(`Seeded dev location: ${DEV_LOCATION_ID}`)
await sql.end()
console.log('Done.')
}
seed().catch((err) => {
console.error('Seed failed:', err)
process.exit(1)
})