
Security News
Vite+ Joins the Push to Consolidate JavaScript Tooling
Evan You announces Vite+, a commercial, Rust-powered toolchain built on the Vite ecosystem to unify JavaScript development and fund open source.
@nichoth/replicache-supabase
Advanced tools
Use replicache with supabase.
This is some glue code for replicache and supabase. Use it in your lambda functions.
This is using the global version strategy.
npm i -S @nichoth/replicache-supabase
We need several environment variables for the DB:
SUPABASE_ANON_KEY="eyJhbGc..."
SUPABASE_DATABASE_PASSWORD="123abc"
SUPABASE_URL="https://my-url.supabase.co"
Use this in a lambda function.
// netlify/functions/replicache-push/replicache-push.ts
import 'dotenv/config'
import { Handler, HandlerEvent } from '@netlify/functions'
import { processPush, PushRequestSchema } from '@nichoth/replicache-supabase/push'
// mutators are specific to your application
import { Mutators } from '../../../example/mutators.js'
export const handler:Handler = async function (ev:HandlerEvent) {
if (!ev.body) return { statusCode: 400 }
const userID = (ev.headers.cookie && ev.headers.cookie['userID']) || 'anon'
const body = JSON.parse(ev.body)
const push = PushRequestSchema.parse(body)
try {
await processPush(push, userID, Mutators())
} catch (err) {
return { statusCode: 500 }
}
return { statusCode: 200, body: 'OK' }
}
Use this in a lambda function.
// netlify/functions/replicache-pull/replicache-pull.ts
import { Handler, HandlerEvent } from '@netlify/functions'
import {
authError,
processPull,
PullRequestSchema
} from '@nichoth/replicache-supabase/pull'
export const handler:Handler = async function (ev:HandlerEvent) {
if (!ev.body) return { statusCode: 400 }
const userID = (ev.headers.cookie && ev.headers.cookie['userID']) || 'anon'
const body = JSON.parse(ev.body)
const pullRequest = PullRequestSchema.parse(body)
try {
const pullResponse = await processPull(pullRequest, userID)
return { statusCode: 200, body: JSON.stringify(pullResponse) }
} catch (err) {
if (err === authError) {
return { statusCode: 401, body: 'Unauthorized' }
} else {
return {
statusCode: 500,
body: 'Error processing pull: ' + err.toString()
}
}
}
}
Run the test like this
npx esbuild test/index.ts --format=cjs --platform=node --bundle | node
FAQs
Use replicache with supabase
We found that @nichoth/replicache-supabase demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Evan You announces Vite+, a commercial, Rust-powered toolchain built on the Vite ecosystem to unify JavaScript development and fund open source.
Security News
Ruby Central’s incident report on the RubyGems.org access dispute sparks backlash from former maintainers and renewed debate over project governance.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.