Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 backend/lumens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export async function v1Handler(_: any, res: Response, next: NextFunction) {
try {
const cachedData = await getOrThrow(redisClient, "lumensV1");
const obj: CachedData = JSON.parse(cachedData);
res.setHeader(
"Cache-Control",
"public, max-age=300, stale-while-revalidate=600",
);
res.json(obj);
} catch (e) {
next(e);
Expand Down
12 changes: 11 additions & 1 deletion test/tests/integration/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,17 @@ describe("integration", function () {

describe("backend api endpoints", function () {
it("/api/lumens should return successfuly with data", async function () {
let { body } = await request(app).get("/api/lumens").expect(200);
let { body, headers } = await request(app)
.get("/api/lumens")
.expect(200)
.expect(
"Cache-Control",
"public, max-age=300, stale-while-revalidate=600",
);

chai
.expect(headers["cache-control"])
.to.include("public, max-age=300, stale-while-revalidate=600");

chai.expect(body).to.be.an("object");
chai.expect(Object.keys(body).length).to.not.equal(0);
Expand Down
Loading