-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi-routes.js
More file actions
32 lines (28 loc) · 815 Bytes
/
api-routes.js
File metadata and controls
32 lines (28 loc) · 815 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Initialize express router
let router = require("express").Router();
// Set default API response
router.get("/", function (req, res) {
res.json({
status: "API Its Working",
message: "Contact Management API ready to serve!",
});
});
// Import contact controller
var contactController = require("./contactController");
// Contact routes
router
.route("/contacts")
.get(contactController.index)
.post(contactController.new);
router
.route("/contacts/:contact_id")
.get(contactController.view)
.patch(contactController.update)
.put(contactController.update)
.delete(contactController.delete);
// Import cache controller
var cacheController = require("./cacheController");
// Contact routes
router.route("/cache").get(cacheController.get);
// Export API routes
module.exports = router;