This service manages challenge resources, resource roles, and resource-role phase dependencies while preserving the existing v6 HTTP and event contracts.
- TypeScript 5 and NestJS 11
- Prisma 7 with PostgreSQL driver adapters
- Node.js 26.5.0
- pnpm 11.15.1
- PostgreSQL for the resources, member, and challenge data sources
The exact local Node version is recorded in .nvmrc. Run nvm use after entering this project directory and before running pnpm or Node commands.
- Node.js 26.5.0 through nvm
- pnpm 11.15.1
- PostgreSQL databases accessible through the existing database URLs
- Docker with BuildKit when building the production image
nvm use
pnpm install --frozen-lockfile
pnpm lint
pnpm build
pnpm testpnpm install runs the postinstall hook and generates the service's resources, member, and challenge Prisma 7 clients. pnpm prisma:generate intentionally generates only those three service clients. The committed packages/resources-prisma-client directory remains the existing Prisma 6-compatible external artifact used by sibling services; it is not regenerated as part of this rollout.
Useful commands are:
pnpm startstarts the compiled application fromdist/main.js.pnpm start:devstarts Nest in watch mode.pnpm buildcompiles the TypeScript application.pnpm lintchecks TypeScript source and tests.pnpm prisma:generateregenerates the three internal clients../node_modules/.bin/prisma migrate deployapplies the existing resources migration history without requiring a global pnpm installation.pnpm seed-tablesseeds resource tables.pnpm view-data <ModelName>displays resource data.pnpm run mock-challenge-apistarts the challenge mock on port 4000.pnpm run mock-apistarts the local API mock on port 4001.pnpm run test:newmanruns the Postman regression suite.pnpm run test:newman:clearremoves Postman test data.
The API listens on port 3000 by default. Swagger UI is available at /v6/resources/api-docs, and the source definition is docs/swagger.yaml.
The TypeScript conversion retains the existing environment-variable names and defaults. No deployment parameter rename is required.
LOG_LEVEL,PORT,API_VERSION,DEFAULT_PAGE_SIZE, andAPI_BASE_URLAUTH_SECRETandVALID_ISSUERSAUTH0_URL,AUTH0_AUDIENCE,TOKEN_CACHE_TIME,AUTH0_CLIENT_ID,AUTH0_CLIENT_SECRET, andAUTH0_PROXY_SERVER_URLSCOPE_READ,SCOPE_CREATE,SCOPE_DELETE,SCOPE_UPDATE, andSCOPE_ALLSUBMITTER_RESOURCE_ROLE_ID,REVIEWER_RESOURCE_ROLE_ID, andITERATIVE_REVIEWER_RESOURCE_ROLE_ID
Defaults remain port 3000, API version v6, and page size 1000.
DATABASE_URLconnects to the resources database and is used byprisma migrate deploy.MEMBER_DB_URLconnects the read-only member client.CHALLENGE_DB_URLconnects the challenge client used for challenge lookups and registrant-count updates.RESOURCE_SERVICE_PRISMA_TIMEOUTretains the existing Prisma timeout setting.
All three URLs are required for application behavior that touches their corresponding data source. They remain separate parameters; this upgrade does not introduce replacement URL names.
TERMS_API_URLMEMBER_API_URLUSER_API_URLCHALLENGE_API_URLCHALLENGE_PHASES_API_URLSUBMISSIONS_API_URLGROUPS_API_URL
This service publishes events through the existing Bus API HTTP client. It does not consume Kafka messages, so it does not use @platformatic/kafka and requires no Kafka broker configuration.
The retained publishing parameters are:
BUSAPI_URLKAFKA_ERROR_TOPICKAFKA_MESSAGE_ORIGINATORRESOURCE_CREATE_TOPICRESOURCE_DELETE_TOPICRESOURCE_ROLE_CREATE_TOPICRESOURCE_ROLE_UPDATE_TOPICEMAIL_NOTIFICATIN_TOPIC
EMAIL_NOTIFICATIN_TOPIC intentionally retains its existing spelling for deployment compatibility. The KAFKA_* parameter names are also retained even though this service reaches Kafka indirectly through Bus API.
Registration email payloads continue to use EMAIL_FROM, SENDGRID_TEMPLATE_ID, SENDGRID_TEMPLATE_ID_NO_FORUM, SUBMIT_URL, REVIEW_APP_URL, HELP_URL, and SUPPORT_EMAIL. TOPCROWD_CHALLENGE_TEMPLATE_ID continues to control whether the registration email event is emitted.
Publishing remains synchronous. A command that emits an event waits for Bus API to accept it, preserving the existing endpoint success and failure behavior.
The existing test-only settings remain supported: WAIT_TIME, MOCK_CHALLENGE_API_PORT, MOCK_API_PORT, AUTH_V2_URL, AUTH_V2_CLIENT_ID, AUTH_V3_URL, the admin/copilot/user credential variables, AUTOMATED_TESTING_REPORTERS_FORMAT, and AUTOMATED_TESTING_NAME_PREFIX.
Start or connect to the three existing PostgreSQL databases, then export their URLs without changing the variable names:
export DATABASE_URL="postgresql://user:password@localhost:5532/resourceapi?schema=resources"
export MEMBER_DB_URL="postgresql://user:password@localhost:5632/memberdb"
export CHALLENGE_DB_URL="postgresql://user:password@localhost:5732/challengedb"Apply the checked-in resources migrations and build the application:
./node_modules/.bin/prisma migrate deploy
pnpm build
pnpm startThis upgrade is designed for existing databases. The SQL files and migration lock under prisma/migrations are the deployment history and must remain unchanged. Do not reset the database, run prisma migrate dev, generate a new migration for this conversion, or use prisma db push against a deployed environment.
The production entrypoint runs ./node_modules/.bin/prisma migrate deploy before starting dist/main.js. This applies only pending migrations from the unchanged history and does not recreate the schema.
Build the Node 26 production image with:
./build.sh resources-api-v6The multi-stage build performs a frozen pnpm install, Prisma generation through postinstall, lint, and TypeScript compilation. The runtime image contains the compiled application, production dependencies, Prisma CLI and configuration, unchanged migrations, Swagger documentation, the three generated internal clients, and the committed external client. Build-only npm and pnpm tooling is removed from the runtime image, which runs as the non-root node user.
Runtime configuration continues to be injected through the existing environment variables. The default configuration is included in the image; local env.sh files remain excluded.
Unit tests require the configured resources, member, and challenge databases as exercised by the relevant test cases:
nvm use
pnpm testFor the Postman suite, build and start the service and challenge mock, then run:
pnpm run test:newman:clear
pnpm run test:newman
pnpm run test:newman:clearCircleCI performs the Docker build and deployment using the existing APPNAME, DEPLOY_ENV, and parameter-store paths. The automated-test workflow uses Node 26.5.0, pnpm 11.15.1, and the same deployment environment names.
See Verification.md for the regression checklist.