-
-
Save catalinpit/885833e0c7e97917431b28139f5e080b to your computer and use it in GitHub Desktop.
The API routes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const courseController = require('../controllers/courseController'); | |
async function routes(app, opts) { | |
// Get all courses | |
app.route({ | |
method: 'GET', | |
url: '/courses', | |
handler: courseController.getCourses | |
}); | |
// Get a specific course | |
app.route({ | |
method: 'GET', | |
url: '/courses/:id', | |
handler: courseController.getSpecificCourse | |
}); | |
// Add a course | |
app.route({ | |
method: 'POST', | |
url: '/courses', | |
handler: courseController.addCourse | |
}); | |
// Edit a course | |
app.route({ | |
method: 'PUT', | |
url: '/courses/:id', | |
handler: courseController.editCourse | |
}); | |
// Delete a course | |
app.route({ | |
method: 'DELETE', | |
url: '/courses/:id', | |
handler: courseController.deleteCourse | |
}); | |
} | |
module.exports = routes; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment