Skip to content

Commit 2f3f764

Browse files
committed
added new route to fetch user art
1 parent 75f22dd commit 2f3f764

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

controllers/arts.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ const getSelfArts = async (req, res) => {
5050
try {
5151
const { id } = req.userData;
5252
const arts = await artsQuery.fetchUserArts(id);
53+
res.set(
54+
"X-Deprecation-Warning",
55+
"WARNING: This endpoint is deprecated and will be removed in the future. Please use /arts/:userId to get the art details."
56+
);
5357
return res.json({
5458
message: "User arts returned successfully!",
5559
arts,

routes/arts.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ import arts from "../controllers/arts";
55
import artValidator from "../middlewares/validators/arts";
66

77
router.get("/", arts.fetchArts);
8-
router.get("/user/self", authenticate, arts.getSelfArts);
9-
router.get("/user/:userId", authenticate, arts.getUserArts);
8+
router.get("/user/self", authenticate, arts.getSelfArts); // this route is soon going to be deprecated soon, please use /arts/:userId endpoint.
9+
router.get("/user/:userId", authenticate, arts.getUserArts); // this route is soon going to be deprecated soon, please use /arts/:userId endpoint.
10+
router.get("/:userId", authenticate, arts.getUserArts);
1011
router.post("/user/add", authenticate, artValidator.createArt, arts.addArt);
1112

1213
module.exports = router;

test/integration/arts.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ describe("Arts", function () {
108108
expect(res.body.arts).to.be.a("array");
109109
expect(res.body.arts[0]).to.be.a("object");
110110
expect(res.body.arts[0].title).to.equal(artData[0].title);
111+
expect(res).to.have.header(
112+
"X-Deprecation-Warning",
113+
"WARNING: This endpoint is deprecated and will be removed in the future. Please use /arts/:userId to get the art details."
114+
);
111115

112116
return done();
113117
});

0 commit comments

Comments
 (0)