Skip to content
This repository has been archived by the owner on Jan 28, 2024. It is now read-only.

Commit

Permalink
chore: add jsconfig; type check js (#1436)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs committed Aug 13, 2023
1 parent 30a384a commit 88c8122
Show file tree
Hide file tree
Showing 18 changed files with 113 additions and 21 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ src/
.pm2.config.js
.prettierignore
.prettierrc
jsconfig.json
CHANGELOG.md
CODE_OF_CONDUCT.md
CONTRIBUTING.md
Expand Down
11 changes: 11 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"compilerOptions": {
// Uncomment as and when needed
// "checkJs": true,
// "strict": true,
"lib": ["ES2022"],
"moduleResolution": "nodenext",
"resolveJsonModule": true
},
"exclude": ["dist", "node_modules"]
}
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"devDependencies": {
"@commitlint/cli": "^17.7.1",
"@commitlint/config-conventional": "^17.7.0",
"@types/jest": "^29.5.3",
"autocannon": "^7.12.0",
"esbuild": "^0.18.14",
"esbuild-plugin-glob": "^2.2.2",
Expand Down
1 change: 1 addition & 0 deletions scripts/license-checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

const { promisify } = require("util");
const { init } = require("license-checker");
// @ts-ignore
const copyLeftLicenses = require("spdx-copyleft");
const path = require("upath");

Expand Down
7 changes: 5 additions & 2 deletions src/migrate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ jest.mock("postgrator");
// Mock MSSQL and PostgreSQL clients to prevent DB connection attempts
jest.mock("mssql", () => ({
ConnectionPool: jest.fn().mockImplementation(() => ({
connect: jest.fn().mockResolvedValue(),
close: jest.fn().mockResolvedValue(),
connect: jest.fn().mockResolvedValue(undefined),
close: jest.fn().mockResolvedValue(undefined),
config: { database: "test" },
})),
}));
Expand Down Expand Up @@ -49,6 +49,7 @@ describe("Migrate script", () => {
// Used to silence log printing to CLI
.mockImplementation(() => {});

// @ts-ignore
Postgrator.mockImplementation(() => ({ migrate: mockMigrate }));

await migrate();
Expand All @@ -71,6 +72,7 @@ describe("Migrate script", () => {
// Used to silence log printing to CLI
.mockImplementation(() => {});

// @ts-ignore
Postgrator.mockImplementation(() => ({ migrate: mockMigrate }));

await migrate();
Expand All @@ -91,6 +93,7 @@ describe("Migrate script", () => {
// Used to silence log printing to CLI
.mockImplementation(() => {});

// @ts-ignore
Postgrator.mockImplementation(() => ({ migrate: mockMigrate }));

await migrate();
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/clean-object/plugin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ const Fastify = require("fastify");
const plugin = require(".");

describe("Clean-Object plugin", () => {
/**
* @type {Fastify.FastifyInstance}
*/
let server;

beforeAll(async () => {
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/convert-date-param-operator/plugin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ const Fastify = require("fastify");
const plugin = require(".");

describe("Convert-Date-Param-Operator plugin", () => {
/**
* @type {Fastify.FastifyInstance}
*/
let server;

beforeAll(async () => {
Expand Down
7 changes: 5 additions & 2 deletions src/plugins/db/plugin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,22 @@ const getConfig = require("../../config");
// Mock MSSQL and PostgreSQL clients to prevent DB connection attempts
jest.mock("mssql", () => ({
connect: jest.fn().mockResolvedValue({
close: jest.fn().mockResolvedValue(),
close: jest.fn().mockResolvedValue(undefined),
}),
query: jest.fn().mockResolvedValue({ recordsets: [[{ example: "test" }]] }),
}));
jest.mock("pg", () => ({
Pool: jest.fn().mockImplementation(() => ({
end: jest.fn().mockResolvedValue(),
end: jest.fn().mockResolvedValue(undefined),
query: jest.fn().mockResolvedValue({ rows: [{ example: "test" }] }),
})),
}));

describe("DB plugin", () => {
let config;
/**
* @type {Fastify.FastifyInstance}
*/
let server;

const query = "SELECT 'test' AS \"example\"";
Expand Down
7 changes: 5 additions & 2 deletions src/routes/admin/access/bearer-token/route.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ describe("Access route", () => {
];
describe.each(connectionTests)("$testName", ({ envVariables, mocks }) => {
let config;
/**
* @type {Fastify.FastifyInstance}
*/
let server;

beforeAll(async () => {
Expand Down Expand Up @@ -377,8 +380,8 @@ describe("Access route", () => {
"access.scopes": "documents/register.search",
"meta.created": testDate1,
"meta.last_updated": testDate1,
per_page: testPage,
page: testPage,
per_page: `${testPage}`,
page: `${testPage}`,
},
});

Expand Down
3 changes: 3 additions & 0 deletions src/routes/admin/healthcheck/route.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ const sharedSchemas = require("../../../plugins/shared-schemas");
describe("Healthcheck route", () => {
describe("GET requests", () => {
let config;
/**
* @type {Fastify.FastifyInstance}
*/
let server;

beforeAll(async () => {
Expand Down
3 changes: 3 additions & 0 deletions src/routes/docs/openapi/route.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ const sharedSchemas = require("../../../plugins/shared-schemas");
describe("OpenAPI route", () => {
describe("GET requests", () => {
let config;
/**
* @type {Fastify.FastifyInstance}
*/
let server;

beforeAll(async () => {
Expand Down
3 changes: 3 additions & 0 deletions src/routes/docs/route.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ const sharedSchemas = require("../../plugins/shared-schemas");
describe("Docs route", () => {
describe("GET requests", () => {
let config;
/**
* @type {Fastify.FastifyInstance}
*/
let server;

beforeAll(async () => {
Expand Down
8 changes: 7 additions & 1 deletion src/routes/documents/receipt/route.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const getConfig = require("../../../config");
const sharedSchemas = require("../../../plugins/shared-schemas");

const testId = 1;
const testPatientId = 9999999999;
const testPatientId = "9999999999";
const testTimeStamp = "2018-08-01T03:51:54.000Z";

describe("Receipt route", () => {
Expand Down Expand Up @@ -40,6 +40,9 @@ describe("Receipt route", () => {
connectionTests.forEach((testObject) => {
describe(`${testObject.testName} - with request scopes`, () => {
let config;
/**
* @type {Fastify.FastifyInstance}
*/
let server;

beforeAll(async () => {
Expand Down Expand Up @@ -227,6 +230,9 @@ describe("Receipt route", () => {

describe(`${testObject.testName} - without request scopes`, () => {
let config;
/**
* @type {Fastify.FastifyInstance}
*/
let server;

beforeAll(async () => {
Expand Down
26 changes: 16 additions & 10 deletions src/routes/documents/register/route.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ describe("Register route", () => {
connectionTests.forEach((testObject) => {
describe(`${testObject.testName} - with request scopes`, () => {
let config;
/**
* @type {Fastify.FastifyInstance}
*/
let server;

beforeAll(async () => {
Expand Down Expand Up @@ -149,8 +152,8 @@ describe("Register route", () => {
url: "/",
query: {
lastModified: testLastModified1,
perPage: testPage,
page: testPage,
perPage: `${testPage}`,
page: `${testPage}`,
},
});

Expand All @@ -171,8 +174,8 @@ describe("Register route", () => {
url: "/",
query: {
lastModified: testLastModified1,
perPage: testPage,
page: testPage,
perPage: `${testPage}`,
page: `${testPage}`,
},
});

Expand Down Expand Up @@ -222,8 +225,8 @@ describe("Register route", () => {
testLastModified1,
testLastModified2,
],
perPage: testPage,
page: testPage,
perPage: `${testPage}`,
page: `${testPage}`,
},
});

Expand Down Expand Up @@ -268,8 +271,8 @@ describe("Register route", () => {
url: "/",
query: {
lastModified: testLastModified1,
perPage: testPage,
page: testPage,
perPage: `${testPage}`,
page: `${testPage}`,
},
});

Expand All @@ -286,6 +289,9 @@ describe("Register route", () => {

describe(`${testObject.testName} - without request scopes`, () => {
let config;
/**
* @type {Fastify.FastifyInstance}
*/
let server;

beforeAll(async () => {
Expand Down Expand Up @@ -315,8 +321,8 @@ describe("Register route", () => {
url: "/",
query: {
lastModified: testLastModified1,
perPage: testPage,
page: testPage,
perPage: `${testPage}`,
page: `${testPage}`,
},
});

Expand Down
6 changes: 6 additions & 0 deletions src/routes/preferences/options/route.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ describe("Options route", () => {
connectionTests.forEach((testObject) => {
describe(`${testObject.testName} - with request scopes`, () => {
let config;
/**
* @type {Fastify.FastifyInstance}
*/
let server;

beforeAll(async () => {
Expand Down Expand Up @@ -192,6 +195,9 @@ describe("Options route", () => {

describe(`${testObject.testName} - without request scopes`, () => {
let config;
/**
* @type {Fastify.FastifyInstance}
*/
let server;

beforeAll(async () => {
Expand Down
6 changes: 6 additions & 0 deletions src/routes/preferences/user/route.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ describe("User route", () => {
connectionTests.forEach((testObject) => {
describe(`${testObject.testName} - with request scopes`, () => {
let config;
/**
* @type {Fastify.FastifyInstance}
*/
let server;

beforeAll(async () => {
Expand Down Expand Up @@ -352,6 +355,9 @@ describe("User route", () => {

describe(`${testObject.testName} - without request scopes`, () => {
let config;
/**
* @type {Fastify.FastifyInstance}
*/
let server;

beforeAll(async () => {
Expand Down
Loading

0 comments on commit 88c8122

Please sign in to comment.