File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change 11import pb from "@/lib/pocketbase" ;
22
3- const { EMAIL , PASSWORD } = process . env ;
3+ const { EMAIL , PASSWORD , COLLECTION = "budgetable" } = process . env ;
44
55async function authenticateSuperuser ( ) {
66 if ( ! EMAIL || ! PASSWORD ) {
@@ -33,7 +33,7 @@ export async function GET(
3333 ) ;
3434 }
3535
36- const record = await pb . collection ( "budgetable" ) . getOne ( id ) ;
36+ const record = await pb . collection ( COLLECTION ) . getOne ( id ) ;
3737 return Response . json ( record , {
3838 status : 200 ,
3939 headers : { "Content-Type" : "application/json" } ,
@@ -76,7 +76,7 @@ export async function DELETE(
7676 ) ;
7777 }
7878
79- await pb . collection ( "budgetable" ) . delete ( id ) ;
79+ await pb . collection ( COLLECTION ) . delete ( id ) ;
8080 return Response . json (
8181 {
8282 success : true ,
@@ -139,7 +139,7 @@ export async function PUT(
139139 ) ;
140140 }
141141
142- const updatedRecord = await pb . collection ( "budgetable" ) . update ( id , body ) ;
142+ const updatedRecord = await pb . collection ( COLLECTION ) . update ( id , body ) ;
143143 return Response . json ( updatedRecord , {
144144 status : 200 ,
145145 headers : { "Content-Type" : "application/json" } ,
Original file line number Diff line number Diff line change 11import pb from "@/lib/pocketbase" ;
22
3- const { EMAIL , PASSWORD } = process . env ;
3+ const { EMAIL , PASSWORD , COLLECTION = "budgetable" } = process . env ;
44
55async function authenticateSuperuser ( ) {
66 if ( ! EMAIL || ! PASSWORD ) {
@@ -14,7 +14,7 @@ async function authenticateSuperuser() {
1414export async function GET ( ) {
1515 try {
1616 await authenticateSuperuser ( ) ;
17- const records = await pb . collection ( "budgetable" ) . getFullList ( ) ;
17+ const records = await pb . collection ( COLLECTION ) . getFullList ( ) ;
1818 return Response . json ( records , {
1919 status : 200 ,
2020 headers : { "Content-Type" : "application/json" } ,
@@ -39,7 +39,7 @@ export async function POST(req: Request) {
3939 try {
4040 await authenticateSuperuser ( ) ;
4141 const data = await req . json ( ) ;
42- const record = await pb . collection ( "budgetable" ) . create ( data ) ;
42+ const record = await pb . collection ( COLLECTION ) . create ( data ) ;
4343 return Response . json ( record , {
4444 status : 201 ,
4545 headers : { "Content-Type" : "application/json" } ,
You can’t perform that action at this time.
0 commit comments