Add audited Graphs stock balances
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m33s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m33s
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
const express = require('express');
|
||||
const { authenticateAPIKey, verifyToken } = require('../auth');
|
||||
const { listStock, upsertStockItems } = require('../services/stockService');
|
||||
const { listGraphsBalanceHistory, listStock, removeGraphsBalance, saveGraphsBalance, upsertStockItems } = require('../services/stockService');
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
@@ -13,6 +13,35 @@ router.get('/stock', verifyToken, async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
router.get('/stock/:productId/graphs-balance-history', verifyToken, async (req, res) => {
|
||||
try {
|
||||
res.json(await listGraphsBalanceHistory(req.params.productId));
|
||||
} catch (error) {
|
||||
console.error('Error fetching Graphs stock balance history:', error);
|
||||
res.status(500).json({ error: 'Internal Server Error' });
|
||||
}
|
||||
});
|
||||
|
||||
router.put('/stock/:productId/graphs-balance', verifyToken, async (req, res) => {
|
||||
try {
|
||||
const balance = await saveGraphsBalance(req.params.productId, req.body, req.user?.email);
|
||||
res.json(balance);
|
||||
} catch (error) {
|
||||
console.error('Error saving Graphs stock balance:', error);
|
||||
res.status(error.statusCode || 500).json({ error: error.message || 'Internal Server Error' });
|
||||
}
|
||||
});
|
||||
|
||||
router.delete('/stock/:productId/graphs-balance', verifyToken, async (req, res) => {
|
||||
try {
|
||||
const balance = await removeGraphsBalance(req.params.productId, req.user?.email);
|
||||
res.json(balance);
|
||||
} catch (error) {
|
||||
console.error('Error removing Graphs stock balance:', error);
|
||||
res.status(error.statusCode || 500).json({ error: error.message || 'Internal Server Error' });
|
||||
}
|
||||
});
|
||||
|
||||
router.post('/stock', authenticateAPIKey, async (req, res) => {
|
||||
res.status(201).json({ message: 'Stock data received, processing in background' });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user