Skip to content

Commit

Permalink
add docstrings for website status service (#9495)
Browse files Browse the repository at this point in the history
  • Loading branch information
pr7prashant authored Aug 21, 2023
1 parent 4f67ab7 commit 531d2ac
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions services/website-status.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,51 @@
/**
* Commonly used functions and utilities for tasks related to website status.
*
* @module
*/

import Joi from 'joi'

/**
* Joi schema for validating query params.
* Checks if the query params obect has valid up_message, down_message, up_color and down_color properties.
*
* @type {Joi}
*/
const queryParamSchema = Joi.object({
up_message: Joi.string(),
down_message: Joi.string(),
up_color: Joi.alternatives(Joi.string(), Joi.number()),
down_color: Joi.alternatives(Joi.string(), Joi.number()),
}).required()

/**
* Example query param object.
* Contains up_message, down_message, up_color and down_color properties.
*
* @type {object}
*/
const exampleQueryParams = {
up_message: 'online',
up_color: 'blue',
down_message: 'offline',
down_color: 'lightgrey',
}

/**
* Creates a badge object that displays information about website status.
*
* @param {object} options - The options for rendering the status
* @param {boolean} options.isUp - Whether the website or service is up or down
* @param {string} [options.upMessage='up'] - The message to display when the website or service is up
* @param {string} [options.downMessage='down'] - The message to display when the website or service is down
* @param {string} [options.upColor='brightgreen'] - The color to use when the website or service is up
* @param {string} [options.downColor='red'] - The color to use when the website or service is down
* @returns {object} An object with a message and a color property
* @example
* renderWebsiteStatus({ isUp: true }) // returns { message: 'up', color: 'brightgreen' }
* renderWebsiteStatus({ isUp: false }) // returns { message: 'down', color: 'red' }
*/
function renderWebsiteStatus({
isUp,
upMessage = 'up',
Expand Down

0 comments on commit 531d2ac

Please sign in to comment.