Skip to content

Commit

Permalink
added client to lib
Browse files Browse the repository at this point in the history
  • Loading branch information
chuma-beep committed Oct 12, 2024
1 parent 4e4ae94 commit cffa58c
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 4 deletions.
77 changes: 73 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,87 @@
# name: Test
# on:
# push:
# branches:
# - '*'
# pull_request:
# branches:
# - '*'
# defaults:
# run:
# working-directory: ./
# jobs:
# build:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# node-version: [20]
# steps:
# - name: Checkout the Repository
# uses: actions/checkout@v4

# - name: Setup Node.js
# uses: actions/setup-node@v4
# with:
# node-version: ${{ matrix.node-version }}
# registry-url: 'https://registry.npmjs.org'
# cache: 'npm'

# - name: Install dependencies
# run: |
# npm install
# npm run build

# - name: Install Playwright browsers
# run: |
# npx playwright install chromium --with-deps
# npx playwright install firefox --with-deps
# npx playwright install webkit --with-deps

# - name: Run tests
# env:
# NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
# NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }}
# run: npm run test:coverage && npm run test:e2e

# - name: Upload coverage reports to Codecov
# uses: codecov/codecov-action@v4
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}



name: Test

on:
push:
branches:
- '*'
pull_request:
branches:
- '*'

defaults:
run:
working-directory: ./

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20]
env:
# Server-Side Environment Variables
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_API_KEY: ${{ secrets.SUPABASE_API_KEY }}

# Client-Side Environment Variables
NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.NEXT_PUBLIC_SUPABASE_URL }}
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }}

# Codecov Token
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

steps:
- name: Checkout the Repository
uses: actions/checkout@v4
Expand All @@ -29,6 +96,9 @@ jobs:
- name: Install dependencies
run: |
npm install
- name: Build the app
run: |
npm run build
- name: Install Playwright browsers
Expand All @@ -38,10 +108,9 @@ jobs:
npx playwright install webkit --with-deps
- name: Run tests
env:
NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }}
run: npm run test:coverage && npm run test:e2e
run: |
npm run test:coverage
npm run test:e2e
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
Expand Down
23 changes: 23 additions & 0 deletions lib/supbaseClient.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// lib/supabaseClient.js

import { createClient } from '@supabase/supabase-js';

// Server-Side
const supabaseUrl = process.env.SUPABASE_URL;
const supabaseApiKey = process.env.SUPABASE_API_KEY;

if (!supabaseUrl || !supabaseApiKey) {
throw new Error('Missing Supabase URL or API Key');
}

export const supabaseServer = createClient(supabaseUrl, supabaseApiKey);

// Client-Side
const supabasePublicUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
const supabaseAnonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;

if (!supabasePublicUrl || !supabaseAnonKey) {
throw new Error('Missing Supabase Public URL or Anon Key');
}

export const supabaseClient = createClient(supabasePublicUrl, supabaseAnonKey);

0 comments on commit cffa58c

Please sign in to comment.