compile42-sdk
v0.6.0
Published
Compile42 SDK - Type-safe API client for Compile42-generated applications
Downloads
230
Maintainers
Readme
@compile42/sdk
SDK for Compile42-generated applications.
Installation
npm install @compile42/sdkUsage
Initialize
import compile42 from '@compile42/sdk'
const client = compile42.init()Authentication
// Sign up
await client.auth.signUp({ email: '[email protected]', password: 'secret', metadata: { name: 'John' } })
// Sign in
await client.auth.signIn({ email: '[email protected]', password: 'secret' })
// Get current session
const session = await client.auth.getSession()
// Sign out
await client.auth.signOut()
// Listen to auth state changes
client.auth.onAuthStateChange((event, session) => {
console.log('Auth event:', event, session)
})Database
// Insert
await client.db.from('posts').insert({ title: 'Hello', body: 'World' })
// Query with chaining
const posts = await client.db
.from('posts')
.where({ published: true })
.orderBy('created_at', 'desc')
.limit(10)
// Update
await client.db.from('posts').where({ id: '123' }).update({ title: 'Updated' })
// Delete
await client.db.from('posts').where({ id: '123' }).delete()License
MIT
