@project-438/sdk
v0.1.4
Published
Official TypeScript client SDK for Project-438 BaaS
Readme
@project-438/sdk
Official TypeScript SDK for Project-438 — EU-sovereign backend-as-a-service for AI-generated apps.
Auth, auto-generated REST & GraphQL APIs, object storage, migrations, and admin tools. All EU-hosted, GDPR-native.
Install
npm install @project-438/sdkQuick start
import { P438 } from '@project-438/sdk'
const app = new P438({
apiKey: process.env.P438_API_KEY,
projectId: process.env.P438_PROJECT_ID,
})
// Query data
const users = await app.db
.from('users')
.select('id', 'name', 'email')
.eq('active', true)
.limit(10)
.get()
// Insert data
await app.db.from('posts').insert({ title: 'Hello, EU.' })Modules
| Module | Description |
|--------|-------------|
| app.auth | Sign up, sign in, email verification, password reset, session management |
| app.db | Query, insert, update, and delete data with a fluent query builder |
| app.migrations | Apply and list SQL migrations |
| app.projects | Create and list projects |
| app.storage | Upload, download, and manage files in S3-compatible buckets |
| app.apiKeys | Create, list, and revoke API keys |
| app.admin | Platform admin — manage users, roles, and audit logs |
| app.serve() | Drop-in route handlers for Next.js, Hono, Cloudflare Workers, etc. |
Auth
// Sign up
const { id } = await app.auth.signUp({
email: '[email protected]',
password: 'securepassword',
})
// Sign in (stores tokens automatically)
await app.auth.signIn({
email: '[email protected]',
password: 'securepassword',
})
// Get current user
const user = await app.auth.me()Database
// Fluent query builder
const posts = await app.db
.from('posts')
.select('id', 'title')
.eq('published', true)
.order('created_at', 'desc')
.limit(20)
.get()
// Insert
await app.db.from('posts').insert({ title: 'New post', body: 'Content' })
// Update
await app.db.from('posts').eq('id', postId).update({ title: 'Updated' })
// Delete
await app.db.from('posts').eq('id', postId).delete()Migrations
// Apply a migration
await app.migrations.apply('create_posts', `
CREATE TABLE posts (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
title text NOT NULL,
body text,
created_at timestamptz DEFAULT now()
);
`)
// List applied migrations
const migrations = await app.migrations.list()Storage
// Upload a file
await app.storage.upload('avatars', 'user-1.png', file)
// Get a signed URL
const url = await app.storage.getSignedUrl('avatars', 'user-1.png')
// List objects
const { objects } = await app.storage.list('avatars')Serve (framework integration)
Drop-in route handlers that proxy requests to the Project-438 API. Works with Next.js App Router, Hono, Cloudflare Workers, and any framework that uses the Fetch API.
// app/api/p438/[...route]/route.ts (Next.js)
import { P438 } from '@project-438/sdk'
const app = new P438({ apiKey: process.env.P438_API_KEY })
export const { GET, POST, PATCH, PUT, DELETE } = app.serve()Configuration
const app = new P438({
apiKey: 'your-api-key', // Server-side API key
projectId: 'your-project-id', // Default project for db/migrations/storage
baseUrl: 'https://api.p438.io', // API URL (default)
tokenStorage: 'memory', // 'memory' (default) or 'localStorage'
})Requirements
- Node.js 18+
- Works in Node.js, browsers, Deno, Bun, and Cloudflare Workers
License
MIT
