00Boobs00 commited on
Commit
afe1de9
·
verified ·
1 Parent(s): 148c64e

Upload pages/api/pocketbase.js with huggingface_hub

Browse files
Files changed (1) hide show
  1. pages/api/pocketbase.js +36 -0
pages/api/pocketbase.js ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // API Proxy for PocketBase
2
+ export default async function handler(req, res) {
3
+ const PB_URL = process.env.POCKETBASE_URL || 'http://localhost:8090';
4
+ const COLLECTION = 'example_collection';
5
+
6
+ try {
7
+ if (req.method === 'GET') {
8
+ // const response = await fetch(`${PB_URL}/api/collections/${COLLECTION}/records`);
9
+ // const data = await response.json();
10
+
11
+ // Mock Data
12
+ return res.status(200).json({
13
+ items: [
14
+ { id: '1', name: 'Project Alpha', created: '2023-10-01' },
15
+ { id: '2', name: 'Deployment Test', created: '2023-10-05' },
16
+ ]
17
+ });
18
+ }
19
+
20
+ if (req.method === 'POST') {
21
+ const { name } = req.body;
22
+ // const response = await fetch(`${PB_URL}/api/collections/${COLLECTION}/records`, {
23
+ // method: 'POST',
24
+ // headers: { 'Content-Type': 'application/json' },
25
+ // body: JSON.stringify({ name }),
26
+ // });
27
+
28
+ return res.status(200).json({ success: true, id: Date.now() });
29
+ }
30
+
31
+ return res.status(405).json({ message: 'Method not allowed' });
32
+ } catch (error) {
33
+ console.error('PocketBase Error:', error);
34
+ return res.status(500).json({ message: 'Internal Server Error' });
35
+ }
36
+ }