https://github.com/satohshi/pocketbase-schema-generator
JS hook for PocketBase to help you with schema generation
https://github.com/satohshi/pocketbase-schema-generator
pocketbase typescript
Last synced: 2 months ago
JSON representation
JS hook for PocketBase to help you with schema generation
- Host: GitHub
- URL: https://github.com/satohshi/pocketbase-schema-generator
- Owner: satohshi
- License: mit
- Created: 2024-11-15T19:18:09.000Z (5 months ago)
- Default Branch: master
- Last Pushed: 2025-02-15T23:38:21.000Z (2 months ago)
- Last Synced: 2025-02-16T00:21:46.001Z (2 months ago)
- Topics: pocketbase, typescript
- Language: TypeScript
- Homepage:
- Size: 359 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-pocketbase - pocketbase-schema-generator - JS hook for automatically generating schema files. (Zod/TS interfaces)  (TypeScript tools)
README
# pocketbase-schema-generator
PocketBase hook for automatically generating schemas for Zod and [pocketbase-ts](https://github.com/satohshi/pocketbase-ts).
## Usage
1. Download `pb_hooks.zip` from [releases](https://github.com/satohshi/pocketbase-ts-schema-generator/releases) and extract it to the same directory as your PocketBase executable.
2. Update `config.json` if necessary.
3. Start up the PocketBase server, and it will automatically generate/update the schema file on bootstrap and every time you make changes to the collections.
4. If you have `exposeEndpoint` set to `true`, you can access the generated schema through the endpoint you specified in `endpointPath` (e.g. `https://URL_TO_YOUR_PB_SERVER/schema`).The generated schema will have field options in docstrings, so you will get additional information like `required`, `min`, and `max` when you hover over properties in your IDE.
## Configuration Options and Defaults
```js
{
// If set to true, the schema will be exposed through an HTTP endpoint
"exposeEndpoint": false,
// Path for the schema endpoint
"endpointPath": "/schema",
// If set to true, the schema endpoint will require authentication
"secureEndpoint": true,"tsSchema": {
// If set to true, schema file for pocketbase-ts will be generated
"generateFile": true,
// If set to true, field metadata will be included as JSDoc comments
"includeDocs": true,
// If set to true, system collections like _superusers and _otps in the schema will be included
"includeSystemCollections": false,
// File path where the generated schema will be saved
"outputPath": "./tsSchema.ts"
},"zodSchema": {
// If set to true, Zod schema file will be generated
"generateFile": true,
// If set to true, system collections like _superusers and _otps in the schema will be included
"includeSystemCollections": false,
// File path where the Zod schema will be saved
"outputPath": "./zodSchema.ts"
}
}
```