UNPKG

@foal/core

Version:

Full-featured Node.js framework, with no complexity

168 lines (167 loc) 23.1 kB
"use strict"; /** * FoalTS * Copyright(c) 2017-2025 Loïc Poullain * Released under the MIT License. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.Config = exports.All = exports.ApiUseTag = exports.ApiServer = exports.ApiSecurityRequirement = exports.ApiResponse = exports.ApiRequestBody = exports.ApiParameter = exports.ApiOperationSummary = exports.ApiOperationId = exports.ApiOperationDescription = exports.ApiOperation = exports.ApiInfo = exports.ApiExternalDoc = exports.ApiDeprecated = exports.ApiDefineTag = exports.ApiDefineSecurityScheme = exports.ApiDefineSchema = exports.ApiDefineResponse = exports.ApiDefineRequestBody = exports.ApiDefineParameter = exports.ApiDefineLink = exports.ApiDefineHeader = exports.ApiDefineExample = exports.ApiDefineCallback = exports.ApiCallback = exports.verifySignedToken = exports.verifyPassword = exports.streamToBuffer = exports.signToken = exports.isInFile = exports.passwordHashNeedsToBeRefreshed = exports.hashPassword = exports.getAjvInstance = exports.generateToken = exports.generateSignedToken = exports.convertBase64urlToBase64 = exports.convertBase64ToBase64url = exports.displayServerURL = exports.controller = exports.PermissionRequired = exports.ValidateQueryParam = exports.ValidatePathParam = exports.ValidateHeader = exports.ValidateCookie = exports.ValidateBody = exports.UserRequired = exports.FileList = exports.File = exports.AsyncService = void 0; exports.getApiParameters = exports.getApiOperationSummary = exports.getApiOperationId = exports.getApiOperationDescription = exports.getApiOperation = exports.getApiInfo = exports.getApiExternalDocs = exports.getApiDeprecated = exports.getApiComponents = exports.getApiCompleteOperation = exports.getApiCallbacks = exports.dependency = exports.createService = exports.createOpenApiDocument = exports.createController = exports.ServiceManager = exports.Put = exports.Post = exports.Patch = exports.Options = exports.OpenApi = exports.MergeHooks = exports.HttpResponseUnauthorized = exports.HttpResponseTooManyRequests = exports.HttpResponseSuccess = exports.HttpResponseServerError = exports.HttpResponseRedirection = exports.HttpResponseRedirect = exports.HttpResponseOK = exports.HttpResponseNotImplemented = exports.HttpResponseNotFound = exports.HttpResponseNoContent = exports.HttpResponseMovedPermanently = exports.HttpResponseMethodNotAllowed = exports.HttpResponseInternalServerError = exports.HttpResponseForbidden = exports.HttpResponseCreated = exports.HttpResponseConflict = exports.HttpResponseClientError = exports.HttpResponseBadRequest = exports.HttpResponse = exports.Hook = exports.Head = exports.Get = exports.Env = exports.Dependency = exports.Delete = exports.Context = exports.ConfigTypeError = exports.ConfigNotFoundError = void 0; exports.readSession = exports.createSession = exports.UseSessions = exports.Store = exports.SessionStore = exports.SessionAlreadyExists = exports.Session = exports.getHttpLogParamsDefault = exports.createApp = exports.OPENAPI_SERVICE_ID = exports.renderError = exports.renderToString = exports.render = exports.Logger = exports.isHttpResponseUnauthorized = exports.isHttpResponseTooManyRequests = exports.isHttpResponseSuccess = exports.isHttpResponseServerError = exports.isHttpResponseRedirection = exports.isHttpResponseRedirect = exports.isHttpResponseOK = exports.isHttpResponseNotImplemented = exports.isHttpResponseNotFound = exports.isHttpResponseNoContent = exports.isHttpResponseMovedPermanently = exports.isHttpResponseMethodNotAllowed = exports.isHttpResponseInternalServerError = exports.isHttpResponseForbidden = exports.isHttpResponseCreated = exports.isHttpResponseConflict = exports.isHttpResponseClientError = exports.isHttpResponseBadRequest = exports.isHttpResponse = exports.getPath = exports.getMetadata = exports.getHttpMethod = exports.getHookFunctions = exports.getHookFunction = exports.getApiUsedTags = exports.getApiTags = exports.getApiServers = exports.getApiSecurity = exports.getApiResponses = exports.getApiRequestBody = void 0; try { const version = process.versions.node; const NODE_CURRENT_MAJOR_VERSION = parseInt(version.split('.')[0], 10); const NODE_MINIMUM_MAJOR_VERSION = 22; if (NODE_CURRENT_MAJOR_VERSION < NODE_MINIMUM_MAJOR_VERSION) { console.warn(`[Warning] You are using version ${version} of Node. FoalTS requires at least version ${NODE_MINIMUM_MAJOR_VERSION}.`); } } finally { } var common_1 = require("./common"); Object.defineProperty(exports, "AsyncService", { enumerable: true, get: function () { return common_1.AsyncService; } }); Object.defineProperty(exports, "File", { enumerable: true, get: function () { return common_1.File; } }); Object.defineProperty(exports, "FileList", { enumerable: true, get: function () { return common_1.FileList; } }); Object.defineProperty(exports, "UserRequired", { enumerable: true, get: function () { return common_1.UserRequired; } }); Object.defineProperty(exports, "ValidateBody", { enumerable: true, get: function () { return common_1.ValidateBody; } }); Object.defineProperty(exports, "ValidateCookie", { enumerable: true, get: function () { return common_1.ValidateCookie; } }); Object.defineProperty(exports, "ValidateHeader", { enumerable: true, get: function () { return common_1.ValidateHeader; } }); Object.defineProperty(exports, "ValidatePathParam", { enumerable: true, get: function () { return common_1.ValidatePathParam; } }); Object.defineProperty(exports, "ValidateQueryParam", { enumerable: true, get: function () { return common_1.ValidateQueryParam; } }); Object.defineProperty(exports, "PermissionRequired", { enumerable: true, get: function () { return common_1.PermissionRequired; } }); Object.defineProperty(exports, "controller", { enumerable: true, get: function () { return common_1.controller; } }); Object.defineProperty(exports, "displayServerURL", { enumerable: true, get: function () { return common_1.displayServerURL; } }); Object.defineProperty(exports, "convertBase64ToBase64url", { enumerable: true, get: function () { return common_1.convertBase64ToBase64url; } }); Object.defineProperty(exports, "convertBase64urlToBase64", { enumerable: true, get: function () { return common_1.convertBase64urlToBase64; } }); Object.defineProperty(exports, "generateSignedToken", { enumerable: true, get: function () { return common_1.generateSignedToken; } }); Object.defineProperty(exports, "generateToken", { enumerable: true, get: function () { return common_1.generateToken; } }); Object.defineProperty(exports, "getAjvInstance", { enumerable: true, get: function () { return common_1.getAjvInstance; } }); Object.defineProperty(exports, "hashPassword", { enumerable: true, get: function () { return common_1.hashPassword; } }); Object.defineProperty(exports, "passwordHashNeedsToBeRefreshed", { enumerable: true, get: function () { return common_1.passwordHashNeedsToBeRefreshed; } }); Object.defineProperty(exports, "isInFile", { enumerable: true, get: function () { return common_1.isInFile; } }); Object.defineProperty(exports, "signToken", { enumerable: true, get: function () { return common_1.signToken; } }); Object.defineProperty(exports, "streamToBuffer", { enumerable: true, get: function () { return common_1.streamToBuffer; } }); Object.defineProperty(exports, "verifyPassword", { enumerable: true, get: function () { return common_1.verifyPassword; } }); Object.defineProperty(exports, "verifySignedToken", { enumerable: true, get: function () { return common_1.verifySignedToken; } }); var core_1 = require("./core"); Object.defineProperty(exports, "ApiCallback", { enumerable: true, get: function () { return core_1.ApiCallback; } }); Object.defineProperty(exports, "ApiDefineCallback", { enumerable: true, get: function () { return core_1.ApiDefineCallback; } }); Object.defineProperty(exports, "ApiDefineExample", { enumerable: true, get: function () { return core_1.ApiDefineExample; } }); Object.defineProperty(exports, "ApiDefineHeader", { enumerable: true, get: function () { return core_1.ApiDefineHeader; } }); Object.defineProperty(exports, "ApiDefineLink", { enumerable: true, get: function () { return core_1.ApiDefineLink; } }); Object.defineProperty(exports, "ApiDefineParameter", { enumerable: true, get: function () { return core_1.ApiDefineParameter; } }); Object.defineProperty(exports, "ApiDefineRequestBody", { enumerable: true, get: function () { return core_1.ApiDefineRequestBody; } }); Object.defineProperty(exports, "ApiDefineResponse", { enumerable: true, get: function () { return core_1.ApiDefineResponse; } }); Object.defineProperty(exports, "ApiDefineSchema", { enumerable: true, get: function () { return core_1.ApiDefineSchema; } }); Object.defineProperty(exports, "ApiDefineSecurityScheme", { enumerable: true, get: function () { return core_1.ApiDefineSecurityScheme; } }); Object.defineProperty(exports, "ApiDefineTag", { enumerable: true, get: function () { return core_1.ApiDefineTag; } }); Object.defineProperty(exports, "ApiDeprecated", { enumerable: true, get: function () { return core_1.ApiDeprecated; } }); Object.defineProperty(exports, "ApiExternalDoc", { enumerable: true, get: function () { return core_1.ApiExternalDoc; } }); Object.defineProperty(exports, "ApiInfo", { enumerable: true, get: function () { return core_1.ApiInfo; } }); Object.defineProperty(exports, "ApiOperation", { enumerable: true, get: function () { return core_1.ApiOperation; } }); Object.defineProperty(exports, "ApiOperationDescription", { enumerable: true, get: function () { return core_1.ApiOperationDescription; } }); Object.defineProperty(exports, "ApiOperationId", { enumerable: true, get: function () { return core_1.ApiOperationId; } }); Object.defineProperty(exports, "ApiOperationSummary", { enumerable: true, get: function () { return core_1.ApiOperationSummary; } }); Object.defineProperty(exports, "ApiParameter", { enumerable: true, get: function () { return core_1.ApiParameter; } }); Object.defineProperty(exports, "ApiRequestBody", { enumerable: true, get: function () { return core_1.ApiRequestBody; } }); Object.defineProperty(exports, "ApiResponse", { enumerable: true, get: function () { return core_1.ApiResponse; } }); Object.defineProperty(exports, "ApiSecurityRequirement", { enumerable: true, get: function () { return core_1.ApiSecurityRequirement; } }); Object.defineProperty(exports, "ApiServer", { enumerable: true, get: function () { return core_1.ApiServer; } }); Object.defineProperty(exports, "ApiUseTag", { enumerable: true, get: function () { return core_1.ApiUseTag; } }); Object.defineProperty(exports, "All", { enumerable: true, get: function () { return core_1.All; } }); Object.defineProperty(exports, "Config", { enumerable: true, get: function () { return core_1.Config; } }); Object.defineProperty(exports, "ConfigNotFoundError", { enumerable: true, get: function () { return core_1.ConfigNotFoundError; } }); Object.defineProperty(exports, "ConfigTypeError", { enumerable: true, get: function () { return core_1.ConfigTypeError; } }); Object.defineProperty(exports, "Context", { enumerable: true, get: function () { return core_1.Context; } }); Object.defineProperty(exports, "Delete", { enumerable: true, get: function () { return core_1.Delete; } }); Object.defineProperty(exports, "Dependency", { enumerable: true, get: function () { return core_1.Dependency; } }); Object.defineProperty(exports, "Env", { enumerable: true, get: function () { return core_1.Env; } }); Object.defineProperty(exports, "Get", { enumerable: true, get: function () { return core_1.Get; } }); Object.defineProperty(exports, "Head", { enumerable: true, get: function () { return core_1.Head; } }); Object.defineProperty(exports, "Hook", { enumerable: true, get: function () { return core_1.Hook; } }); Object.defineProperty(exports, "HttpResponse", { enumerable: true, get: function () { return core_1.HttpResponse; } }); Object.defineProperty(exports, "HttpResponseBadRequest", { enumerable: true, get: function () { return core_1.HttpResponseBadRequest; } }); Object.defineProperty(exports, "HttpResponseClientError", { enumerable: true, get: function () { return core_1.HttpResponseClientError; } }); Object.defineProperty(exports, "HttpResponseConflict", { enumerable: true, get: function () { return core_1.HttpResponseConflict; } }); Object.defineProperty(exports, "HttpResponseCreated", { enumerable: true, get: function () { return core_1.HttpResponseCreated; } }); Object.defineProperty(exports, "HttpResponseForbidden", { enumerable: true, get: function () { return core_1.HttpResponseForbidden; } }); Object.defineProperty(exports, "HttpResponseInternalServerError", { enumerable: true, get: function () { return core_1.HttpResponseInternalServerError; } }); Object.defineProperty(exports, "HttpResponseMethodNotAllowed", { enumerable: true, get: function () { return core_1.HttpResponseMethodNotAllowed; } }); Object.defineProperty(exports, "HttpResponseMovedPermanently", { enumerable: true, get: function () { return core_1.HttpResponseMovedPermanently; } }); Object.defineProperty(exports, "HttpResponseNoContent", { enumerable: true, get: function () { return core_1.HttpResponseNoContent; } }); Object.defineProperty(exports, "HttpResponseNotFound", { enumerable: true, get: function () { return core_1.HttpResponseNotFound; } }); Object.defineProperty(exports, "HttpResponseNotImplemented", { enumerable: true, get: function () { return core_1.HttpResponseNotImplemented; } }); Object.defineProperty(exports, "HttpResponseOK", { enumerable: true, get: function () { return core_1.HttpResponseOK; } }); Object.defineProperty(exports, "HttpResponseRedirect", { enumerable: true, get: function () { return core_1.HttpResponseRedirect; } }); Object.defineProperty(exports, "HttpResponseRedirection", { enumerable: true, get: function () { return core_1.HttpResponseRedirection; } }); Object.defineProperty(exports, "HttpResponseServerError", { enumerable: true, get: function () { return core_1.HttpResponseServerError; } }); Object.defineProperty(exports, "HttpResponseSuccess", { enumerable: true, get: function () { return core_1.HttpResponseSuccess; } }); Object.defineProperty(exports, "HttpResponseTooManyRequests", { enumerable: true, get: function () { return core_1.HttpResponseTooManyRequests; } }); Object.defineProperty(exports, "HttpResponseUnauthorized", { enumerable: true, get: function () { return core_1.HttpResponseUnauthorized; } }); Object.defineProperty(exports, "MergeHooks", { enumerable: true, get: function () { return core_1.MergeHooks; } }); Object.defineProperty(exports, "OpenApi", { enumerable: true, get: function () { return core_1.OpenApi; } }); Object.defineProperty(exports, "Options", { enumerable: true, get: function () { return core_1.Options; } }); Object.defineProperty(exports, "Patch", { enumerable: true, get: function () { return core_1.Patch; } }); Object.defineProperty(exports, "Post", { enumerable: true, get: function () { return core_1.Post; } }); Object.defineProperty(exports, "Put", { enumerable: true, get: function () { return core_1.Put; } }); Object.defineProperty(exports, "ServiceManager", { enumerable: true, get: function () { return core_1.ServiceManager; } }); Object.defineProperty(exports, "createController", { enumerable: true, get: function () { return core_1.createController; } }); Object.defineProperty(exports, "createOpenApiDocument", { enumerable: true, get: function () { return core_1.createOpenApiDocument; } }); Object.defineProperty(exports, "createService", { enumerable: true, get: function () { return core_1.createService; } }); Object.defineProperty(exports, "dependency", { enumerable: true, get: function () { return core_1.dependency; } }); Object.defineProperty(exports, "getApiCallbacks", { enumerable: true, get: function () { return core_1.getApiCallbacks; } }); Object.defineProperty(exports, "getApiCompleteOperation", { enumerable: true, get: function () { return core_1.getApiCompleteOperation; } }); Object.defineProperty(exports, "getApiComponents", { enumerable: true, get: function () { return core_1.getApiComponents; } }); Object.defineProperty(exports, "getApiDeprecated", { enumerable: true, get: function () { return core_1.getApiDeprecated; } }); Object.defineProperty(exports, "getApiExternalDocs", { enumerable: true, get: function () { return core_1.getApiExternalDocs; } }); Object.defineProperty(exports, "getApiInfo", { enumerable: true, get: function () { return core_1.getApiInfo; } }); Object.defineProperty(exports, "getApiOperation", { enumerable: true, get: function () { return core_1.getApiOperation; } }); Object.defineProperty(exports, "getApiOperationDescription", { enumerable: true, get: function () { return core_1.getApiOperationDescription; } }); Object.defineProperty(exports, "getApiOperationId", { enumerable: true, get: function () { return core_1.getApiOperationId; } }); Object.defineProperty(exports, "getApiOperationSummary", { enumerable: true, get: function () { return core_1.getApiOperationSummary; } }); Object.defineProperty(exports, "getApiParameters", { enumerable: true, get: function () { return core_1.getApiParameters; } }); Object.defineProperty(exports, "getApiRequestBody", { enumerable: true, get: function () { return core_1.getApiRequestBody; } }); Object.defineProperty(exports, "getApiResponses", { enumerable: true, get: function () { return core_1.getApiResponses; } }); Object.defineProperty(exports, "getApiSecurity", { enumerable: true, get: function () { return core_1.getApiSecurity; } }); Object.defineProperty(exports, "getApiServers", { enumerable: true, get: function () { return core_1.getApiServers; } }); Object.defineProperty(exports, "getApiTags", { enumerable: true, get: function () { return core_1.getApiTags; } }); Object.defineProperty(exports, "getApiUsedTags", { enumerable: true, get: function () { return core_1.getApiUsedTags; } }); Object.defineProperty(exports, "getHookFunction", { enumerable: true, get: function () { return core_1.getHookFunction; } }); Object.defineProperty(exports, "getHookFunctions", { enumerable: true, get: function () { return core_1.getHookFunctions; } }); Object.defineProperty(exports, "getHttpMethod", { enumerable: true, get: function () { return core_1.getHttpMethod; } }); Object.defineProperty(exports, "getMetadata", { enumerable: true, get: function () { return core_1.getMetadata; } }); Object.defineProperty(exports, "getPath", { enumerable: true, get: function () { return core_1.getPath; } }); Object.defineProperty(exports, "isHttpResponse", { enumerable: true, get: function () { return core_1.isHttpResponse; } }); Object.defineProperty(exports, "isHttpResponseBadRequest", { enumerable: true, get: function () { return core_1.isHttpResponseBadRequest; } }); Object.defineProperty(exports, "isHttpResponseClientError", { enumerable: true, get: function () { return core_1.isHttpResponseClientError; } }); Object.defineProperty(exports, "isHttpResponseConflict", { enumerable: true, get: function () { return core_1.isHttpResponseConflict; } }); Object.defineProperty(exports, "isHttpResponseCreated", { enumerable: true, get: function () { return core_1.isHttpResponseCreated; } }); Object.defineProperty(exports, "isHttpResponseForbidden", { enumerable: true, get: function () { return core_1.isHttpResponseForbidden; } }); Object.defineProperty(exports, "isHttpResponseInternalServerError", { enumerable: true, get: function () { return core_1.isHttpResponseInternalServerError; } }); Object.defineProperty(exports, "isHttpResponseMethodNotAllowed", { enumerable: true, get: function () { return core_1.isHttpResponseMethodNotAllowed; } }); Object.defineProperty(exports, "isHttpResponseMovedPermanently", { enumerable: true, get: function () { return core_1.isHttpResponseMovedPermanently; } }); Object.defineProperty(exports, "isHttpResponseNoContent", { enumerable: true, get: function () { return core_1.isHttpResponseNoContent; } }); Object.defineProperty(exports, "isHttpResponseNotFound", { enumerable: true, get: function () { return core_1.isHttpResponseNotFound; } }); Object.defineProperty(exports, "isHttpResponseNotImplemented", { enumerable: true, get: function () { return core_1.isHttpResponseNotImplemented; } }); Object.defineProperty(exports, "isHttpResponseOK", { enumerable: true, get: function () { return core_1.isHttpResponseOK; } }); Object.defineProperty(exports, "isHttpResponseRedirect", { enumerable: true, get: function () { return core_1.isHttpResponseRedirect; } }); Object.defineProperty(exports, "isHttpResponseRedirection", { enumerable: true, get: function () { return core_1.isHttpResponseRedirection; } }); Object.defineProperty(exports, "isHttpResponseServerError", { enumerable: true, get: function () { return core_1.isHttpResponseServerError; } }); Object.defineProperty(exports, "isHttpResponseSuccess", { enumerable: true, get: function () { return core_1.isHttpResponseSuccess; } }); Object.defineProperty(exports, "isHttpResponseTooManyRequests", { enumerable: true, get: function () { return core_1.isHttpResponseTooManyRequests; } }); Object.defineProperty(exports, "isHttpResponseUnauthorized", { enumerable: true, get: function () { return core_1.isHttpResponseUnauthorized; } }); Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return core_1.Logger; } }); Object.defineProperty(exports, "render", { enumerable: true, get: function () { return core_1.render; } }); Object.defineProperty(exports, "renderToString", { enumerable: true, get: function () { return core_1.renderToString; } }); Object.defineProperty(exports, "renderError", { enumerable: true, get: function () { return core_1.renderError; } }); var express_1 = require("./express"); Object.defineProperty(exports, "OPENAPI_SERVICE_ID", { enumerable: true, get: function () { return express_1.OPENAPI_SERVICE_ID; } }); Object.defineProperty(exports, "createApp", { enumerable: true, get: function () { return express_1.createApp; } }); Object.defineProperty(exports, "getHttpLogParamsDefault", { enumerable: true, get: function () { return express_1.getHttpLogParamsDefault; } }); var sessions_1 = require("./sessions"); Object.defineProperty(exports, "Session", { enumerable: true, get: function () { return sessions_1.Session; } }); Object.defineProperty(exports, "SessionAlreadyExists", { enumerable: true, get: function () { return sessions_1.SessionAlreadyExists; } }); Object.defineProperty(exports, "SessionStore", { enumerable: true, get: function () { return sessions_1.SessionStore; } }); Object.defineProperty(exports, "Store", { enumerable: true, get: function () { return sessions_1.Store; } }); Object.defineProperty(exports, "UseSessions", { enumerable: true, get: function () { return sessions_1.UseSessions; } }); Object.defineProperty(exports, "createSession", { enumerable: true, get: function () { return sessions_1.createSession; } }); Object.defineProperty(exports, "readSession", { enumerable: true, get: function () { return sessions_1.readSession; } });