The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
chore: refactor default project to constants
Qiao Han39b02776129c
diff --git a/studio/pages/api/constants.ts b/studio/pages/api/constants.tsindex ae150beae97..7d40e62c010 100644--- a/studio/pages/api/constants.ts+++ b/studio/pages/api/constants.ts@@ -3,3 +3,14 @@ const PUBLIC_URL = new URL(process.env.SUPABASE_PUBLIC_URL || 'http://localhost:export const PROJECT_REST_URL = `${PUBLIC_URL.origin}/rest/v1/`export const PROJECT_ENDPOINT = PUBLIC_URL.hostexport const PROJECT_ENDPOINT_PROTOCOL = PUBLIC_URL.protocol.replace(':', '')++export const DEFAULT_PROJECT = {+ id: 1,+ ref: 'default',+ name: process.env.DEFAULT_PROJECT_NAME || 'Default Project',+ organization_id: 1,+ cloud_provider: 'localhost',+ status: 'ACTIVE_HEALTHY',+ region: 'local',+ inserted_at: '2021-08-02T06:40:40.646Z',+}diff --git a/studio/pages/api/profile/index.ts b/studio/pages/api/profile/index.tsindex 4b88292532a..a432bd209bd 100644--- a/studio/pages/api/profile/index.ts+++ b/studio/pages/api/profile/index.ts@@ -1,6 +1,7 @@import { NextApiRequest, NextApiResponse } from 'next'import apiWrapper from 'lib/api/apiWrapper'+import { DEFAULT_PROJECT } from '../constants'export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)@@ -30,18 +31,7 @@ const handleGetAll = async (req: NextApiRequest, res: NextApiResponse) => {name: process.env.DEFAULT_ORGANIZATION_NAME || 'Default Organization',slug: 'default-org-slug',billing_email: '[email protected]',- projects: [- {- id: 1,- ref: 'default',- name: process.env.DEFAULT_PROJECT_NAME || 'Default Project',- organization_id: 1,- cloud_provider: 'localhost',- status: 'ACTIVE_HEALTHY',- region: 'local',- connectionString: '',- },- ],+ projects: [{ ...DEFAULT_PROJECT, connectionString: '' }],},],}diff --git a/studio/pages/api/projects/[ref]/index.ts b/studio/pages/api/projects/[ref]/index.tsindex 8c83076216c..5d8423116b1 100644--- a/studio/pages/api/projects/[ref]/index.ts+++ b/studio/pages/api/projects/[ref]/index.ts@@ -1,7 +1,7 @@import { NextApiRequest, NextApiResponse } from 'next'import apiWrapper from 'lib/api/apiWrapper'-import { PROJECT_REST_URL } from 'pages/api/constants'+import { DEFAULT_PROJECT, PROJECT_REST_URL } from 'pages/api/constants'export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)@@ -20,13 +20,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {const handleGet = async (req: NextApiRequest, res: NextApiResponse) => {// Platform specific endpointconst response = {- id: 1,- ref: 'default',- name: process.env.DEFAULT_PROJECT_NAME || 'Default Project',- organization_id: 1,- cloud_provider: 'localhost',- status: 'ACTIVE_HEALTHY',- region: 'local',+ ...DEFAULT_PROJECT,connectionString: '',kpsVersion: 'kps-v1.0.0',restUrl: PROJECT_REST_URL,diff --git a/studio/pages/api/projects/index.ts b/studio/pages/api/projects/index.tsindex a6a20f609b3..b281d3b383a 100644--- a/studio/pages/api/projects/index.ts+++ b/studio/pages/api/projects/index.ts@@ -1,6 +1,7 @@import { NextApiRequest, NextApiResponse } from 'next'import apiWrapper from 'lib/api/apiWrapper'+import { DEFAULT_PROJECT } from '../constants'export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)@@ -18,16 +19,6 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {const handleGetAll = async (req: NextApiRequest, res: NextApiResponse) => {// Platform specific endpoint- const response = [- {- id: 1,- ref: 'default',- name: process.env.DEFAULT_PROJECT_NAME || 'Default Project',- organization_id: 1,- cloud_provider: 'localhost',- status: 'ACTIVE_HEALTHY',- region: 'local',- },- ]+ const response = [DEFAULT_PROJECT]return res.status(200).json(response)}diff --git a/studio/pages/api/props/project/[ref]/api.ts b/studio/pages/api/props/project/[ref]/api.tsindex 271614fee55..2fbf6cfc63d 100644--- a/studio/pages/api/props/project/[ref]/api.ts+++ b/studio/pages/api/props/project/[ref]/api.ts@@ -1,7 +1,12 @@import { NextApiRequest, NextApiResponse } from 'next'import apiWrapper from 'lib/api/apiWrapper'-import { PROJECT_ENDPOINT, PROJECT_ENDPOINT_PROTOCOL, PROJECT_REST_URL } from 'pages/api/constants'+import {+ DEFAULT_PROJECT,+ PROJECT_ENDPOINT,+ PROJECT_ENDPOINT_PROTOCOL,+ PROJECT_REST_URL,+} from 'pages/api/constants'export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)@@ -21,17 +26,13 @@ const handleGetAll = async (req: NextApiRequest, res: NextApiResponse) => {// Platform specific endpointconst response = {project: {+ ...DEFAULT_PROJECT,api_key_supabase_encrypted: '',db_host: 'localhost',db_name: 'postgres',db_port: 5432,db_ssl: false,db_user: 'postgres',- id: 1,- inserted_at: '2021-08-02T06:40:40.646362',- name: process.env.DEFAULT_PROJECT_NAME || 'Default Project',- ref: 'default',- status: 'ACTIVE_HEALTHY',services: [{id: 1,diff --git a/studio/pages/api/props/project/[ref]/index.ts b/studio/pages/api/props/project/[ref]/index.tsindex a197855ddaf..c7f217a2e2b 100644--- a/studio/pages/api/props/project/[ref]/index.ts+++ b/studio/pages/api/props/project/[ref]/index.ts@@ -1,6 +1,7 @@import { NextApiRequest, NextApiResponse } from 'next'import apiWrapper from 'lib/api/apiWrapper'+import { DEFAULT_PROJECT } from 'pages/api/constants'export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)@@ -20,12 +21,7 @@ const handleGetAll = async (req: NextApiRequest, res: NextApiResponse) => {// Platform specific endpointconst response = {project: {- id: 1,- ref: 'default',- name: process.env.DEFAULT_PROJECT_NAME || 'Default Project',- status: 'ACTIVE_HEALTHY',- organization_id: 1,- inserted_at: '2021-08-02T06:40:40.646362',+ ...DEFAULT_PROJECT,services: [],},}diff --git a/studio/pages/api/props/project/[ref]/settings.ts b/studio/pages/api/props/project/[ref]/settings.tsindex cefd4bdc80e..20eebfda208 100644--- a/studio/pages/api/props/project/[ref]/settings.ts+++ b/studio/pages/api/props/project/[ref]/settings.ts@@ -1,7 +1,7 @@import { NextApiRequest, NextApiResponse } from 'next'import apiWrapper from 'lib/api/apiWrapper'-import { PROJECT_ENDPOINT } from 'pages/api/constants'+import { DEFAULT_PROJECT, PROJECT_ENDPOINT } from 'pages/api/constants'export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)@@ -21,20 +21,16 @@ const handleGetAll = async (req: NextApiRequest, res: NextApiResponse) => {// Platform specific endpointconst response = {project: {+ ...DEFAULT_PROJECT,cloud_provider: 'AWS',+ region: 'ap-southeast-1',db_dns_name: '-',db_host: 'localhost',db_name: 'postgres',db_port: 5432,db_ssl: false,db_user: 'postgres',- id: 1,- inserted_at: '2021-08-02T06:40:40.646362',jwt_secret: '-',- name: process.env.DEFAULT_PROJECT_NAME || 'Default Project',- ref: 'default',- region: 'ap-southeast-1',- status: 'ACTIVE_HEALTHY',},services: [{