Skip to content

Commit f97f133

Browse files
committed
Update implementation
1 parent 8290570 commit f97f133

File tree

14 files changed

+898
-72
lines changed

14 files changed

+898
-72
lines changed

dev-packages/e2e-tests/test-applications/supabase-nextjs/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"build": "next build",
88
"start": "next start",
99
"clean": "npx rimraf node_modules pnpm-lock.yaml .next",
10-
"start-local-supabase": "supabase init --force --workdir . && supabase start -o env && supabase db reset",
10+
"start-local-supabase": "supabase start -o env && supabase db reset",
1111
"test:prod": "TEST_ENV=production playwright test",
1212
"test:build": "pnpm install && pnpm start-local-supabase && pnpm build",
1313
"test:assert": "pnpm test:prod"
@@ -25,7 +25,7 @@
2525
"next": "14.2.25",
2626
"react": "18.2.0",
2727
"react-dom": "18.2.0",
28-
"supabase": "2.19.7",
28+
"supabase": "2.22.12",
2929
"typescript": "4.9.5"
3030
},
3131
"devDependencies": {
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { NextApiRequest, NextApiResponse } from 'next';
2+
import { createClient } from '@supabase/supabase-js';
3+
import * as Sentry from '@sentry/nextjs';
4+
5+
// These are the default development keys for a local Supabase instance
6+
const NEXT_PUBLIC_SUPABASE_URL = 'http://localhost:54321';
7+
const SUPABASE_SERVICE_ROLE_KEY =
8+
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU';
9+
10+
const supabaseClient = createClient(NEXT_PUBLIC_SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY, {
11+
db: {
12+
schema: 'pgmq_public',
13+
},
14+
});
15+
16+
Sentry.instrumentSupabaseClient(supabaseClient);
17+
18+
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
19+
// Enqueue a job to the queue
20+
const { data, error } = await supabaseClient.rpc('send_batch', {
21+
queue_name: 'todos',
22+
messages: [
23+
{
24+
title: 'Test Todo 1',
25+
},
26+
{
27+
title: 'Test Todo 2',
28+
},
29+
],
30+
});
31+
32+
if (error) {
33+
return res.status(500).json({ error: error.message });
34+
}
35+
36+
return res.status(200).json({ data });
37+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Enqueue a job to the queue
2+
3+
import { NextApiRequest, NextApiResponse } from 'next';
4+
import { createClient } from '@supabase/supabase-js';
5+
import * as Sentry from '@sentry/nextjs';
6+
7+
// These are the default development keys for a local Supabase instance
8+
const NEXT_PUBLIC_SUPABASE_URL = 'http://localhost:54321';
9+
const SUPABASE_SERVICE_ROLE_KEY =
10+
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU';
11+
12+
const supabaseClient = createClient(NEXT_PUBLIC_SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY);
13+
14+
Sentry.instrumentSupabaseClient(supabaseClient);
15+
16+
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
17+
// Enqueue a job to the queue
18+
const { data, error } = await supabaseClient.schema('pgmq_public').rpc('pop', {
19+
queue_name: 'non-existing-queue',
20+
});
21+
22+
if (error) {
23+
return res.status(500).json({ error: error.message });
24+
}
25+
26+
return res.status(200).json({ data });
27+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Enqueue a job to the queue
2+
3+
import { NextApiRequest, NextApiResponse } from 'next';
4+
import { createClient } from '@supabase/supabase-js';
5+
import * as Sentry from '@sentry/nextjs';
6+
7+
// These are the default development keys for a local Supabase instance
8+
const NEXT_PUBLIC_SUPABASE_URL = 'http://localhost:54321';
9+
const SUPABASE_SERVICE_ROLE_KEY =
10+
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU';
11+
12+
const supabaseClient = createClient(NEXT_PUBLIC_SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY, {
13+
db: {
14+
schema: 'pgmq_public',
15+
},
16+
});
17+
18+
Sentry.instrumentSupabaseClient(supabaseClient);
19+
20+
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
21+
// Enqueue a job to the queue
22+
const { data, error } = await supabaseClient.rpc('pop', {
23+
queue_name: 'todos',
24+
});
25+
26+
if (error) {
27+
return res.status(500).json({ error: error.message });
28+
}
29+
30+
return res.status(200).json({ data });
31+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { NextApiRequest, NextApiResponse } from 'next';
2+
import { createClient } from '@supabase/supabase-js';
3+
import * as Sentry from '@sentry/nextjs';
4+
5+
// These are the default development keys for a local Supabase instance
6+
const NEXT_PUBLIC_SUPABASE_URL = 'http://localhost:54321';
7+
const SUPABASE_SERVICE_ROLE_KEY =
8+
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU';
9+
10+
const supabaseClient = createClient(NEXT_PUBLIC_SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY);
11+
12+
Sentry.instrumentSupabaseClient(supabaseClient);
13+
14+
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
15+
// Process a job from the queue
16+
const { data, error } = await supabaseClient.schema('pgmq_public').rpc('pop', {
17+
queue_name: 'todos',
18+
});
19+
20+
if (error) {
21+
return res.status(500).json({ error: error.message });
22+
}
23+
24+
return res.status(200).json({ data });
25+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { NextApiRequest, NextApiResponse } from 'next';
2+
import { createClient } from '@supabase/supabase-js';
3+
import * as Sentry from '@sentry/nextjs';
4+
5+
// These are the default development keys for a local Supabase instance
6+
const NEXT_PUBLIC_SUPABASE_URL = 'http://localhost:54321';
7+
const SUPABASE_SERVICE_ROLE_KEY =
8+
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU';
9+
10+
const supabaseClient = createClient(NEXT_PUBLIC_SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY, {
11+
db: {
12+
schema: 'pgmq_public',
13+
},
14+
});
15+
16+
Sentry.instrumentSupabaseClient(supabaseClient);
17+
18+
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
19+
// Enqueue a job to the queue
20+
const { data, error } = await supabaseClient.rpc('send', {
21+
queue_name: 'todos',
22+
message: {
23+
title: 'Test Todo',
24+
},
25+
});
26+
27+
if (error) {
28+
return res.status(500).json({ error: error.message });
29+
}
30+
31+
return res.status(200).json({ data });
32+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { NextApiRequest, NextApiResponse } from 'next';
2+
import { createClient } from '@supabase/supabase-js';
3+
import * as Sentry from '@sentry/nextjs';
4+
5+
// These are the default development keys for a local Supabase instance
6+
const NEXT_PUBLIC_SUPABASE_URL = 'http://localhost:54321';
7+
const SUPABASE_SERVICE_ROLE_KEY =
8+
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU';
9+
10+
const supabaseClient = createClient(NEXT_PUBLIC_SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY);
11+
12+
Sentry.instrumentSupabaseClient(supabaseClient);
13+
14+
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
15+
// Enqueue a job to the queue
16+
const { data, error } = await supabaseClient.schema('pgmq_public').rpc('send', {
17+
queue_name: 'todos',
18+
message: {
19+
title: 'Test Todo',
20+
},
21+
});
22+
23+
if (error) {
24+
return res.status(500).json({ error: error.message });
25+
}
26+
27+
return res.status(200).json({ data });
28+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { NextApiRequest, NextApiResponse } from 'next';
2+
import { createClient } from '@supabase/supabase-js';
3+
import * as Sentry from '@sentry/nextjs';
4+
5+
// These are the default development keys for a local Supabase instance
6+
const NEXT_PUBLIC_SUPABASE_URL = 'http://localhost:54321';
7+
const SUPABASE_SERVICE_ROLE_KEY =
8+
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU';
9+
10+
const supabaseClient = createClient(NEXT_PUBLIC_SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY, {
11+
db: {
12+
schema: 'pgmq_public',
13+
},
14+
});
15+
16+
Sentry.instrumentSupabaseClient(supabaseClient);
17+
18+
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
19+
// Read from queue
20+
const { data, error } = await supabaseClient.rpc('read', {
21+
queue_name: 'todos',
22+
n: 2,
23+
sleep_seconds: 0,
24+
});
25+
26+
if (error) {
27+
return res.status(500).json({ error: error.message });
28+
}
29+
30+
return res.status(200).json({ data });
31+
}

