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

Commit

Permalink
chore: use @see jsdoc tag for inline comment links
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs committed Sep 3, 2023
1 parent 0869ab7 commit a121897
Show file tree
Hide file tree
Showing 16 changed files with 50 additions and 35 deletions.
2 changes: 1 addition & 1 deletion scripts/license-checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async function checkLicenses() {

/**
* List of deprecated copyleft license identifiers
* @see https://spdx.org/licenses/
* @see {@link https://spdx.org/licenses/ | SPDX License List}
*/
const deprecatedLicenseList = [
"AGPL-1.0",
Expand Down
8 changes: 5 additions & 3 deletions src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ async function getConfig() {
},
fastifyInit: {
/**
* See https://fastify.io/docs/latest/Reference/Logging/
* and https://getpino.io/#/docs/api for logger options
* @see {@link https://fastify.io/docs/latest/Reference/Logging | Fastify logging}
* @see {@link https://getpino.io/#/docs/api | Pino API}
*/
logger: {
formatters: {
Expand Down Expand Up @@ -341,7 +341,9 @@ async function getConfig() {
if (env.LOG_ROTATION_FILENAME) {
const logFile = path.normalizeTrim(env.LOG_ROTATION_FILENAME);

// Rotation options: https://github.com/rogerc/file-stream-rotator/#options
/**
* @see {@link https://github.com/rogerc/file-stream-rotator/#options | File stream rotator options}
*/
config.fastifyInit.logger.stream = getStream({
audit_file: path.joinSafe(path.dirname(logFile), ".audit.json"),
date_format: env.LOG_ROTATION_DATE_FORMAT || "YYYY-MM-DD",
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 @@ -15,7 +15,7 @@ async function plugin(server) {
* @author Frazer Smith
* @author Felix Meyer-Wolters
* @description Recursively removes key value pairs from an object where the value is null
* or undefined. Adapted from Felix's answer at https://stackoverflow.com/a/38340730
* or undefined.
* @param {object} [object] - Object to be parsed and cleaned.
* @returns {object} cleaned object.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/shared-schemas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ async function plugin(server) {
/**
* NOTE: `.definition()` definitions have been replaced with `.prop()` properties, and
* `.id()` ids removed due to definitions breaking in v4.12.1 of fastify-swagger.
* See https://github.com/fastify/fastify-swagger/issues/524
* @see {@link https://github.com/fastify/fastify-swagger/issues/524 | fastify-swagger Issue #524}
*/

// Response schemas
Expand Down
5 changes: 4 additions & 1 deletion src/routes/admin/access/bearer-token/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ WHERE id = '${id}';`;
// DISTINCT SQL keyword not needed as PK constraints enforce unique values
const accessGetSearch = ({ client, whereClausePredicates, page, perPage }) => `
SELECT COUNT(id)${
// Cast from string to int - https://node-postgres.com/features/types
/**
* Cast from string to int.
* @see {@link https://node-postgres.com/features/types | Node-Postgres Type Parsing}
*/
client === "postgresql" ? "::int" : ""
} AS total
FROM access.tokens
Expand Down
7 changes: 3 additions & 4 deletions src/routes/admin/access/bearer-token/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,10 @@ const accessRecordBaseSchema = S.object()
.required(["access"]);

/**
* Fastify uses AJV for JSON Schema Validation,
* see https://fastify.io/docs/latest/Reference/Validation-and-Serialization/
*
* Fastify uses AJV for JSON Schema Validation.
* Input validation protects against XSS, HPP, prototype pollution,
* and most other injection attacks
* and most other injection attacks.
* @see {@link https://fastify.io/docs/latest/Reference/Validation-and-Serialization | Fastify Validation and Serialization}
*/
const accessDeleteSchema = {
tags,
Expand Down
7 changes: 3 additions & 4 deletions src/routes/admin/healthcheck/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ const S = require("fluent-json-schema").default;
const tags = ["System administration"];

/**
* Fastify uses AJV for JSON Schema Validation,
* see https://fastify.io/docs/latest/Reference/Validation-and-Serialization/
*
* Fastify uses AJV for JSON Schema Validation.
* Input validation protects against XSS, HPP, prototype pollution,
* and most other injection attacks
* and most other injection attacks.
* @see {@link https://fastify.io/docs/latest/Reference/Validation-and-Serialization | Fastify Validation and Serialization}
*/
const healthcheckGetSchema = {
tags,
Expand Down
5 changes: 4 additions & 1 deletion src/routes/contact/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ WHERE id = '${id}';`;
// DISTINCT SQL keyword needed as CROSS APPLY causes duplicates
const contactGetSearch = ({ client, whereClausePredicates, page, perPage }) => `
SELECT COUNT(DISTINCT id)${
// Cast from string to int - https://node-postgres.com/features/types
/**
* Cast from string to int.
* @see {@link https://node-postgres.com/features/types | Node-Postgres Type Parsing}
*/
client === "postgresql" ? "::int" : ""
} AS total
FROM lookup.contacts
Expand Down
7 changes: 3 additions & 4 deletions src/routes/contact/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,10 @@ const contactBaseSchema = S.object()
.required(["match", "telecom"]);

/**
* Fastify uses AJV for JSON Schema Validation,
* see https://fastify.io/docs/latest/Reference/Validation-and-Serialization/
*
* Fastify uses AJV for JSON Schema Validation.
* Input validation protects against XSS, HPP, prototype pollution,
* and most other injection attacks
* and most other injection attacks.
* @see {@link https://fastify.io/docs/latest/Reference/Validation-and-Serialization | Fastify Validation and Serialization}
*/
const contactDeleteSchema = {
tags,
Expand Down
5 changes: 4 additions & 1 deletion src/routes/docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
</head>
<body>
<script>
// Redoc no longer supports IE, see https://github.com/Redocly/redoc/issues/1936
/**
* @description Detect IE and display message if detected.
* @see {@link https://github.com/Redocly/redoc/issues/1936 | Redoc Issue #1936}
*/
if (window.document.documentMode) {
var p = document.createElement("p");
p.innerHTML =
Expand Down
7 changes: 3 additions & 4 deletions src/routes/docs/openapi/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
const S = require("fluent-json-schema").default;

/**
* Fastify uses AJV for JSON Schema Validation,
* see https://fastify.io/docs/latest/Reference/Validation-and-Serialization/
*
* Fastify uses AJV for JSON Schema Validation.
* Input validation protects against XSS, HPP, prototype pollution,
* and most other injection attacks
* and most other injection attacks.
* @see {@link https://fastify.io/docs/latest/Reference/Validation-and-Serialization | Fastify Validation and Serialization}
*/
const docsOpenapiGetSchema = {
hide: true,
Expand Down
5 changes: 4 additions & 1 deletion src/routes/docs/route.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ exports[`Docs route GET requests Returns HTML 1`] = `
</head>
<body>
<script>
// Redoc no longer supports IE, see https://github.com/Redocly/redoc/issues/1936
/**
* @description Detect IE and display message if detected.
* @see {@link https://github.com/Redocly/redoc/issues/1936 | Redoc Issue #1936}
*/
if (window.document.documentMode) {
var p = document.createElement("p");
p.innerHTML =
Expand Down
7 changes: 3 additions & 4 deletions src/routes/docs/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
const S = require("fluent-json-schema").default;

/**
* Fastify uses AJV for JSON Schema Validation,
* see https://fastify.io/docs/latest/Reference/Validation-and-Serialization/
*
* Fastify uses AJV for JSON Schema Validation.
* Input validation protects against XSS, HPP, prototype pollution,
* and most other injection attacks
* and most other injection attacks.
* @see {@link https://fastify.io/docs/latest/Reference/Validation-and-Serialization | Fastify Validation and Serialization}
*/
const docsGetSchema = {
hide: true,
Expand Down
7 changes: 5 additions & 2 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ async function plugin(server, config) {
// Opt-out of Google's Topics advertising-surveillance API
.register(flocOff)

// Use Helmet to set response security headers: https://helmetjs.github.io/
/**
* Use Helmet to set response security headers.
* @see {@link https://helmetjs.github.io | Helmet}
*/
.register(helmet, config.helmet)

// Utility functions and error handlers
Expand Down Expand Up @@ -109,7 +112,7 @@ async function plugin(server, config) {
/**
* Encapsulate plugins and routes into child context, so that other
* routes do not inherit `accepts` preHandler.
* See https://fastify.io/docs/latest/Reference/Encapsulation/ for more info
* @see {@link https://fastify.io/docs/latest/Reference/Encapsulation | Fastify Encapsulation}
*/
.register(async (serializedContext) => {
serializedContext
Expand Down
4 changes: 2 additions & 2 deletions src/server.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1021,8 +1021,8 @@ describe("Server deployment", () => {
"Community Contacts API | Documentation"
);
/**
* Checks redoc has not rendered an error component:
* https://github.com/Redocly/redoc/blob/main/src/components/ErrorBoundary.tsx
* Checks redoc has not rendered an error component.
* @see {@link https://github.com/Redocly/redoc/blob/main/src/components/ErrorBoundary.tsx | Redoc ErrorBoundary component}
*/
const heading = page.locator("h1 >> nth=0");
await heading.waitFor();
Expand Down
5 changes: 4 additions & 1 deletion src/server.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ exports[`Server deployment API documentation Content /docs route Returns HTML 1`
</head>
<body>
<script>
// Redoc no longer supports IE, see https://github.com/Redocly/redoc/issues/1936
/**
* @description Detect IE and display message if detected.
* @see {@link https://github.com/Redocly/redoc/issues/1936 | Redoc Issue #1936}
*/
if (window.document.documentMode) {
var p = document.createElement("p");
p.innerHTML =
Expand Down

0 comments on commit a121897

Please sign in to comment.