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

Commit

Permalink
Merge pull request #1352 from Fdawgs/chore/types
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs committed Jun 22, 2023
2 parents 863f34c + 42ad0cc commit 650c45d
Show file tree
Hide file tree
Showing 25 changed files with 30 additions and 27 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ module.exports = {
root: true,
rules: {
"import/no-extraneous-dependencies": "error",
"jsdoc/require-hyphen-before-param-description": "error",
"no-multiple-empty-lines": ["error", { max: 1 }],
"prefer-destructuring": ["error", { object: true, array: false }],
"promise/prefer-await-to-callbacks": "warn",
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
> **Note**
> This repository is unmaintained as of 2023-05-03 as
> I am no longer employed by Somerset NHS Foundation Trust.
> As of 2023-05-03 as I am no longer employed by Somerset NHS Foundation Trust.
> However, this repository will continue to be maintained as it acts as
> a 'canary in the coalmine' for changes to Node and other dependencies.
<a href="https://somersetft.nhs.uk/yeovilhospital/">
<img alttext="Somerset NHSFT logo" src="https://raw.githubusercontent.com/Fdawgs/yh-myydh-crud-api/main/docs/images/somerset-nhsft-logo-left-aligned-transparent-background.png" width="480" />
Expand Down
2 changes: 1 addition & 1 deletion src/config/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require("dotenv").config();

const envSchema = require("env-schema");
const S = require("fluent-json-schema");
const S = require("fluent-json-schema").default;
const fs = require("fs/promises");
const path = require("upath");
const pino = require("pino");
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/clean-object/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function cleanObject(object = {}) {
* @author Frazer Smith
* @description Plugin that decorates Fastify instance with `cleanObject` function,
* which removes key value pairs from an object where the value is null or undefined.
* @param {object} server - Fastify instance.
* @param {import("fastify").FastifyInstance} server - Fastify instance.
*/
async function plugin(server) {
server.decorate("cleanObject", cleanObject);
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/convert-date-param-operator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function convDateParamOperator(operator) {
* @author Frazer Smith
* @description Plugin that decorates Fastify instance with `convertDateParamOperator` function,
* which convert date param operators to corresponding values.
* @param {object} server - Fastify instance.
* @param {import("fastify").FastifyInstance} server - Fastify instance.
*/
async function plugin(server) {
server.decorate("convertDateParamOperator", convDateParamOperator);
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/db/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const mssql = require("mssql");
/**
* @author Frazer Smith
* @description Decorator plugin that adds Microsoft SQL Server or PostgreSQL client.
* @param {object} server - Fastify instance.
* @param {import("fastify").FastifyInstance} server - Fastify instance.
* @param {object} options - Plugin config values.
* @param {('mssql'|'postgresql')} options.client - Database client.
* @param {string} options.connection - Database connection string.
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/hashed-bearer-auth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const secJSON = require("secure-json-parse");
* @author Frazer Smith
* @description Decorator plugin that adds bearer token authentication,
* querying a database for bcrypt-hashed bearer token keys.
* @param {object} server - Fastify instance.
* @param {import("fastify").FastifyInstance} server - Fastify instance.
*/
async function plugin(server) {
await server.register(bearer, {
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/shared-schemas/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const fp = require("fastify-plugin");
const S = require("fluent-json-schema");
const S = require("fluent-json-schema").default;

/**
* @author Frazer Smith
* @description Plugin that adds a collection of shared schemas for re-use throughout the server.
* @param {object} server - Fastify instance.
* @param {import("fastify").FastifyInstance} server - Fastify instance.
*/
async function plugin(server) {
/**
Expand Down
2 changes: 1 addition & 1 deletion src/routes/admin/access/bearer-token/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function buildBearerTokenRecord(result, req) {
/**
* @author Frazer Smith
* @description Sets routing options for server.
* @param {object} server - Fastify instance.
* @param {import("fastify").FastifyInstance} server - Fastify instance.
* @param {object} options - Route config values.
* @param {object} options.cors - CORS settings.
* @param {object} options.database - Database config values.
Expand Down
2 changes: 1 addition & 1 deletion src/routes/admin/access/bearer-token/schema.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const S = require("fluent-json-schema");
const S = require("fluent-json-schema").default;

const security = [{ basicAuth: [] }];
const tags = ["System administration"];
Expand Down
2 changes: 1 addition & 1 deletion src/routes/admin/healthcheck/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const accepts = ["text/plain"];
* @description Sets routing options for server for healthcheck endpoint.
* Monitoring software polls this to confirm the API is running,
* so needs no authentication.
* @param {object} server - Fastify instance.
* @param {import("fastify").FastifyInstance} server - Fastify instance.
* @param {object} options - Route config values.
* @param {object} options.cors - CORS settings.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/routes/admin/healthcheck/schema.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const S = require("fluent-json-schema");
const S = require("fluent-json-schema").default;

const tags = ["System administration"];

Expand Down
2 changes: 1 addition & 1 deletion src/routes/docs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const accepts = ["text/html"];
/**
* @author Frazer Smith
* @description Sets routing options for server.
* @param {object} server - Fastify instance.
* @param {import("fastify").FastifyInstance} server - Fastify instance.
*/
async function route(server) {
// Register plugins
Expand Down
2 changes: 1 addition & 1 deletion src/routes/docs/openapi/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const accepts = docsOpenapiGetSchema.produces;
/**
* @author Frazer Smith
* @description Sets routing options for server.
* @param {object} server - Fastify instance.
* @param {import("fastify").FastifyInstance} server - Fastify instance.
* @param {object} options - Route config values.
* @param {object} options.cors - CORS settings.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/routes/docs/openapi/schema.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const S = require("fluent-json-schema");
const S = require("fluent-json-schema").default;

/**
* Fastify uses AJV for JSON Schema Validation,
Expand Down
2 changes: 1 addition & 1 deletion src/routes/docs/schema.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const S = require("fluent-json-schema");
const S = require("fluent-json-schema").default;

/**
* Fastify uses AJV for JSON Schema Validation,
Expand Down
2 changes: 1 addition & 1 deletion src/routes/documents/receipt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const { receiptDelete, receiptInsert } = require("./query");
/**
* @author Frazer Smith
* @description Sets routing options for server.
* @param {object} server - Fastify instance.
* @param {import("fastify").FastifyInstance} server - Fastify instance.
* @param {object} options - Route config values.
* @param {boolean=} options.bearerTokenAuthEnabled - Apply `bearerToken` security scheme to route if defined.
* @param {object} options.cors - CORS settings.
Expand Down
2 changes: 1 addition & 1 deletion src/routes/documents/receipt/schema.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const S = require("fluent-json-schema");
const S = require("fluent-json-schema").default;

const tags = ["Documents"];

Expand Down
3 changes: 2 additions & 1 deletion src/routes/documents/register/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ const { registerSelect } = require("./query");
/**
* @author Frazer Smith
* @description Sets routing options for server.
* @param {object} server - Fastify instance.
* @param {import("fastify").FastifyInstance} server - Fastify instance.
* @param {object} options - Route config values.
* @param {boolean=} options.bearerTokenAuthEnabled - Apply `bearerToken` security scheme to route if defined.
* @param {object} options.cors - CORS settings.
* @param {object} options.database - Database config values.
* @param {('mssql' | 'postgresql')} options.database.client - Database client.
* @param {object} options.database.tables - Database tables.
* @param {string} options.database.tables.documentRegister - Name and schema of document register table.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/routes/documents/register/schema.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const S = require("fluent-json-schema");
const S = require("fluent-json-schema").default;

const tags = ["Documents"];

Expand Down
2 changes: 1 addition & 1 deletion src/routes/preferences/options/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const { optionsSelect } = require("./query");
/**
* @author Frazer Smith
* @description Sets routing options for server.
* @param {object} server - Fastify instance.
* @param {import("fastify").FastifyInstance} server - Fastify instance.
* @param {object} options - Route config values.
* @param {boolean=} options.bearerTokenAuthEnabled - Apply `bearerToken` security scheme to route if defined.
* @param {object} options.cors - CORS settings.
Expand Down
2 changes: 1 addition & 1 deletion src/routes/preferences/options/schema.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const S = require("fluent-json-schema");
const S = require("fluent-json-schema").default;

const tags = ["Contact preferences"];

Expand Down
2 changes: 1 addition & 1 deletion src/routes/preferences/user/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const { userInsert, userSelect } = require("./query");
/**
* @author Frazer Smith
* @description Sets routing options for server.
* @param {object} server - Fastify instance.
* @param {import("fastify").FastifyInstance} server - Fastify instance.
* @param {object} options - Route config values.
* @param {boolean=} options.bearerTokenAuthEnabled - Apply `bearerToken` security scheme to route if defined.
* @param {object} options.cors - CORS settings.
Expand Down
4 changes: 2 additions & 2 deletions src/routes/preferences/user/schema.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const S = require("fluent-json-schema");
const S = require("fluent-json-schema").default;

const tags = ["Contact preferences"];

Expand Down Expand Up @@ -148,7 +148,7 @@ const userPutSchema = {
.maxItems(4)
.uniqueItems(true)
)
.required("preferences"),
.required(["preferences"]),
response: {
204: S.string().raw({ nullable: true }).description("No Content"),
400: S.ref("responses#/properties/badRequest").description(
Expand Down
2 changes: 1 addition & 1 deletion src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const sharedSchemas = require("./plugins/shared-schemas");
/**
* @author Frazer Smith
* @description Builds Fastify instance.
* @param {object} server - Fastify instance.
* @param {import("fastify").FastifyInstance} server - Fastify instance.
* @param {object} config - Fastify configuration values.
*/
async function plugin(server, config) {
Expand Down

0 comments on commit 650c45d

Please sign in to comment.