forked from elizaOS/eliza
-
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.
Merge pull request #21 from marvinmarnold/ma/agent-better
feat: supabase and mint
- Loading branch information
Showing
7 changed files
with
437 additions
and
167 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
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
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
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,39 @@ | ||
import { createClient } from '@supabase/supabase-js' | ||
import { IListing } from './api' | ||
|
||
if (!process.env.TWAS_SUPABASE_URL || !process.env.TWAS_SUPABASE_SERVICE_ROLE) { | ||
console.error('TWAS_SUPABASE_URL or TWAS_SUPABASE_SERVICE_ROLE is not set') | ||
throw new Error('TWAS_SUPABASE_URL or TWAS_SUPABASE_SERVICE_ROLE is not set') | ||
} | ||
|
||
// Create a single supabase client for interacting with your database | ||
export const supabase = createClient(process.env.TWAS_SUPABASE_URL, process.env.TWAS_SUPABASE_SERVICE_ROLE) | ||
|
||
export async function updateListing(id: string, updatedListing: any) { | ||
const { data, error } = await supabase | ||
.from('listings') | ||
.update(updatedListing) | ||
.eq('id', id) | ||
.select() | ||
|
||
if (error) { | ||
throw error | ||
} | ||
|
||
return data | ||
} | ||
|
||
export async function createListing(listing: IListing): Promise<IListing> { | ||
const { data, error } = await supabase | ||
.from('listings') | ||
.insert(listing) | ||
.select() | ||
|
||
if (error) { | ||
throw error | ||
} | ||
|
||
console.log('inserted listing', data) | ||
|
||
return data[0] as any as IListing | ||
} |
Oops, something went wrong.