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,
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.
This extensions only works with Directus 10 and higher.
Add directus-extension-types
as a dependency to your directus app.
# 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
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
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.