express-ts-skeleton
Version:
This is a skeleton(boiler plate) for nodejs, express and typescript.
36 lines (35 loc) • 1.51 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.checkResponseType = void 0;
const http_status_codes_1 = require("http-status-codes");
const defaultStatusCode = http_status_codes_1.StatusCodes.OK;
//MARK: checkResponseType
class checkResponseType {
/**
* Checks if the result is a download response.
* @param {string} result.filePath - The path of the file to download.
* @param {string} result.fileName - The name of the file to download.
* @param {number} result.statusCode - The HTTP status code.
* @returns {boolean} True if the result is a download response, false otherwise.
*/
static isDownloadResponse(result) {
return (result &&
typeof result.filePath === "string" &&
typeof result.fileName === "string" &&
result.statusCode == defaultStatusCode);
}
/**
* Checks if the result is a render response.
* @param {string} result.view - The name of the view template.
* @param {object} result.content - The content to render in the view.
* @param {number} result.statusCode - The HTTP status code.
* @returns {boolean} True if the result is a render response, false otherwise.
*/
static isRenderResponse(result) {
return (result &&
typeof result.view === "string" &&
typeof result.content === "object" &&
result.statusCode === defaultStatusCode);
}
}
exports.checkResponseType = checkResponseType;