mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-24 06:06:02 +09:00
32 lines
684 B
JavaScript
32 lines
684 B
JavaScript
const express = require('express');
|
|
const cors = require('cors');
|
|
require('dotenv').config();
|
|
|
|
const app = express();
|
|
const port = process.env.PORT || 3000;
|
|
|
|
// Middleware
|
|
app.use(cors());
|
|
app.use(express.json());
|
|
app.use(express.urlencoded({ extended: true }));
|
|
|
|
// Routes
|
|
app.use('/api/users', require('./routes/users'));
|
|
|
|
// Health check
|
|
app.get('/health', (req, res) => {
|
|
res.json({ status: 'healthy', service: 'REST API' });
|
|
});
|
|
|
|
// Error handling
|
|
app.use((err, req, res, next) => {
|
|
console.error(err.stack);
|
|
res.status(500).json({ error: 'Internal server error' });
|
|
});
|
|
|
|
app.listen(port, () => {
|
|
console.log(`Server running on port ${port}`);
|
|
});
|
|
|
|
module.exports = app;
|