dev-packages/e2e-tests/test-applications/supabase-nextjs/supabase/config.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ enabled = true
1010
port = 54321
1111
# Schemas to expose in your API. Tables, views and stored procedures in this schema will get API
1212
# endpoints. `public` and `graphql_public` schemas are included by default.
13-
schemas = ["public", "graphql_public"]
13+
schemas = ["public", "graphql_public", "storage", "pgmq_public"]
1414
# Extra schemas to add to the search_path of every request.
15-
extra_search_path = ["public", "extensions"]
15+
extra_search_path = ["public", "extensions", "pgmq_public"]
1616
# The maximum number of rows returns from a view, table, or stored procedure. Limits payload size
1717
# for accidental or malicious requests.
1818
max_rows = 1000
@@ -28,7 +28,7 @@ port = 54322
2828
shadow_port = 54320
2929
# The database major version to use. This has to be the same as your remote database's. Run `SHOW
3030
# server_version;` on the remote database to check.
31-
major_version = 15
31+
major_version = 17
3232

3333
[db.pooler]
3434
enabled = false
@@ -141,7 +141,6 @@ sign_in_sign_ups = 30
141141
# Number of OTP / Magic link verifications that can be made in a 5 minute interval per IP address.
142142
token_verifications = 30
143143

144-
145144
# Configure one of the supported captcha providers: `hcaptcha`, `turnstile`.
146145
# [auth.captcha]
147146
# enabled = true
@@ -283,6 +282,8 @@ enabled = true
283282
policy = "oneshot"
284283
# Port to attach the Chrome inspector for debugging edge functions.
285284
inspector_port = 8083
285+
# The Deno major version to use.
286+
deno_version = 1
286287

287288
# [edge_runtime.secrets]
288289
# secret_key = "env(SECRET_VALUE)"

dev-packages/e2e-tests/test-applications/supabase-nextjs/supabase/migrations/20230712094349_init.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ create policy "Individuals can view their own todos. " on todos for
1313
create policy "Individuals can update their own todos." on todos for
1414
update using (auth.uid() = user_id);
1515
create policy "Individuals can delete their own todos." on todos for
16-
delete using (auth.uid() = user_id);
16+
delete using (auth.uid() = user_id);

0 commit comments

Comments
 (0)