Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new route to fetch user Art #2255

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions controllers/arts.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ const getSelfArts = async (req, res) => {
try {
const { id } = req.userData;
const arts = await artsQuery.fetchUserArts(id);
res.set(
"X-Deprecation-Warning",
"WARNING: This endpoint is deprecated and will be removed in the future. Please use /arts/:userId to get the art details."
);
return res.json({
message: "User arts returned successfully!",
arts,
Expand Down
6 changes: 4 additions & 2 deletions routes/arts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
import authenticate from "../middlewares/authenticate";
import arts from "../controllers/arts";
import artValidator from "../middlewares/validators/arts";
import { devFlagMiddleware } from "../middlewares/devFlag";

router.get("/", arts.fetchArts);
router.get("/user/self", authenticate, arts.getSelfArts);
router.get("/user/:userId", authenticate, arts.getUserArts);
router.get("/user/self", authenticate, arts.getSelfArts); // this route is soon going to be deprecated soon, please use /arts/:userId endpoint.
Dismissed Show dismissed Hide dismissed
router.get("/user/:userId", authenticate, arts.getUserArts); // this route is soon going to be deprecated soon, please use /arts/:userId endpoint.
Dismissed Show dismissed Hide dismissed
router.get("/:userId", devFlagMiddleware, authenticate, arts.getUserArts);
Dismissed Show dismissed Hide dismissed
router.post("/user/add", authenticate, artValidator.createArt, arts.addArt);

module.exports = router;
4 changes: 4 additions & 0 deletions test/integration/arts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ describe("Arts", function () {
expect(res.body.arts).to.be.a("array");
expect(res.body.arts[0]).to.be.a("object");
expect(res.body.arts[0].title).to.equal(artData[0].title);
expect(res).to.have.header(
"X-Deprecation-Warning",
"WARNING: This endpoint is deprecated and will be removed in the future. Please use /arts/:userId to get the art details."
);

return done();
});
Expand Down
Loading