Restore Random_Increase helper

This commit is contained in:
Artur
2025-12-31 15:12:47 +03:00
parent a1d326aa40
commit d39f5f129e
2 changed files with 50 additions and 34 deletions

View File

@@ -16,6 +16,8 @@ const {
PASSWORD
} = process.env;
const appPort = Number(PORT) || 3000;
const app = express();
app.use(express.json());
@@ -240,9 +242,7 @@ app.put('/api/orders/:orderId/items/:itemId', async (req, res) => {
app.delete('/api/orders/:orderId/items/:itemId', async (req, res) => {
try {
await adapter.deleteOrderItem(req.params.itemId);
res.statusCode = 204;
res.message = "OK";
res.json({message: "success"});
res.status(204).end();
} catch (err){
res.statusCode = 500;
res.message = "WHOOPS";
@@ -283,11 +283,11 @@ app.use((req, res) => {
res.status(404).json({ error: 'Invalid route' });
});
app.listen(3000, async() => {
const server = app.listen(appPort, async() => {
try {
await adapter.connect();
console.log(`✅ Server running on port 3000`);
console.log(`📡 Local: http://localhost:3000`);
console.log(`✅ Server running on port ${appPort}`);
console.log(`📡 Local: http://localhost:${appPort}`);
} catch(err){
console.log("Shutting down application...");
process.exit(100);
@@ -296,8 +296,8 @@ app.listen(3000, async() => {
process.on('SIGTERM', () => {
console.log("CLOSE APP");
app.close( async() => {
server.close(async () => {
await adapter.disconnect();
console.log("DB DISCONNECTED");
});
});
});