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
+1 -1
View File
@@ -10,7 +10,7 @@ module.exports = (sequelize, DataTypes) => {
last_name: DataTypes.STRING,
email: DataTypes.STRING,
age: DataTypes.INTEGER,
phone: DataTypes.INTEGER,
phone: DataTypes.BIGINT,
address: DataTypes.STRING,
city: DataTypes.STRING,
state: DataTypes.STRING,
+20 -18
View File
@@ -1,19 +1,21 @@
module.exports = function(app) {
const donors = require('../controllers/donors.controller.js');
// Create a new Donor
app.post('/api/donors', donors.create);
// Retrieve all Donor
app.get('/api/donors', donors.findAll);
// Retrieve a single Donor by Id
app.get('/api/donors/:DonorId', donors.findById);
const express = require('express'),
router = express.Router();
// Delete a Donor with Id
app.delete('/api/donors/:DonorId', donors.delete);
// // Update a Donor with Id
// app.put('/api/donors/:DonorId', donors.update);
}
const donors = require('../controllers/donors.controller.js');
// Create a new Donor
router.post('/', donors.create);
// Retrieve all Donor
router.get('/', donors.findAll);
// Retrieve a single Donor by Id
router.get('/:DonorId', donors.findById);
// Delete a Donor with Id
router.delete('/:DonorId', donors.delete);
// // Update a Donor with Id
// router.put('/api/donors/:DonorId', donors.update);
module.exports = router;