relocated routes to routes folder

This commit is contained in:
Wilkozx 2024-08-04 18:13:02 +01:00
parent 0cad380e49
commit f9c7359fd6
2 changed files with 12 additions and 4 deletions

View File

@ -4,6 +4,8 @@ const express = require('express');
// Invoke express app
const app = express();
const APIRoutes = require('./routes/api');
// Middleware to log requests
app.use((req, res, next) => {
let time = new Date().toLocaleTimeString();
@ -11,10 +13,7 @@ app.use((req, res, next) => {
next();
});
// Setup Route for Testing
app.get('/', (req, res) => {
res.json({'message': 'Hello World!'});
});
app.use(APIRoutes);
// Listen on port set in .env
app.listen(process.env.PORT, () => {

9
backend/routes/api.js Normal file
View File

@ -0,0 +1,9 @@
const express = require('express');
const APIRoutes = express.Router();
APIRoutes.get('/', (req, res) => {
res.json({'message': 'Hello World!'});
});
module.exports = APIRoutes;