Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

formatting

Copple987657ff3282
diff --git a/web/docs/guides/api/generating-types.mdx b/web/docs/guides/api/generating-types.mdx
index 865ae468091..2479ab2b55d 100644
--- a/web/docs/guides/api/generating-types.mdx
+++ b/web/docs/guides/api/generating-types.mdx
@@ -31,21 +31,21 @@ Important notes:
After you have generated your types, you can use them in your TypeScript projects:
```ts
-import { NextApiRequest, NextApiResponse } from "next";
-import { createClient } from "@supabase/supabase-js";
-import { definitions } from "../../types/supabase";
+import { NextApiRequest, NextApiResponse } from "next"
+import { createClient } from "@supabase/supabase-js"
+import { definitions } from "../../types/supabase"
const supabase = createClient(
process.env.NEXT_PUBLIC_SUPABASE_URL,
process.env.SUPABASE_SECRET_KEY
-);
+)
export default async (req: NextApiRequest, res: NextApiResponse) => {
const allOnlineUsers = await supabase
.from<definitions["users"]>("users")
.select("*")
- .eq("status", "ONLINE");
- res.status(200).json(allOnlineUsers);
+ .eq("status", "ONLINE")
+ res.status(200).json(allOnlineUsers)
};
```
diff --git a/web/spec/supabase.yml b/web/spec/supabase.yml
index 723226c4e78..195b563f57d 100644
--- a/web/spec/supabase.yml
+++ b/web/spec/supabase.yml
@@ -312,7 +312,7 @@ pages:
Generating Types:
description: |
- Supabase will soon release native type generators that dump your database types for various languages. For now, we support TypeScript through a third-party tool.
+ Supabase will soon release native type generators that dump your database types for various languages. For now, we support TypeScript [through third-party tools](/docs/guides/api/generating-types).
## Usage with TypeScript
@@ -345,55 +345,6 @@ pages:
response.data // Response data will be of type Array<any>.
```
- ### Generate database types from OpenAPI specification
-
- Supabase generates an OpenAPI specification file for your database which can be used to generate your data types for usage with TypeScript.
-
- The OpenAPI specification for your Supabase project can be accessed as follows:
-
- ```txt
- https://your-project.supabase.co/rest/v1/?apikey=your-anon-key
- ```
-
- Using the open source [openapi-typescript](https://github.com/drwpow/openapi-typescript#%EF%B8%8F-reading-specs-from-remote-resource) tool you can generate your types and store them locally:
-
- ```bash
- npx openapi-typescript https://your-project.supabase.co/rest/v1/?apikey=your-anon-key --output types/supabase.ts
- ```
-
- Important notes:
-
- - Since the generator uses JSON API, there is no way to determine if a column is an Array. It will generate array types as `string`, even though Supabase handles this automatically and returns arrays.
- You can fix this manually in the files by changing the type, e.g. `names: string` -> `names: string[]`
- - The types won't automatically stay in sync with your database, so make sure to regenerate your types after your make changes to your database.
-
- After you have generated your types, you can use them in your TypeScript projects:
-
- ```ts
- import { NextApiRequest, NextApiResponse } from "next";
- import { createClient } from "@supabase/supabase-js";
- import { definitions } from "../../types/supabase";
-
- const supabase = createClient(
- process.env.NEXT_PUBLIC_SUPABASE_URL,
- process.env.SUPABASE_SECRET_KEY
- );
-
- export default async (req: NextApiRequest, res: NextApiResponse) => {
- const allOnlineUsers = await supabase
- .from<definitions["users"]>("users")
- .select("*")
- .eq("status", "ONLINE");
- res.status(200).json(allOnlineUsers);
- };
- ```
-
- For more advance type-support, check out [`postgrest-js-tools`](https://github.com/mzalevski/postgrest-js-tools).
-
- ### Update types automatically with GitHub Actions
-
- For updating types automatically with GitHub actions, please refer to [this guide](/docs/guides/database/generating-types).
-
auth.signUp():