CLI to generate types based on your Strapi API content types.
- Generate Typescript's types based on your content types
- Ease-of-use thanks a beautiful prompt
yarn add strapi-generate-typesor
npm install --save strapi-generate-typesIn order to use this generator you must have installed the GraphQL plugin on your Strapi API.
yarn strapi install graphqlFor more informations see the GraphQL plugin
yarn strapi-generate-types generateOR
npx strapi-generate-types generateThe prompt will ask you 3 things:
- First, the host of your Strapi API with which you want to generate your types (default:
http://localhost:1337). - Then, where you want to generate it (default:
./models/). - Finally, the name of the file which will be generated (default:
types.ts)
Enjoy 🎉
If you don't want to use the prompt everytime you run the generator, you can use the quickgen:
yarn|npx strapi quickgen <url> [-p, --path <location>, default: "./models/"] [-n, --file-name <filename>, default: "types.ts"]