Install
This section takes you from an empty directory to a running API, one page at a time: install the packages, set up the database and the search index, then register the plugin.
Prerequisites
Section titled “Prerequisites”- Node.js 22.18 or later. These pages run TypeScript files directly with
node, which strips types without a build step. - pnpm. The commands use pnpm; npm and Yarn work too.
- PostgreSQL 18 or later. arocapi doesn’t support other databases.
- OpenSearch for search.
For local development, run the database and OpenSearch with Docker Compose:
services: db: image: postgres:18 ports: - 5432:5432 environment: POSTGRES_PASSWORD: password POSTGRES_DB: catalog
opensearch: image: opensearchproject/opensearch:3 ports: - 9200:9200 environment: - discovery.type=single-node - DISABLE_SECURITY_PLUGIN=true - OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512mdocker compose up -dCreate the project
Section titled “Create the project”arocapi is an ES module, so your project needs "type": "module":
mkdir my-repository && cd my-repositorypnpm initpnpm pkg set type=moduleAdd the packages
Section titled “Add the packages”pnpm add arocapi@beta fastify @opensearch-project/opensearch @prisma/client@7 @prisma/adapter-pg@7pnpm add -D prisma@7 dotenvarocapiis the plugin. It depends on Fastify, but you installfastifyyourself to create the server it runs in.@prisma/clientis a peer dependency. arocapi reads entities through the Prisma client that you generate in your project. arocapi needs Prisma 7.10 or later 7.x; Prisma 8 isn’t supported.@prisma/adapter-pgis the driver adapter Prisma 7 needs to connect to PostgreSQL.prismais the CLI that runs migrations and generates the client. Pin it to 7:prisma@latestis Prisma 8, which can’t read a Prisma 7 config.@opensearch-project/opensearchis the search client you pass to arocapi.dotenvloads.envfor the Prisma CLI.
pnpm doesn’t run dependency build scripts until you allow them. The Prisma CLI needs the schema engine that
@prisma/engines downloads when it installs, so allow that one in pnpm-workspace.yaml and rebuild it:
allowBuilds: '@prisma/engines': true prisma: falsepnpm rebuild @prisma/enginesType checking (optional)
Section titled “Type checking (optional)”Node runs your TypeScript without checking it. To check types in your editor or with tsc, add typescript and
@types/node as dev dependencies and a tsconfig.json:
{ "compilerOptions": { "target": "esnext", "module": "nodenext", "strict": true, "noEmit": true, "allowImportingTsExtensions": true, "skipLibCheck": true }}Next, set up the database.