Help please I'm retarded.
I'm setting up a node server to fuck around with GraphQL but for some reason I can't get the Express router to work at all. None of the routes get triggered, it just loads forever.
// index.js
const appConfig = require('./config');
const express = require('express');
var app = express();
// Set up configuration variables according to the current execution environment
const environment = appConfig.environment;
const config = appConfig[environment];
const defaultPort = config.app.port;
const logLevel = config.app.logLevel;
// Set up modules
const logger = require('./src/logger')('server', logLevel);
const db = require('./src/db')(config);
const handler = require('./src/handler')(db);
const routes = require('./src/routes')(handler);
// Set up routes
app.use('/', routes);
// Start listening
const server = app.listen(process.env.PORT || defaultPort, function() {
const port = server.address().port;
logger.log('info', 'App now listening to port ' + port);
});
// src/routes/index.js
const logger = require('../logger')('routes');
const bodyParser = require('body-parser');
const express = require('express');
const router = express.Router();
module.exports = function(handler) {
logger.log('info', 'Setting up routes.')
router.use(bodyParser.json);
router.get('/', (req, res) => {
logger.log('info', '/');
res.send('Home Page');
});
router.get('/quotes', (req, res) => {
logger.log('info', '/quotes');
res.send('/quotes');
});
return router;
}
What am I missing here?