Refactor to accommodate authentication, transaction and pagination states together (#4636)

* fix: refactor to accommodate authentication, transaction and pagination together into ctx.state

* feat: allow passing response type to APIContext
This commit is contained in:
Apoorv Mishra
2023-01-04 23:51:44 +05:30
committed by GitHub
parent bb568d2e62
commit f4461573de
31 changed files with 753 additions and 675 deletions

View File

@@ -24,7 +24,7 @@ describe("Authentication middleware", () => {
},
jest.fn()
);
expect(state.user.id).toEqual(user.id);
expect(state.auth.user.id).toEqual(user.id);
});
it("should return error with invalid token", async () => {
@@ -68,7 +68,7 @@ describe("Authentication middleware", () => {
},
jest.fn()
);
expect(state.user.id).toEqual(user.id);
expect(state.auth.user.id).toEqual(user.id);
});
it("should return error with invalid API key", async () => {
const state = {} as DefaultState;
@@ -133,7 +133,7 @@ describe("Authentication middleware", () => {
},
jest.fn()
);
expect(state.user.id).toEqual(user.id);
expect(state.auth.user.id).toEqual(user.id);
});
it("should allow passing auth token in body params", async () => {
@@ -154,7 +154,7 @@ describe("Authentication middleware", () => {
},
jest.fn()
);
expect(state.user.id).toEqual(user.id);
expect(state.auth.user.id).toEqual(user.id);
});
it("should return an error for suspended users", async () => {