Files
DELIVER_MAN/server.js
2025-12-27 17:15:45 +03:00

37 lines
921 B
JavaScript

const express = require('express');
const app = express();
const PORT = process.env.PORT || 3000;
app.use(express.json());
app.get('/', (req, res) => {
res.json({ message: 'Server is running!', status: 'OK' });
});
app.get('/health', (req, res) => {
res.status(200).json({ status: 'healthy', timestamp: new Date().toISOString() });
});
// Example POST route
app.post('/api/data', (req, res) => {
const data = req.body;
res.json({
message: 'Data received',
data: data,
timestamp: new Date().toISOString()
});
});
app.use((req, res) => {
res.status(404).json({ error: 'Route not found' });
});
app.use((err, req, res, next) => {
console.error(err.stack);
res.status(500).json({ error: 'Something went wrong!' });
});
app.listen(PORT, () => {
console.log(`✅ Server running on port ${PORT}`);
console.log(`📡 Local: http://localhost:${PORT}`);
});