Skip to content

okkindel/appwrite-typescript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Appwrite Collection Builder

This project generates TypeScript models for Appwrite collections based on a configuration file.

Usage

To generate the TypeScript models, run the following command:

"scripts": {
  ...
  "codegen": "appwrite-typescript --config path/to/config.json --output models.ts --directory ./types"
}

Configuration

The configuration file should be a JSON file with the following structure:

{
  "endpoint": "https://[HOSTNAME_OR_IP]/v1",
  "projectId": "YOUR_PROJECT_ID",
  "apiKey": "YOUR_API_KEY",
  "databaseId": "YOUR_DATABASE_ID"
}
  • endpoint: The endpoint of your Appwrite server.
  • projectId: The ID of your Appwrite project.
  • apiKey: Your Appwrite API key.
  • databaseId: The ID of the database containing the collections.

Example

Here is an example of how to run the script:

npx appwrite-typescript --config ./config.json --output models.ts --directory ./output

Options

  • --config: Path to the configuration JSON file.
  • --output: Name of the output TypeScript file.
  • --directory: Directory where the output file will be saved.
  • --enumType: The type of enums to generate. Possible values are native and object. Default is object.

Results

The script will generate a TypeScript file similar to this:

Example

About

Generate typescript types for Appwrite API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published