Revert API docs snippets changes

This commit is contained in:
Joshen Lim committed 2023-09-19 16:46:48 +08:00
1 parent bc66a537b8
commit c8aae043b6
1 file changed
+29 -6
+29 -6
View File
@@ -56,27 +56,28 @@ Future<void> main() async {
}`,
},
}),
authKey: (title: string, varName: string, apiKey: string) => ({
authKey: (title: string, varName: string, apikey: string) => ({
title: `${title}`,
bash: {
language: 'bash',
code: `${apiKey}`,
code: `${apikey}`,
},
js: {
language: 'js',
code: `const ${varName} = '${apiKey}'`,
code: `const ${varName} = '${apikey}'`,
},
}),
authKeyExample: (
defaultApiKey: string,
endpoint: string,
{ keyName, showBearer = true }: { keyName?: string; showBearer?: boolean }
{ keyName, showBearer = true }: { keyName: string; showBearer: boolean }
) => ({
title: 'Example usage',
bash: {
language: 'bash',
code: `
curl '${endpoint}/rest/v1/' ${
curl '${endpoint}/rest/v1/' \\
-H "apikey: ${defaultApiKey}" ${
showBearer
? `\\
-H "Authorization: Bearer ${defaultApiKey}"`
@@ -125,7 +126,8 @@ const supabase = createClient(SUPABASE_URL, process.env.${keyName || 'SUPABASE_K
language: 'bash',
code: `
curl -X POST '${endpoint}/rest/v1/rpc/${rpcName}' \\${bashParams}
-H "Content-Type: application/json" ${
-H "Content-Type: application/json" \\
-H "apikey: ${apiKey}" ${
showBearer
? `\\
-H "Authorization: Bearer ${apiKey}"`
@@ -251,6 +253,7 @@ const ${listenerName} = supabase.channel('custom-filter-channel')
language: 'bash',
code: `
curl '${endpoint}/rest/v1/${resourceId}?select=*' \\
-H "apikey: ${apiKey}" \\
-H "Authorization: Bearer ${apiKey}"
`,
},
@@ -281,6 +284,7 @@ let { data: ${resourceId}, error } = await supabase
language: 'bash',
code: `
curl '${endpoint}/rest/v1/${resourceId}?select=${columnName}' \\
-H "apikey: ${apiKey}" \\
-H "Authorization: Bearer ${apiKey}"
`,
},
@@ -299,6 +303,7 @@ let { data: ${resourceId}, error } = await supabase
language: 'bash',
code: `
curl '${endpoint}/rest/v1/${resourceId}?select=some_column,other_table(foreign_key)' \\
-H "apikey: ${apiKey}" \\
-H "Authorization: Bearer ${apiKey}"
`,
},
@@ -322,6 +327,7 @@ let { data: ${resourceId}, error } = await supabase
language: 'bash',
code: `
curl '${endpoint}/rest/v1/${resourceId}?select=*' \\
-H "apikey: ${apiKey}" \\
-H "Authorization: Bearer ${apiKey}" \\
-H "Range: 0-9"
`,
@@ -342,6 +348,7 @@ let { data: ${resourceId}, error } = await supabase
language: 'bash',
code: `
curl '${endpoint}/rest/v1/${resourceId}?id=eq.1&select=*' \\
-H "apikey: ${apiKey}" \\
-H "Authorization: Bearer ${apiKey}" \\
-H "Range: 0-9"
`,
@@ -378,6 +385,7 @@ let { data: ${resourceId}, error } = await supabase
language: 'bash',
code: `
curl -X POST '${endpoint}/rest/v1/${resourceId}' \\
-H "apikey: ${apiKey}" \\
-H "Authorization: Bearer ${apiKey}" \\
-H "Content-Type: application/json" \\
-H "Prefer: return=minimal" \\
@@ -402,6 +410,7 @@ const { data, error } = await supabase
language: 'bash',
code: `
curl -X POST '${endpoint}/rest/v1/${resourceId}' \\
-H "apikey: ${apiKey}" \\
-H "Authorization: Bearer ${apiKey}" \\
-H "Content-Type: application/json" \\
-d '[{ "some_column": "someValue" }, { "other_column": "otherValue" }]'
@@ -426,6 +435,7 @@ const { data, error } = await supabase
language: 'bash',
code: `
curl -X POST '${endpoint}/rest/v1/${resourceId}' \\
-H "apikey: ${apiKey}" \\
-H "Authorization: Bearer ${apiKey}" \\
-H "Content-Type: application/json" \\
-H "Prefer: resolution=merge-duplicates" \\
@@ -448,6 +458,7 @@ const { data, error } = await supabase
language: 'bash',
code: `
curl -X PATCH '${endpoint}/rest/v1/${resourceId}?some_column=eq.someValue' \\
-H "apikey: ${apiKey}" \\
-H "Authorization: Bearer ${apiKey}" \\
-H "Content-Type: application/json" \\
-H "Prefer: return=minimal" \\
@@ -471,6 +482,7 @@ const { data, error } = await supabase
language: 'bash',
code: `
curl -X DELETE '${endpoint}/rest/v1/${resourceId}?some_column=eq.someValue' \\
-H "apikey: ${apiKey}" \\
-H "Authorization: Bearer ${apiKey}"
`,
},
@@ -490,6 +502,7 @@ const { error } = await supabase
language: 'bash',
code: `
curl -X POST '${endpoint}/auth/v1/signup' \\
-H "apikey: ${apiKey}" \\
-H "Content-Type: application/json" \\
-d '{
"email": "someone@email.com",
@@ -513,6 +526,7 @@ let { data, error } = await supabase.auth.signUp({
language: 'bash',
code: `
curl -X POST '${endpoint}/auth/v1/token?grant_type=password' \\
-H "apikey: ${apiKey}" \\
-H "Content-Type: application/json" \\
-d '{
"email": "someone@email.com",
@@ -536,6 +550,7 @@ let { data, error } = await supabase.auth.signInWithPassword({
language: 'bash',
code: `
curl -X POST '${endpoint}/auth/v1/magiclink' \\
-H "apikey: ${apiKey}" \\
-H "Content-Type: application/json" \\
-d '{
"email": "someone@email.com"
@@ -557,6 +572,7 @@ let { data, error } = await supabase.auth.signInWithOtp({
language: 'bash',
code: `
curl -X POST '${endpoint}/auth/v1/signup' \\
-H "apikey: ${apiKey}" \\
-H "Content-Type: application/json" \\
-d '{
"phone": "+13334445555",
@@ -580,6 +596,7 @@ let { data, error } = await supabase.auth.signUp({
language: 'bash',
code: `
curl -X POST '${endpoint}/auth/v1/otp' \\
-H "apikey: ${apiKey}" \\
-H "Content-Type: application/json" \\
-d '{
"phone": "+13334445555"
@@ -601,6 +618,7 @@ let { data, error } = await supabase.auth.signInWithOtp({
language: 'bash',
code: `
curl -X POST '${endpoint}/auth/v1/verify' \\
-H "apikey: ${apiKey}" \\
-H "Content-Type: application/json" \\
-d '{
"type": "sms",
@@ -626,6 +644,7 @@ let { data, error } = await supabase.auth.verifyOtp({
language: 'bash',
code: `
curl -X POST '${endpoint}/auth/v1/invite' \\
-H "apikey: ${apiKey}" \\
-H "Authorization: Bearer ${apiKey}" \\
-H "Content-Type: application/json" \\
-d '{
@@ -661,6 +680,7 @@ let { data, error } = await supabase.auth.signInWithOAuth({
language: 'bash',
code: `
curl -X GET '${endpoint}/auth/v1/user' \\
-H "apikey: ${apiKey}" \\
-H "Authorization: Bearer USER_TOKEN"
`,
},
@@ -677,6 +697,7 @@ const { data: { user } } = await supabase.auth.getUser()
language: 'bash',
code: `
curl -X POST '${endpoint}/auth/v1/recover' \\
-H "apikey: ${apiKey}" \\
-H "Content-Type: application/json" \\
-d '{
"email": "someone@email.com"
@@ -696,6 +717,7 @@ let { data, error } = await supabase.auth.resetPasswordForEmail(email)
language: 'bash',
code: `
curl -X PUT '${endpoint}/auth/v1/user' \\
-H "apikey: ${apiKey}" \\
-H "Authorization: Bearer <USERS-ACCESS-TOKEN>" \\
-H "Content-Type: application/json" \\
-d '{
@@ -724,6 +746,7 @@ const { data, error } = await supabase.auth.updateUser({
language: 'bash',
code: `
curl -X POST '${endpoint}/auth/v1/logout' \\
-H "apikey: ${apiKey}" \\
-H "Content-Type: application/json" \\
-H "Authorization: Bearer USER_TOKEN"
`,