Версия 0.4.0 Добавлены скрипты для работы в Docker.
This commit is contained in:
parent
569d10a4ba
commit
f298f21edf
@ -1 +1,2 @@
|
||||
VITE_API_URL="http://localhost:3001"
|
||||
VITE_ENV="development"
|
||||
|
@ -1 +1,2 @@
|
||||
VITE_API_URL=/api
|
||||
VITE_ENV=docker
|
||||
|
@ -18,4 +18,4 @@ RUN chown -R node:node /app
|
||||
USER node
|
||||
|
||||
# Запускаем dev-сервер
|
||||
CMD ["npm", "run", "dev"]
|
||||
CMD ["npm", "run", "docker"]
|
||||
|
24
package-lock.json
generated
24
package-lock.json
generated
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "lawn-mowing-scheduler",
|
||||
"version": "0.2.5",
|
||||
"version": "0.3.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "lawn-mowing-scheduler",
|
||||
"version": "0.2.5",
|
||||
"version": "0.3.1",
|
||||
"dependencies": {
|
||||
"@libsql/client": "^0.4.0",
|
||||
"cors": "^2.8.5",
|
||||
@ -24,6 +24,7 @@
|
||||
"@vitejs/plugin-react": "^4.3.1",
|
||||
"autoprefixer": "^10.4.18",
|
||||
"concurrently": "^8.2.2",
|
||||
"cross-env": "^7.0.3",
|
||||
"eslint": "^9.9.1",
|
||||
"eslint-plugin-react-hooks": "^5.1.0-rc.0",
|
||||
"eslint-plugin-react-refresh": "^0.4.11",
|
||||
@ -2518,6 +2519,25 @@
|
||||
"node": ">= 0.10"
|
||||
}
|
||||
},
|
||||
"node_modules/cross-env": {
|
||||
"version": "7.0.3",
|
||||
"resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz",
|
||||
"integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"cross-spawn": "^7.0.1"
|
||||
},
|
||||
"bin": {
|
||||
"cross-env": "src/bin/cross-env.js",
|
||||
"cross-env-shell": "src/bin/cross-env-shell.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.14",
|
||||
"npm": ">=6",
|
||||
"yarn": ">=1"
|
||||
}
|
||||
},
|
||||
"node_modules/cross-spawn": {
|
||||
"version": "7.0.3",
|
||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
||||
|
@ -1,11 +1,13 @@
|
||||
{
|
||||
"name": "lawn-mowing-scheduler",
|
||||
"private": true,
|
||||
"version": "0.3.1",
|
||||
"version": "0.4.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "concurrently \"npm run server\" \"npm run client\"",
|
||||
"client": "vite",
|
||||
"client": "vite --mode development",
|
||||
"docker": "concurrently \"npm run server\" \"npm run docker_client\"",
|
||||
"docker_client": "vite --mode docker",
|
||||
"server": "nodemon server/index.js",
|
||||
"build": "vite build",
|
||||
"lint": "eslint .",
|
||||
@ -28,6 +30,7 @@
|
||||
"@vitejs/plugin-react": "^4.3.1",
|
||||
"autoprefixer": "^10.4.18",
|
||||
"concurrently": "^8.2.2",
|
||||
"cross-env": "^7.0.3",
|
||||
"eslint": "^9.9.1",
|
||||
"eslint-plugin-react-hooks": "^5.1.0-rc.0",
|
||||
"eslint-plugin-react-refresh": "^0.4.11",
|
||||
|
@ -1,17 +1,17 @@
|
||||
import { Zone, ZoneFormData, MowingHistoryResponse, MowingStats, MowingFormData, Mower, MowerFormData, BulkMowingFormData } from '../types/zone';
|
||||
|
||||
const API_BASE = import.meta.env.VITE_API_URL;
|
||||
const API_BASE = new URL('api', import.meta.env.VITE_API_URL).toString();
|
||||
|
||||
export const api = {
|
||||
async getZones(): Promise<Zone[]> {
|
||||
const response = await fetch(`${API_BASE}/api/zones`);
|
||||
console.log(`${API_BASE}/api/zones`);
|
||||
const response = await fetch(`${API_BASE}/zones`);
|
||||
console.log(`${API_BASE}/zones`);
|
||||
if (!response.ok) throw new Error('Failed to fetch zones');
|
||||
return response.json();
|
||||
},
|
||||
|
||||
async getZone(id: number): Promise<Zone> {
|
||||
const response = await fetch(`${API_BASE}/api/zones/${id}`);
|
||||
const response = await fetch(`${API_BASE}/zones/${id}`);
|
||||
if (!response.ok) throw new Error('Failed to fetch zone');
|
||||
return response.json();
|
||||
},
|
||||
@ -32,7 +32,7 @@ export const api = {
|
||||
formData.append('image', data.image);
|
||||
}
|
||||
|
||||
const response = await fetch(`${API_BASE}/api/zones`, {
|
||||
const response = await fetch(`${API_BASE}/zones`, {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
});
|
||||
@ -60,7 +60,7 @@ export const api = {
|
||||
formData.append('image', data.image);
|
||||
}
|
||||
|
||||
const response = await fetch(`${API_BASE}/api/zones/${id}`, {
|
||||
const response = await fetch(`${API_BASE}/zones/${id}`, {
|
||||
method: 'PUT',
|
||||
body: formData,
|
||||
});
|
||||
@ -70,14 +70,14 @@ export const api = {
|
||||
},
|
||||
|
||||
async deleteZone(id: number): Promise<void> {
|
||||
const response = await fetch(`${API_BASE}/api/zones/${id}`, {
|
||||
const response = await fetch(`${API_BASE}/zones/${id}`, {
|
||||
method: 'DELETE',
|
||||
});
|
||||
if (!response.ok) throw new Error('Failed to delete zone');
|
||||
},
|
||||
|
||||
async markAsMowed(id: number, data?: MowingFormData): Promise<Zone> {
|
||||
const response = await fetch(`${API_BASE}/api/zones/${id}/mow`, {
|
||||
const response = await fetch(`${API_BASE}/zones/${id}/mow`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@ -89,7 +89,7 @@ export const api = {
|
||||
},
|
||||
|
||||
async markAsTrimmed(id: number, data?: MowingFormData): Promise<void> {
|
||||
const response = await fetch(`${API_BASE}/api/zones/${id}/trim`, {
|
||||
const response = await fetch(`${API_BASE}/zones/${id}/trim`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@ -99,7 +99,7 @@ export const api = {
|
||||
if (!response.ok) throw new Error('Failed to mark as trimmed');
|
||||
},
|
||||
async bulkMarkAsMowed(data: BulkMowingFormData): Promise<void> {
|
||||
const response = await fetch(`${API_BASE}/api/zones/bulk-mow`, {
|
||||
const response = await fetch(`${API_BASE}/zones/bulk-mow`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@ -118,25 +118,25 @@ export const api = {
|
||||
params.append('zoneId', zoneId.toString());
|
||||
}
|
||||
|
||||
const response = await fetch(`${API_BASE}/api/history?${params}`);
|
||||
const response = await fetch(`${API_BASE}/history?${params}`);
|
||||
if (!response.ok) throw new Error('Failed to fetch mowing history');
|
||||
return response.json();
|
||||
},
|
||||
|
||||
async getMowingStats(period = 30): Promise<MowingStats> {
|
||||
const response = await fetch(`${API_BASE}/api/history/stats?period=${period}`);
|
||||
const response = await fetch(`${API_BASE}/history/stats?period=${period}`);
|
||||
if (!response.ok) throw new Error('Failed to fetch mowing statistics');
|
||||
return response.json();
|
||||
},
|
||||
|
||||
async getMowers(): Promise<Mower[]> {
|
||||
const response = await fetch(`${API_BASE}/api/mowers`);
|
||||
const response = await fetch(`${API_BASE}/mowers`);
|
||||
if (!response.ok) throw new Error('Failed to fetch mowers');
|
||||
return response.json();
|
||||
},
|
||||
|
||||
async createMower(data: MowerFormData): Promise<Mower> {
|
||||
const response = await fetch(`${API_BASE}/api/mowers`, {
|
||||
const response = await fetch(`${API_BASE}/mowers`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
Loading…
x
Reference in New Issue
Block a user