setting up route with proper mini-apps with express.Router() and app.use()

This commit is contained in:
Arjun Patel
2019-01-04 16:51:27 -08:00
parent 044f947e6d
commit 518840a576
3 changed files with 26 additions and 23 deletions
+5 -4
View File
@@ -19,18 +19,19 @@ db.sequelize
});
// force: true will drop the table if it already exists
db.sequelize.sync({force: true}).then(() => {
console.log('Drop and Resync with { force: true }');
const drop_tables = true;
db.sequelize.sync({force: drop_tables}).then(() => {
console.log(`Drop and Resync with { force: ${drop_tables} }`);
});
//define a route, usually this would be a bunch of routes imported from another file
router.get('/', function (req, res, next) {
app.get('/', function (req, res, next) {
res.send('Welcome to the Ucharify API');
});
//adding routes to Express app
require('./app/routes/donors.route.js')(app);
app.use('/api/donors', require('./app/routes/donors.route.js'));
// Create a Server
var server = app.listen(port, function () {