CLI for zapi - Zero to API in seconds
npm install @zapi-x/cli
Command-line interface for zapi - Zero to API in seconds.
``bash`
npm install -g @zapi-x/clior use with npx
npx @zapi-x/cli generate
Generate Prisma schema, TypeScript types, and API client from your entity definitions:
`bash`
zapi generate
Options:
- -c, --config - Path to zapi config file (default: ./zapi.config.ts)-o, --out
- - Output directory (default: ./generated)-p, --provider
- - Database provider: sqlite, postgresql, mysql (default: sqlite)
Get help on initializing a new zapi project:
`bash`
zapi init
For full project scaffolding, use:
`bash`
npm create zapi-x@latest
Create a zapi.config.ts file in your project root:
`typescript
import { entity, string, text, belongsTo } from "@zapi-x/core"
export const user = entity("user", {
email: string.unique(),
name: string,
})
export const post = entity("post", {
title: string,
body: text,
author: belongsTo(() => user),
}).ownedBy("author")
export default {
entities: [user, post],
}
`
Then run:
`bash`
npx @zapi-ts/cli generate
npx prisma db push --schema=./generated/prisma/schema.prisma
The generator creates:
- generated/prisma/schema.prisma - Prisma database schemagenerated/types.ts
- - TypeScript interfaces for all entitiesgenerated/client.ts` - Typed API client for frontend use
-
- zapi Documentation
- Prisma Documentation
MIT