diff --git a/test-api.cjs b/test-api.cjs new file mode 100644 index 0000000..1c1d4d7 --- /dev/null +++ b/test-api.cjs @@ -0,0 +1,26 @@ +const http = require('http'); + +const data = JSON.stringify({ + id: "default_user", height: 175, weight: 70, age: 30, gender: "male", + activityLevel: "light", goal: "maintain", bmi: 22.8, tdee: 2000, + targetCalories: 2000, targetProtein: 100, targetFat: 50, targetCarbs: 250, targetWater: 2000 +}); + +const req = http.request({ + hostname: 'localhost', + port: 3131, + path: '/api/profile', + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Content-Length': Buffer.byteLength(data) + } +}, (res) => { + let body = ''; + res.on('data', chunk => body += chunk); + res.on('end', () => console.log('Response:', res.statusCode, body)); +}); + +req.on('error', e => console.error('Error:', e)); +req.write(data); +req.end(); diff --git a/test-get.cjs b/test-get.cjs new file mode 100644 index 0000000..850a3dd --- /dev/null +++ b/test-get.cjs @@ -0,0 +1,15 @@ +const http = require('http'); + +const req = http.request({ + hostname: 'localhost', + port: 3131, + path: '/api/logs/default_user', + method: 'GET' +}, (res) => { + let body = ''; + res.on('data', chunk => body += chunk); + res.on('end', () => console.log('Response:', res.statusCode, body)); +}); + +req.on('error', e => console.error('Error:', e)); +req.end(); diff --git a/test-meal.cjs b/test-meal.cjs new file mode 100644 index 0000000..74c6b29 --- /dev/null +++ b/test-meal.cjs @@ -0,0 +1,34 @@ +const http = require('http'); + +const data = JSON.stringify({ + userId: "default_user", + date: "2026-06-09", + meal: { + id: "test1", + name: "Apple", + time: "10:00", + calories: 100, + protein: 1, + fat: 0, + carbs: 25 + } +}); + +const req = http.request({ + hostname: 'localhost', + port: 3131, + path: '/api/logs/meal', + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Content-Length': Buffer.byteLength(data) + } +}, (res) => { + let body = ''; + res.on('data', chunk => body += chunk); + res.on('end', () => console.log('Response:', res.statusCode, body)); +}); + +req.on('error', e => console.error('Error:', e)); +req.write(data); +req.end(); diff --git a/vite.config.ts b/vite.config.ts index d1203cd..b59f247 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -8,4 +8,12 @@ export default defineConfig({ react(), babel({ presets: [reactCompilerPreset()] }) ], + server: { + proxy: { + '/api': { + target: 'http://localhost:3000', + changeOrigin: true + } + } + } })