created basic backend, with simple routes

This commit is contained in:
Karma Riuk
2025-04-28 10:09:10 +02:00
parent d70c8bd689
commit 89f9b323fa
4 changed files with 187 additions and 0 deletions

14
src/routes/index.js Normal file
View File

@ -0,0 +1,14 @@
const express = require('express');
const router = express.Router();
// Routes
router.get('/', (req, res) => {
res.json({ message: 'Welcome to the Express backend!' });
});
// Example route
router.get('/api/hello', (req, res) => {
res.json({ message: 'Hello from the backend!' });
});
module.exports = router;

20
src/server.js Normal file
View File

@ -0,0 +1,20 @@
const express = require('express');
const cors = require('cors');
require('dotenv').config();
const routes = require('./routes');
const app = express();
const port = process.env.PORT || 3000;
// Middleware
app.use(cors());
app.use(express.json());
// Use routes
app.use('/', routes);
// Start server
app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});