- New stock_adjustments table logs every stock change (restock, order create/update/delete) with reason and reference - Orders now track payment_method and amount_paid with validation - New /api/reports endpoint with 5 aggregation queries and date filtering - Reports page with date range presets and sales, customer, revenue, status, and inventory sections - Payment fields added to OrderNew and OrderDetail pages with balance due - Girl Scouts trefoil logo added to header - Vite dev server exposed on network for mobile access Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
45 lines
1.4 KiB
JavaScript
45 lines
1.4 KiB
JavaScript
require('dotenv').config({ path: require('path').join(__dirname, '..', '.env') });
|
|
const express = require('express');
|
|
const cookieParser = require('cookie-parser');
|
|
const path = require('path');
|
|
|
|
const authRouter = require('./routes/auth');
|
|
const { authMiddleware } = require('./middleware/auth');
|
|
const productsRouter = require('./routes/products');
|
|
const customersRouter = require('./routes/customers');
|
|
const ordersRouter = require('./routes/orders');
|
|
const dashboardRouter = require('./routes/dashboard');
|
|
const reportsRouter = require('./routes/reports');
|
|
|
|
const app = express();
|
|
const PORT = process.env.PORT || 3002;
|
|
|
|
app.set('trust proxy', 1);
|
|
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
const cors = require('cors');
|
|
app.use(cors({ origin: 'http://localhost:5173', credentials: true }));
|
|
}
|
|
|
|
app.use(express.json());
|
|
app.use(cookieParser());
|
|
|
|
app.use('/api/auth', authRouter);
|
|
app.use('/api', authMiddleware);
|
|
app.use('/api/products', productsRouter);
|
|
app.use('/api/customers', customersRouter);
|
|
app.use('/api/orders', ordersRouter);
|
|
app.use('/api/dashboard', dashboardRouter);
|
|
app.use('/api/reports', reportsRouter);
|
|
|
|
if (process.env.NODE_ENV === 'production') {
|
|
app.use(express.static(path.join(__dirname, '..', 'client', 'dist')));
|
|
app.get('*', (req, res) => {
|
|
res.sendFile(path.join(__dirname, '..', 'client', 'dist', 'index.html'));
|
|
});
|
|
}
|
|
|
|
app.listen(PORT, () => {
|
|
console.log(`Server running on http://localhost:${PORT}`);
|
|
});
|