Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lundjrl/directus-types-endpoint
Endpoint to generate schema types for TS development.
https://github.com/lundjrl/directus-types-endpoint
directus directus-extension directus-extension-endpoint typescript
Last synced: 2 months ago
JSON representation
Endpoint to generate schema types for TS development.
- Host: GitHub
- URL: https://github.com/lundjrl/directus-types-endpoint
- Owner: lundjrl
- License: mit
- Created: 2024-07-23T13:24:58.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-07-26T17:21:00.000Z (5 months ago)
- Last Synced: 2024-09-26T19:06:56.861Z (3 months ago)
- Topics: directus, directus-extension, directus-extension-endpoint, typescript
- Language: TypeScript
- Homepage:
- Size: 68.4 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Types Endpoint for Directus
This extension exposes your Directus schema to an endpoint.
It is specifically designed to be passed as the "SCHEMA" interface in the Directus client SDK but is certainly not limited to that.> [!IMPORTANT]
> This work was greatly inspired from [maltejur's generate types extension](https://www.npmjs.com/package/directus-extension-generate-types),
> however our team needed something that would expose an endpoint and work with newer versions of Directus. We sincerely hope you find it useful ☺️> [!WARNING]
> It is not recommended to expose your database schema in production. We use this tool to generate a types file and commit it to git.
> We recommend you do the same.## Requirements
This extensions only works with Directus 10 and higher.
## Installation
Add `directus-extension-types` as a dependency to your directus app.
```bash
# Using npm
npm install directus-extension-types
# Using bun
bun install directus-extension-types
# Using yarn
yarn add directus-extension-types
# Using pnpm
pnpm add directus-extension-types
```## Usage
### Getting types
After installation, the extension should be good to go.
To get your types, you'll need to ping the `/types` endpoint of your application.Ex: `http://localhost:8055/types`
### Using types
This endpoint is typically used to auto-generate the `SCHEMA` interface for the Directus client sdk.
The endpoint has a type called `CustomDirectusTypes`, this is your `SCHEMA` interface. Use that in your client SDK and see your types match the model of your back-end.