TypeScript backend and /api/v2 foundations (1.51.0)
- tsconfig (allowJs, strict .ts), npm run build -> dist/, typecheck, dev via tsx, ts-jest. - src/index.js is now a launcher (dist build when it matches, else tsx); server moved to app.js. - /api/v2: defineRoute with zod -> request validation, response stripping, OpenAPI 3.1 at /docs/v2; one error shape and one paged-list shape. First endpoints: events, event, me, my registrations. - deploy.sh/install.sh build the backend; rollback to older releases skips the build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ls1vMdg2GYqbnKZmPaX1ot
This commit is contained in:
@@ -63,7 +63,8 @@ rollback() {
|
||||
clear_pm2_config
|
||||
git checkout -q "$PREVIOUS"
|
||||
restore_pm2_config
|
||||
(cd backend && npm ci --silent) || true
|
||||
# Releases from 1.51.0 on have a TypeScript build; older ones run src/ as it is.
|
||||
(cd backend && npm ci --include=dev --silent && { ! grep -q '"build":' package.json || npm run build --silent; }) || true
|
||||
(cd frontend && npm ci --silent && npm run build --silent) || true
|
||||
}
|
||||
trap rollback ERR
|
||||
@@ -76,8 +77,9 @@ if [ ! -f "$PM2_CONFIG" ]; then
|
||||
echo " Created $PM2_CONFIG from the example — check its app names and port."
|
||||
fi
|
||||
|
||||
echo "==> Backend: install and migrate"
|
||||
(cd backend && npm ci && npm run prisma:deploy)
|
||||
echo "==> Backend: install, migrate and build"
|
||||
# --include=dev: the TypeScript build needs the type packages even where NODE_ENV=production.
|
||||
(cd backend && npm ci --include=dev && npm run prisma:deploy && npm run build)
|
||||
|
||||
echo "==> Frontend: install and build"
|
||||
(cd frontend && npm ci && npm run build)
|
||||
|
||||
@@ -125,7 +125,7 @@ chown "$APP_USER:$APP_USER" "$DIR/backend/.env" "$DIR/frontend/.env.production"
|
||||
chmod 600 "$DIR/backend/.env"
|
||||
|
||||
step "Install, migrate, build"
|
||||
as_app "cd '$DIR/backend' && npm ci --no-audit --no-fund && npx prisma migrate deploy && npx prisma generate"
|
||||
as_app "cd '$DIR/backend' && npm ci --include=dev --no-audit --no-fund && npx prisma migrate deploy && npx prisma generate && npm run build"
|
||||
as_app "cd '$DIR/frontend' && npm ci --no-audit --no-fund && npm run build"
|
||||
|
||||
step "Start with PM2"
|
||||
|
||||
Reference in New Issue
Block a user