-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
James Addison
authored and
James Addison
committed
Oct 9, 2022
1 parent
648dce5
commit 1022627
Showing
7 changed files
with
251 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules | ||
.DS_Store | ||
coverage | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import dotenv from 'dotenv' | ||
|
||
dotenv.config() | ||
|
||
export const supabaseKey = process.env.SUPABASE_KEY | ||
export const supabaseUrl = process.env.SUPABASE_URL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { createClient } from '@supabase/supabase-js' | ||
import { supabaseUrl, supabaseKey } from './config' | ||
|
||
const supabase = createClient(supabaseUrl, supabaseKey) | ||
|
||
export const getSnapshot = async (id) => { | ||
const { data, error } = await supabase | ||
.from('rooms') | ||
.select('snapshot') | ||
.is('slug', id) | ||
|
||
if (error) { | ||
// Probably doesn't exist. | ||
// Could be another error. We should check for other errors too. | ||
return [] | ||
} | ||
|
||
return JSON.parse(data[0].snapshot) | ||
} | ||
|
||
export const setSnapshot = async (id, snapshot) => { | ||
const { data, error } = await supabase | ||
.from('rooms') | ||
.insert({ snapshot: JSON.stringify(snapshot), slug: id }) | ||
.single() | ||
|
||
if (error) { | ||
return [] | ||
} | ||
|
||
return data | ||
} | ||
|
||
export default supabase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.