Gathering detailed insights and metrics for @daveyplate/supabase-swr-entities
Gathering detailed insights and metrics for @daveyplate/supabase-swr-entities
Gathering detailed insights and metrics for @daveyplate/supabase-swr-entities
Gathering detailed insights and metrics for @daveyplate/supabase-swr-entities
npm install @daveyplate/supabase-swr-entities
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
184 Commits
1 Watching
1 Branches
1 Contributors
Updated on 21 Nov 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-94.9%
8
Compared to previous day
Last week
-69%
365
Compared to previous week
Last month
-30.5%
2,320
Compared to previous month
Last year
0%
5,656
Compared to previous year
1npm install @daveyplate/supabase-swr-entities
Create schema JSON file in root directory:
`entity.schemas.json'
1[ 2 { 3 "table": "profiles", 4 "authenticate": false, 5 "disableList": false, 6 "select": ["id", "full_name", "avatar_url", "created_at", "updated_at"], 7 "defaultOrder": "-created_at", 8 "defaultParams": { 9 "full_name_neq": null 10 }, 11 "requiredParams": { 12 "deactivated": false 13 } 14 } 15]
/pages/api/[entities]/[entity_id].js
1import { entityRoute } from '@daveyplate/supabase-swr-entities/server' 2import { createClient } from '@/utils/supabase/api' 3 4export default async (req, res) => { 5 const supabase = createClient(req, res) 6 7 const response = await entityRoute({ 8 supabase, 9 ...req 10 }) 11 12 res.status(response.status).json(response.body) 13}
/pages/api/[entities]/index.js
1import { entitiesRoute } from '@daveyplate/supabase-swr-entities/server' 2import { createClient } from '@/utils/supabase/api' 3 4export default async (req, res) => { 5 const supabase = createClient(req, res) 6 7 const response = await entitiesRoute({ 8 supabase, 9 ...req 10 }) 11 12 res.status(response.status).json(response.body) 13}
/app/api/[entities]/[entity_id]/route.js
1import { entityRoute } from '@daveyplate/supabase-swr-entities/server' 2import { createClient } from '@/utils/supabase/server' 3 4async function handler(request, context) { 5 const params = await context.params 6 7 const { nextUrl: { search } } = request 8 const urlSearchParams = new URLSearchParams(search) 9 const query = Object.fromEntries(urlSearchParams.entries()) 10 11 const body = request.method == "POST" || request.method == "PATCH" ? await request.json() : null 12 const supabase = createClient() 13 14 const response = await entityRoute({ 15 supabase, 16 method: request.method, 17 headers: request.headers, 18 query: { ...params, ...query }, 19 body 20 }) 21 22 return Response.json(response.body, { 23 status: response.status 24 }) 25} 26 27export async function GET(request, context) { 28 return await handler(request, context) 29} 30 31export async function PATCH(request, context) { 32 return await handler(request, context) 33} 34 35export async function DELETE(request, context) { 36 return await handler(request, context) 37}
/app/api/[entities]/route.js
1import { entitiesRoute } from '@daveyplate/supabase-swr-entities/server' 2import { createClient } from '@/utils/supabase/server' 3 4async function handler(request, context) { 5 const params = await context.params 6 7 const { nextUrl: { search } } = request 8 const urlSearchParams = new URLSearchParams(search) 9 const query = Object.fromEntries(urlSearchParams.entries()) 10 11 const body = request.method == "POST" || request.method == "PATCH" ? await request.json() : null 12 const supabase = createClient() 13 14 const response = await entitiesRoute({ 15 supabase, 16 method: request.method, 17 headers: request.headers, 18 query: { ...params, ...query }, 19 body 20 }) 21 22 return Response.json(response.body, { 23 status: response.status 24 }) 25} 26 27export async function GET(request, context) { 28 return await handler(request, context) 29} 30 31export async function PATCH(request, context) { 32 return await handler(request, context) 33} 34 35export async function POST(request, context) { 36 return await handler(request, context) 37} 38 39export async function DELETE(request, context) { 40 return await handler(request, context) 41}
No vulnerabilities found.
No security vulnerabilities found.