relocated routes to routes folder
This commit is contained in:
parent
0cad380e49
commit
f9c7359fd6
|
@ -4,6 +4,8 @@ const express = require('express');
|
||||||
// Invoke express app
|
// Invoke express app
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
|
const APIRoutes = require('./routes/api');
|
||||||
|
|
||||||
// Middleware to log requests
|
// Middleware to log requests
|
||||||
app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
let time = new Date().toLocaleTimeString();
|
let time = new Date().toLocaleTimeString();
|
||||||
|
@ -11,10 +13,7 @@ app.use((req, res, next) => {
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Setup Route for Testing
|
app.use(APIRoutes);
|
||||||
app.get('/', (req, res) => {
|
|
||||||
res.json({'message': 'Hello World!'});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Listen on port set in .env
|
// Listen on port set in .env
|
||||||
app.listen(process.env.PORT, () => {
|
app.listen(process.env.PORT, () => {
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
const express = require('express');
|
||||||
|
|
||||||
|
const APIRoutes = express.Router();
|
||||||
|
|
||||||
|
APIRoutes.get('/', (req, res) => {
|
||||||
|
res.json({'message': 'Hello World!'});
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = APIRoutes;
|
Loading…
Reference in New Issue