This PR mainly refactors the code by extracting a "core" package which is then used by the "backend" and "frontend" apps. Apart from this the PR also contains several smaller changes like fixing dependabot, upgrading dependencies, aligned "package.json" files, added tests, ... addresses step 1 of #32 closes #136 --------- Co-authored-by: Marco Pasqualetti <marco.pasqualetti@live.com>
42 lines
895 B
JavaScript
42 lines
895 B
JavaScript
import axios from "axios";
|
|
import MockAdapter from "axios-mock-adapter";
|
|
import { beforeAll, bench, describe, vi } from "vitest";
|
|
|
|
import { data_user } from "../utils.js";
|
|
|
|
const mock = new MockAdapter(axios);
|
|
|
|
const createResponse = () => ({
|
|
end: vi.fn(),
|
|
setHeader: vi.fn(),
|
|
});
|
|
|
|
let router;
|
|
|
|
beforeAll(async () => {
|
|
vi.stubEnv("CACHE_SECONDS", "");
|
|
vi.stubEnv("GIST_WHITELIST", "");
|
|
vi.stubEnv("POSTGRES_URL", "");
|
|
vi.stubEnv("WHITELIST", "");
|
|
|
|
({ default: router } = await import("../../router.js"));
|
|
|
|
mock.onPost("https://api.github.com/graphql").reply(200, data_user);
|
|
});
|
|
|
|
describe("bench /api/pin", () => {
|
|
bench(
|
|
"base",
|
|
async () => {
|
|
const req = {
|
|
headers: {},
|
|
url: "/api/pin?username=anuraghazra&repo=convoychat",
|
|
};
|
|
const res = createResponse();
|
|
|
|
await router(req, res);
|
|
},
|
|
{ warmupIterations: 50 },
|
|
);
|
|
});
|