Files
supabase/apps/studio/lib/api/supabaseClient.ts
Ivan Vasilov 436bdb10ae chore: Move the studio app to apps/studio (#18915)
* Move all studio files from /studio to /apps/studio.

* Move studio specific prettier ignores.

* Fix the ui references from studio.

* Fix the css imports.

* Fix all package.json issues.

* Fix the prettier setup for the studio app.

* Add .turbo folder to prettierignore.

* Fix the github workflows.
2023-11-15 12:38:55 +01:00

27 lines
671 B
TypeScript

import { createClient } from '@supabase/supabase-js'
import { IS_PLATFORM } from '../constants'
let readOnly: any
if (IS_PLATFORM) {
readOnly = createClient(process.env.READ_ONLY_URL ?? '', process.env.READ_ONLY_API_KEY ?? '')
const readOnlyErrMessage = Error('This client is for read-only actions. Use readWrite instead.')
// overwrites function calls
// for readOnly
readOnly.from('').insert = () => {
throw readOnlyErrMessage
}
readOnly.from('').delete = () => {
throw readOnlyErrMessage
}
readOnly.from('').update = () => {
throw readOnlyErrMessage
}
readOnly.rpc = () => {
throw readOnlyErrMessage
}
}
export { readOnly }