End-to-end types rely on the file structure of conventions, which are created and deleted through the command line. It will automatically help you adhere to the conventions.
Create One
If no HTTP Method is specified, the default is post.
yarn v1 get/useryarn v1 get/useroutput
+ api-v1/index.ts
+ api-v1/get/index.ts
+ api-v1/get/user.ts
v1 is an alias script for tealina api-v1
Create Multiple
Create four APIs for a model to perform CRUD operations. Alternatively, you can only pass “cr” to create two APIs.
crudis an abbreviation for template defined in config.
yarn v1 user -t crudyarn v1 user -t crudBatch Create
According to the model name in the schema.prisma file, create APIs in bulk. If you are not using Prisma ORM, a .prisma file is also acceptable.
yarn v1 -t crud -myarn v1 -t crud -mIf the API file already exists, it will not be overwritten.
Delete API
Just add -d.
yarn v1 get/user -dyarn v1 get/user -dRealign
If the file structure has been manually changed, this command can help you realign the index file.
yarn v1 -ayarn v1 -aGenerate API Document
yarn v1 gdocyarn v1 gdocBefore running, make sure your Handler has been defined with the correct type.
Generate Types
yarn v1 gtypeyarn v1 gtypeFeatures
- The relation fields are excluded
- All types use
interfacekeyword (for remain the type name when usegdoc)
Options
| Option | description | default |
|---|---|---|
| --align, -a | Align and update the index file according to the existing API files. | false |
| --delete-api, -d | Delete API | false |
| --template-alias, -t | Templates alias | |
| --model, -m | Use the model name from schema.prisma | false |
| --input, -i | The file path of schema.prisma when executing gtype | prisma/schema.prisma |
| --output, -o | Output path, gdoc is the folder, gtype is the file path | docs(gdoc), types/pure.d.ts(gtype) |
| --namespace, -n | gtype Generated type, within this namespace | Pure |
| --with-test | Generate test files too | false |
| --config-path | Tealina config file path | tealina.config.mjs |
| --verbose | Print more detail when error | false |