Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add supabase package #3675

Merged
merged 2 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/data/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export const OLD_LENS_RELAYER_ADDRESS =

// URLs
export const STATIC_ASSETS_URL = 'https://static-assets.lenster.xyz';
export const SUPABASE_URL = 'https://nberpnnqcqfnrzjpnisb.supabase.co';
export const LENS_MEDIA_SNAPSHOT_URL =
'https://ik.imagekit.io/lens/media-snapshot';
export const STATIC_IMAGES_URL = `${STATIC_ASSETS_URL}/images`;
Expand Down
3 changes: 3 additions & 0 deletions packages/supabase/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: [require.resolve('@lenster/config/eslint/base.js')]
};
1 change: 1 addition & 0 deletions packages/supabase/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const SUPABASE_URL = 'https://nberpnnqcqfnrzjpnisb.supabase.co';
11 changes: 11 additions & 0 deletions packages/supabase/createSupabaseClient.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { createClient } from '@supabase/supabase-js';

import { SUPABASE_URL } from './constants';
// @ts-ignore
import type { Database } from './database.types';

const createSupabaseClient = (key: string) => {
return createClient<Database>(SUPABASE_URL, key);
};

export default createSupabaseClient;
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export interface Database {
channels: {
Row: {
avatar: string;
cover: string;
description: string;
id: string;
name: string;
Expand All @@ -21,7 +20,6 @@ export interface Database {
};
Insert: {
avatar: string;
cover: string;
description: string;
id?: string;
name: string;
Expand All @@ -30,7 +28,6 @@ export interface Database {
};
Update: {
avatar?: string;
cover?: string;
description?: string;
id?: string;
name?: string;
Expand Down
21 changes: 21 additions & 0 deletions packages/supabase/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "@lenster/supabase",
"version": "0.0.0",
"private": true,
"license": "AGPL-3.0",
"scripts": {
"codegen": "supabase gen types typescript --project-id nberpnnqcqfnrzjpnisb > database.types.ts; pnpm lint:fix",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --fix --ext .ts",
"prettier": "prettier --check \"**/*.{js,ts,tsx,md}\" --cache",
"prettier:fix": "prettier --write \"**/*.{js,ts,tsx,md}\" --cache",
"typecheck": "tsc --pretty"
},
"dependencies": {
"@supabase/supabase-js": "^2.33.1"
},
"devDependencies": {
"@lenster/config": "workspace:*",
"typescript": "^5.2.2"
}
}
3 changes: 3 additions & 0 deletions packages/supabase/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@lenster/config/base.tsconfig.json"
}
3 changes: 1 addition & 2 deletions packages/workers/channels/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"private": true,
"license": "AGPL-3.0",
"scripts": {
"codegen": "supabase gen types typescript --project-id nberpnnqcqfnrzjpnisb > src/database.types.ts; pnpm lint:fix",
"dev": "wrangler dev --port 8093",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --fix --ext .ts",
Expand All @@ -16,8 +15,8 @@
"dependencies": {
"@lenster/data": "workspace:*",
"@lenster/lib": "workspace:*",
"@lenster/supabase": "workspace:*",
"@sentry/tracing": "^7.66.0",
"@supabase/supabase-js": "^2.33.1",
"itty-router": "^4.0.22",
"toucan-js": "^3.2.3",
"zod": "^3.22.2"
Expand Down
4 changes: 2 additions & 2 deletions packages/workers/channels/src/handlers/allChannels.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import '@sentry/tracing';

import response from '@lenster/lib/response';
import createSupabaseClient from '@lenster/supabase/createSupabaseClient';

import createSupabaseClient from '../helpers/createSupabaseClient';
import type { WorkerRequest } from '../types';

export default async (request: WorkerRequest) => {
Expand All @@ -14,7 +14,7 @@ export default async (request: WorkerRequest) => {
const cache = await request.env.CHANNELS.get('channels-list');

if (!cache) {
const client = createSupabaseClient(request.env);
const client = createSupabaseClient(request.env.SUPABASE_KEY);
const { data } = await client.from('channels').select('*');
await request.env.CHANNELS.put('channels-list', JSON.stringify(data));

Expand Down
12 changes: 0 additions & 12 deletions packages/workers/channels/src/helpers/createSupabaseClient.ts

This file was deleted.

3 changes: 1 addition & 2 deletions packages/workers/preferences/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"private": true,
"license": "AGPL-3.0",
"scripts": {
"codegen": "supabase gen types typescript --project-id nberpnnqcqfnrzjpnisb > src/database.types.ts; pnpm lint:fix",
"dev": "wrangler dev --port 8092",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --fix --ext .ts",
Expand All @@ -16,8 +15,8 @@
"dependencies": {
"@lenster/data": "workspace:*",
"@lenster/lib": "workspace:*",
"@lenster/supabase": "workspace:*",
"@sentry/tracing": "^7.66.0",
"@supabase/supabase-js": "^2.33.1",
"@tsndr/cloudflare-worker-jwt": "^2.2.2",
"itty-router": "^4.0.22",
"toucan-js": "^3.2.3",
Expand Down
4 changes: 2 additions & 2 deletions packages/workers/preferences/src/handlers/getPreferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import '@sentry/tracing';

import { Errors } from '@lenster/data/errors';
import response from '@lenster/lib/response';
import createSupabaseClient from '@lenster/supabase/createSupabaseClient';

import createSupabaseClient from '../helpers/createSupabaseClient';
import type { WorkerRequest } from '../types';

export default async (request: WorkerRequest) => {
Expand All @@ -18,7 +18,7 @@ export default async (request: WorkerRequest) => {
}

try {
const client = createSupabaseClient(request.env);
const client = createSupabaseClient(request.env.SUPABASE_KEY);

const { data } = await client
.from('rights')
Expand Down
4 changes: 2 additions & 2 deletions packages/workers/preferences/src/handlers/getVerified.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import '@sentry/tracing';

import response from '@lenster/lib/response';
import createSupabaseClient from '@lenster/supabase/createSupabaseClient';

import createSupabaseClient from '../helpers/createSupabaseClient';
import type { WorkerRequest } from '../types';

export default async (request: WorkerRequest) => {
Expand All @@ -14,7 +14,7 @@ export default async (request: WorkerRequest) => {
const cache = await request.env.PREFERENCES.get('verified-list');

if (!cache) {
const client = createSupabaseClient(request.env);
const client = createSupabaseClient(request.env.SUPABASE_KEY);

const { data } = await client
.from('rights')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { Errors } from '@lenster/data/errors';
import hasOwnedLensProfiles from '@lenster/lib/hasOwnedLensProfiles';
import response from '@lenster/lib/response';
import validateLensAccount from '@lenster/lib/validateLensAccount';
import createSupabaseClient from '@lenster/supabase/createSupabaseClient';
import jwt from '@tsndr/cloudflare-worker-jwt';
import { boolean, object, string } from 'zod';

import createSupabaseClient from '../helpers/createSupabaseClient';
import type { WorkerRequest } from '../types';

type ExtensionRequest = {
Expand Down Expand Up @@ -57,7 +57,7 @@ export default async (request: WorkerRequest) => {
);
}

const client = createSupabaseClient(request.env);
const client = createSupabaseClient(request.env.SUPABASE_KEY);

const { data, error } = await client
.from('rights')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { adminAddresses } from '@lenster/data/staffs';
import hasOwnedLensProfiles from '@lenster/lib/hasOwnedLensProfiles';
import response from '@lenster/lib/response';
import validateLensAccount from '@lenster/lib/validateLensAccount';
import createSupabaseClient from '@lenster/supabase/createSupabaseClient';
import jwt from '@tsndr/cloudflare-worker-jwt';
import { boolean, object, string } from 'zod';

import createSupabaseClient from '../helpers/createSupabaseClient';
import type { WorkerRequest } from '../types';

type ExtensionRequest = {
Expand Down Expand Up @@ -83,7 +83,7 @@ export default async (request: WorkerRequest) => {
);
}

const client = createSupabaseClient(request.env);
const client = createSupabaseClient(request.env.SUPABASE_KEY);

const { data, error } = await client
.from('rights')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { Errors } from '@lenster/data/errors';
import hasOwnedLensProfiles from '@lenster/lib/hasOwnedLensProfiles';
import response from '@lenster/lib/response';
import validateLensAccount from '@lenster/lib/validateLensAccount';
import createSupabaseClient from '@lenster/supabase/createSupabaseClient';
import jwt from '@tsndr/cloudflare-worker-jwt';
import { boolean, object, string } from 'zod';

import createSupabaseClient from '../helpers/createSupabaseClient';
import type { WorkerRequest } from '../types';

type ExtensionRequest = {
Expand Down Expand Up @@ -57,7 +57,7 @@ export default async (request: WorkerRequest) => {
);
}

const client = createSupabaseClient(request.env);
const client = createSupabaseClient(request.env.SUPABASE_KEY);

const { data, error } = await client
.from('rights')
Expand Down

This file was deleted.

25 changes: 19 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading