express-api-example/index.js

19 lines
387 B
JavaScript

require('./app/db/db.connect');
const express = require('express');
const routes = require('./app/routes');
const app = express();
const port = process.env.PORT || 8080; // set our port
app.use('/', routes);
app.use((req, res) => {
res.status(404).json({ message: 'Resource not found.' });
});
// Start the server
app.listen(port);
console.log(`Server started on port ${port}`);