Skip to content

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.

bash
yarn v1 get/user
yarn v1 get/user
output

+ 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.

crud is an abbreviation for template defined in config.

bash
yarn v1 user -t crud
yarn v1 user -t crud

Batch 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.

bash
yarn v1 -t crud -m
yarn v1 -t crud -m

If the API file already exists, it will not be overwritten.

Delete API

Just add -d.

bash
yarn v1 get/user -d
yarn v1 get/user -d

Realign

If the file structure has been manually changed, this command can help you realign the index file.

bash
yarn v1 -a
yarn v1 -a

Generate API Document

bash
yarn v1 gdoc
yarn v1 gdoc

Before running, make sure your Handler has been defined with the correct type.

Generate Types

bash
yarn v1 gtype
yarn v1 gtype

Features

  1. The relation fields are excluded
  2. All types use interface keyword (for remain the type name when use gdoc)

Options

Optiondescriptiondefault
--align, -aAlign and update the index file according to the existing API files.false
--delete-api, -dDelete APIfalse
--template-alias, -tTemplates alias
--model, -mUse the model name from schema.prismafalse
--input, -iThe file path of schema.prisma when executing gtypeprisma/schema.prisma
--output, -oOutput path, gdoc is the folder, gtype is the file pathdocs(gdoc), types/pure.d.ts(gtype)
--namespace, -ngtype Generated type, within this namespacePure
--with-testGenerate test files toofalse
--config-pathTealina config file pathtealina.config.mjs
--verbosePrint more detail when errorfalse