Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 8 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
EXPOSE 8000
CMD ["node", "index.js"]
46 changes: 46 additions & 0 deletions backend/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const express = require('express');
const cors = require('cors');
const app = express();

// Разрешим запросы с вашего фронтенда
app.use(cors({
origin: ['http://localhost:3000'] // порт вашего React dev-сервера
}));

// Данные отчёта
const reportHeader = 'Прайс Лист BionicPRO';
const columns = ['протез', 'цена'];
const rows = [
['нога', '1 млн'],
['рука', '2 млн'],
['голова', '5 млн'],
['глаз', '6 млн'],
['ягодицы', '0,5 млн'],
['почка', '10 млн'],
['жабры', '100 млн'],
['инфракрасное зрение', '100 млн'],
];

// Утилита: собрать CSV-строку
function generateCsv() {
let out = reportHeader + '\r\n';
out += columns.join(',') + '\r\n';
for (const r of rows) {
out += r.join(',') + '\r\n';
}
return out;
}

// Эндпоинт /reports
app.get('/reports', (req, res) => {
const filename = 'price_list_bionicpro.csv';
res.setHeader('Content-Type', 'text/csv; charset=utf-8');
res.setHeader('Content-Disposition', 'attachment; filename="${filename}"');
res.send(generateCsv());
});

// Стартуем на 8000 порту
const PORT = 8000;
app.listen(PORT, () => {
console.log('BionicPRO-backend listening on http://localhost:${PORT}');
});
Loading