Skip to main content
Module

x/drash/api_reference.json

A microframework for Deno's HTTP server with zero third-party dependencies
Go to Latest
File
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
{ "Exceptions": { "HttpException": [ { "doc_block": "/**\n* This class gives you a way to throw HTTP errors semantically.\n*/\n", "signature": "export class HttpException extends Error { }", "member_type": "method" }, { "doc_block": "/**\n* A property to hold the HTTP response code associated with this\n* exception.\n*/\n", "signature": "public code: number;", "member_type": "method" }, { "doc_block": "/**\n* Construct an object of this class.\n*\n* @param code - The HTTP response code associated with this exception.\n* @param message - (optional) The exception message.\n*/\n", "signature": "constructor(code: number, message?: string) { }", "member_type": "method" } ], "HttpMiddlewareException": [ { "doc_block": "/**\n* This class gives you a way to throw HTTP errors semantically in the\n* middleware classes. The difference between this class and HttpException\n* comes when you want to check which exception was thrown via\n* exception.constructor.name.\n*/\n", "signature": "export class HttpMiddlewareException extends HttpException { }}", "member_type": "method" } ] }, "Http": { "Middleware": [ { "doc_block": "/**\n* @param request - Contains the instance of the request.\n* @param server - Contains the instance of the server.\n* @param response - Contains the instance of the response.\n*/\n", "signature": "export type MiddlewareFunction =| ((request: Drash.Http.Request,response: Drash.Http.Response,) => Promise<void>)| ((request: Drash.Http.Request, response: Drash.Http.Response) => void);", "member_type": "method" }, { "doc_block": "/**\n* @description\n* before_request?: MiddlewareFunction[]\n*\n* An array that contains all the functions that will be run before a Drash.Http.Request is handled.\n*\n* after_request: MiddlewareFunction[]\n*\n* An array that contains all the functions that will be run after a Drash.Http.Request is handled.\n*\n*/\n", "signature": "export type MiddlewareType = { }", "member_type": "method" }, { "doc_block": "/**\n* Function associated to decorate the middleware decorators\n*\n* @param middlewares - Contains middlewares to be executed\n*/\n", "signature": "export function Middleware(middlewares: MiddlewareType) { }", "member_type": "method" }, { "doc_block": "/**\n* Executes the middleware function before or after the request at method level\n*\n* @param middlewares - Contains all middleware to be run\n*/\n", "signature": "function MethodMiddleware(middlewares: MiddlewareType): any { }", "member_type": "method" }, { "doc_block": "/**\n* Executes the middleware function before or after the request at class level\n*\n* @param middlewares - Contains all middleware to be run\n*/\n", "signature": "function ClassMiddleware(middlewares: MiddlewareType) { }", "member_type": "method" } ], "Request": [ { "doc_block": "/**\n* Construct an object of this class.\n*\n* @param ServerRequest - originalRequest\n* The original Deno ServerRequest object that's used to help create this\n* Drash.Http.Request object. There are some data members that the\n* original request has that can't be attached to this object. Therefore,\n* we keep track of the original request if we ever want to access data\n* members from it. An example of a data member that we want to access is\n* the original request's body.\n* @param IOptionsConfig - options to be used in the server\n*/\n", "signature": "constructor(originalRequest: ServerRequest, options?: IOptionsConfig) { }", "member_type": "method" }, { "doc_block": "/**\n* Used to check which headers are accepted\n* @param type It is either a string or an array of strings that contains the Accept Headers\n* @returns Either true or the string of the correct header\n*/\n", "signature": "public accepts(type: string | string[]): boolean | string { }", "member_type": "method" }, { "doc_block": "/**\n* Get a cookie value by the name that is sent in with the request\n*\n* @param cookie - The name of the cookie to retrieve\n*\n* @return The cookie value associated with the cookie name or undefined if a cookie with that name doesn't exist\n*/\n", "signature": "public getCookie(name: string): string { }", "member_type": "method" }, { "doc_block": "/**\n* Get the requested file from the body of a multipart/form-data\n* request, by it's name.\n*\n* @param input - The name of the file to get.\n*\n* @return The file requested or undefined if not available\n*/\n", "signature": "public getBodyFile(input: string): FormFile | undefined { }", "member_type": "method" }, { "doc_block": "/**\n* Get the value of one of this request's body params by its input name.\n*\n* @return The corresponding parameter or null if not found\n*/\n", "signature": "public getBodyParam(input: string): string | null { }", "member_type": "method" }, { "doc_block": "/**\n* Get the value of one of this request's headers by its input name.\n*\n* @return The corresponding header or null if not found\n*/\n", "signature": "public getHeaderParam(input: string): string | null { }", "member_type": "method" }, { "doc_block": "/**\n* Get the value of one of this request's path params by its input name.\n*\n* @return The corresponding path parameter or null if not found\n*/\n", "signature": "public getPathParam(input: string): string | null { }", "member_type": "method" }, { "doc_block": "/**\n* Get the value of one of this request's query params by its input name.\n*\n* @return The corresponding query parameter from url or null if not found\n*/\n", "signature": "public getUrlQueryParam(input: string): string | null { }", "member_type": "method" }, { "doc_block": "/**\n* Get this request's URL path.\n*\n* @return Returns the URL path.\n*/\n", "signature": "public getUrlPath(serverRequest: ServerRequest): string { }", "member_type": "method" }, { "doc_block": "/**\n* Get the request's URL query params by parsing its URL query string.\n*\n* @return Returns the URL query string in key-value pair format.\n* ```ts\n* {[key: string]: string}\n* ```\n*/\n", "signature": "public getUrlQueryParams(serverRequest: ServerRequest,): { } [key: string]: string } {", "member_type": "method" }, { "doc_block": "/**\n*Get the specified HTTP request's URL query string.\n*\n* @return Returns the URL query string (e.g., key1=value1&key2=value2) without the leading \"?\" character. Could be null if not available\n*/\n", "signature": "public getUrlQueryString(): null | string { }", "member_type": "method" }, { "doc_block": "/**\n* Does the specified request have a body?\n*\n* @return Returns boolean promise. `true` if the request has a body, `false` if not.\n*/\n", "signature": "public async hasBody(): Promise<boolean> { }", "member_type": "method" }, { "doc_block": "/**\n* Parse the specified request's body.\n*\n* @param IOptionsConfig options\n*\n* @returns\n* Returns the content type of the body, and based on this\n* the body itself in that format. If there is no body, it\n* returns an empty properties\n*/\n", "signature": "public async parseBody(options?: IOptionsConfig,): Promise<Drash.Interfaces.ParsedRequestBody> { }", "member_type": "method" }, { "doc_block": "/**\n* Parse this request's body as application/x-www-form-url-encoded.\n*\n* @return\n* Returns a Promise of an empty object if no body exists, else a key/value pair\n* array e.g. returnValue['someKey']\n*/\n", "signature": "public async parseBodyAsFormUrlEncoded(): Promise<object | Array<unknown>> { }", "member_type": "method" }, { "doc_block": "/**\n* Parse this request's body as application/json.\n*\n* @return Returns a promise of a JSON object decoded from request body\n*/\n", "signature": "public async parseBodyAsJson(): Promise<object> { }", "member_type": "method" }, { "doc_block": "/**\n* Parse this request's body as multipart/form-data.\n*\n* @param body - The request's body.\n* @param boundary - The boundary of the part (e.g., `----------437192313`)\n* @param maxMemory - The maximum memory to allocate to this process in megabytes.\n*\n* @return Returns a Promise<{ [key: string]: string | FormFile }>\n* Returned values can be seen here (look for `readForm`:\n* https://deno.land/std@v0.32.0/mime/multipart.ts\n*/\n", "signature": "public async parseBodyAsMultipartFormData(body: Reader,boundary: string,maxMemory: number,): Promise<any> { }", "member_type": "method" }, { "doc_block": "/**\n* Respond the the client's request by using the original request's\n* respond() method.\n*\n* @param output - The data to respond with.\n*/\n", "signature": "public async respond(output: Drash.Interfaces.ResponseOutput): Promise<void> { }", "member_type": "method" }, { "doc_block": "/**\n* Set headers on the request.\n*\n* @param headers - Headers in the form of `{[key: string]: string}`\n* @return void\n*/\n", "signature": "public setHeaders(headers: { } [key: string]: string }): void {", "member_type": "method" } ], "Resource": [ { "doc_block": "/**\n* This is the base resource class for all resources. All resource classes\n* must be derived from this class.\n*/\n", "signature": "export class Resource implements Drash.Interfaces.Resource { }", "member_type": "method" }, { "doc_block": "/**\n* A property to hold the middleware this resource uses.\n*\n* All derived middleware classes MUST define this property as static\n* (e.g., static middleware = [\"MiddlewareClass\"];)\n*/\n", "signature": "public middleware: { after_request?: []; before_request?: [] } = {};", "member_type": "method" }, { "doc_block": "/**\n* A property to hold the name of this resource. This property is used by\n* Drash.Http.Server to help it store resources in its resources property\n* by name.\n*/\n", "signature": "public name: string = \"\";", "member_type": "method" }, { "doc_block": "/**\n* A property to hold the paths to access this resource.\n*\n* All derived resource classes MUST define this property as static\n* (e.g., static paths = [\"path\"];)\n*/\n", "signature": "public paths: string[] = [];", "member_type": "method" }, { "doc_block": "/**\n* The request object.\n*/\n", "signature": "protected request: Drash.Http.Request;", "member_type": "method" }, { "doc_block": "/**\n* The response object.\n*/\n", "signature": "protected response: Drash.Http.Response;", "member_type": "method" }, { "doc_block": "/**\n* The server object.\n*/\n", "signature": "protected server: Drash.Http.Server;", "member_type": "method" }, { "doc_block": "/**\n* Construct an object of this class.\n*\n* @param request - The request object.\n* @param response - The response object.\n* @param server - The server object.\n*/\n", "signature": "constructor(request: Drash.Http.Request,response: Drash.Http.Response,server: Drash.Http.Server,) { }", "member_type": "method" } ], "Response": [ { "doc_block": "/**\n* @description\n* views_path?: string\n*\n* A string that contains the path to the views directory from\n* your project directory. This must exist if the `views_renderer` property\n* is set by you. Only needs to be set if you plan to return HTML\n*\n* const server = new Drash.Http.Server({\n* ...,\n* views_path: \"/public/views\"\n* })\n*\n* template_engine?: boolean\n*\n* True if you wish to use Drash's own template engine to render html files.\n* The `views_path` property must be set if this is set to true\n*\n* const server = new Drash.Http.Server({\n* ...\n* template_engine: true\n* })\n*/\n", "signature": "export interface IResponseOptions { }", "member_type": "method" }, { "doc_block": "/**\n* Response handles sending a response to the client making the request.\n*/\n", "signature": "export class Response { }", "member_type": "method" }, { "doc_block": "/**\n* A property to hold the body of this response.\n*/\n", "signature": "public body: boolean | null | object | string | undefined = \"\";", "member_type": "method" }, { "doc_block": "/**\n* A property to hold this response's headers.\n*/\n", "signature": "public headers: Headers;", "member_type": "method" }, { "doc_block": "/**\n* The request object.\n*/\n", "signature": "public request: Drash.Http.Request;", "member_type": "method" }, { "doc_block": "/**\n* A property to hold this response's status code (e.g., 200 for OK).\n* This class uses Status and STATUS_TEXT from the Deno Standard\n* Modules' http_status module for response codes.\n*/\n", "signature": "public status_code: number = Status.OK;", "member_type": "method" }, { "doc_block": "/**\n* An object of options to help determine how this object should behave.\n*/\n", "signature": "private options: IResponseOptions;", "member_type": "method" }, { "doc_block": "/**\n* A property to hold the path to the users views directory\n* from their project root\n*/\n", "signature": "private views_path: string | undefined;", "member_type": "method" }, { "doc_block": "/**\n* The render method extracted from dejs\n*/\n", "signature": "private readonly template_engine: boolean | undefined = false;", "member_type": "method" }, { "doc_block": "/**\n* Construct an object of this class.\n*\n* @param request - Contains the request object\n*\n* @param options - The response options\n*/\n", "signature": "constructor(request: Drash.Http.Request, options: IResponseOptions = { }}) {", "member_type": "method" }, { "doc_block": "/**\n* Render html files. Can be used with Drash's template engine or basic\n* HTML files. This method will read a file based on the `views_path`\n* and filename passed in. When called, will set the response content\n* type to \"text/html\"\n*\n* @param args - The arguments used to render\n*\n* @remarks\n* // if `views_path` is \"/public/views\",\n* // file to read is \"/public/views/users/add.html\"\n* const content = this.response.render('/users/add.html', { name: 'Drash' })\n* if (!content) throw new Error(...)\n* this.response.body = content\n*\n* @return The html content of the view, or false if the `views_path` is not set.\n*/\n", "signature": "public render(// deno-lint-ignore no-explicit-any...args: unknown[]): string | boolean { }", "member_type": "method" }, { "doc_block": "/**\n* Create a cookie to be sent in the response.\n* Note: Once set, it cannot be read until the next\n* request\n*\n* @param cookie - Object holding all the properties for a cookie object\n*/\n", "signature": "public setCookie(cookie: Cookie): void { }", "member_type": "method" }, { "doc_block": "/**\n* Delete a cookie before sending a response\n*\n* @param cookieName - The cookie name to delete\n*/\n", "signature": "public delCookie(cookieName: string): void { }", "member_type": "method" }, { "doc_block": "/**\n* Generate a response.\n*\n* @return The response in string form\n*/\n", "signature": "public generateResponse(): string { }", "member_type": "method" }, { "doc_block": "/**\n* Get the status message based on the status code.\n*\n* @return\n* Returns the status message associated with this.status_code. For\n* example, if the response's status_code is 200, then this method\n* will return \"OK\" as the status message.\n*/\n", "signature": "public getStatusMessage(): null | string { }", "member_type": "method" }, { "doc_block": "/**\n* Get the full status message based on the status code. This is just the\n* status code and the status message together. For example:\n*\n* If the status code is 200, then this will return \"200 (OK)\"\n* If the status code is 404, then this will return \"404 (Not Found)\"\n*\n* @return The status code\n*/\n", "signature": "public getStatusMessageFull(): null | string { }", "member_type": "method" }, { "doc_block": "/**\n* Send the response to the client making the request.\n*\n* @return\n* Returns a Promise of the output which is passed to `request.respond()`. The output\n* is only returned for unit testing purposes. It is not intended to be\n* used elsewhere as this call is the last call in the\n* request-resource-response lifecycle.\n*/\n", "signature": "public async send(): Promise<Drash.Interfaces.ResponseOutput> { }", "member_type": "method" }, { "doc_block": "/**\n* Send the response of a static asset (e.g., a CSS file, JS file, PDF\n* file, etc.) to the client making the request.\n*\n* @param file - The file that will be served to the client.\n* @param contents - The content in a Uint8Array\n*\n* @return The final output to be sent\n*/\n", "signature": "public sendStatic(file: null | string,contents: Uint8Array | string = \"\",): Drash.Interfaces.ResponseOutput { }", "member_type": "method" }, { "doc_block": "/**\n* Get the content type from the request object's \"Accept\" header. Default\n* to the response_output config passed in when the server was created if\n* no accept header is specified. If no response_output config was passed\n* in during server creation, then default to application/json.\n*\n*\n* @return\n* Returns a content type to set as this object's content-type header. If\n* multiple content types are passed in, then return the first accepted\n* content type.\n*/\n", "signature": "protected getContentTypeFromRequestAcceptHeader(): string { }", "member_type": "method" }, { "doc_block": "if (contentTypes && contentTypes == \"*/*\") {\n", "signature": "return \"application/json\";", "member_type": "method" }, { "doc_block": "if (firstType == \"*/*\") {\n", "signature": "return \"application/json\";", "member_type": "method" }, { "doc_block": "/**\n* Redirect the client to another URL.\n*\n* @param httpStatusCode - Response's status code.\n* Permanent: (301 and 308)\n* Temporary: (302, 303, and 307)\n*\n* @param location - URL of desired redirection. Relative or external paths (e.g., \"/users/1\", https://drash.land)\n*\n* @return The final output to be sent\n*/\n", "signature": "public redirect(httpStatusCode: number,location: string,): Drash.Interfaces.ResponseOutput { }", "member_type": "method" } ], "Server": [ { "doc_block": "/**\n* Server handles the entire request-resource-response lifecycle. It is in\n* charge of handling HTTP requests to resources, static paths, sending\n* appropriate responses, and handling errors that bubble up within the\n* request-resource-response lifecycle.\n*/\n", "signature": "export class Server { }", "member_type": "method" }, { "doc_block": "/**\n* A property to hold the Deno server. This property is set in\n* this.run() like so:\n*\n* this.deno_server = serve(HTTPOptions);\n*\n* serve() is imported from https://deno.land/x/http/server.ts.\n*/\n", "signature": "public deno_server: DenoServer | null = null;", "member_type": "method" }, { "doc_block": "/**\n* The hostname of the Deno server.\n*/\n", "signature": "public hostname: string = \"localhost\";", "member_type": "method" }, { "doc_block": "/**\n* The port of the Deno server.\n*/\n", "signature": "public port: number = 1447;", "member_type": "method" }, { "doc_block": "/**\n* A property to hold this server's logger.\n*/\n", "signature": "public logger: Drash.CoreLoggers.ConsoleLogger | Drash.CoreLoggers.FileLogger;", "member_type": "method" }, { "doc_block": "/**\n* A property to hold this server's configs.\n*/\n", "signature": "protected configs: Drash.Interfaces.ServerConfigs;", "member_type": "method" }, { "doc_block": "/**\n* A property to hold the location of this server on the filesystem. This\n* property is used when resolving static paths.\n*/\n", "signature": "protected directory: string | undefined = undefined;", "member_type": "method" }, { "doc_block": "/**\n* A property to hold middleware.\n*/\n", "signature": "protected middleware: ServerMiddleware = {};", "member_type": "method" }, { "doc_block": "/**\n* A property to hold the resources passed in from the configs.\n*/\n", "signature": "protected resources: { [key: string]: Drash.Interfaces.Resource } = {};", "member_type": "method" }, { "doc_block": "/**\n* This server's list of static paths. HTTP requests to a static path are\n* usually intended to retrieve some type of concrete resource (e.g., a\n* CSS file or a JS file). If an HTTP request is matched to a static path\n* and the resource the HTTP request is trying to get is found, then\n* Drash.Http.Response will use its sendStatic() method to send the\n* static asset back to the client.\n*/\n", "signature": "protected static_paths: string[] = [];", "member_type": "method" }, { "doc_block": "/**\n* Construct an object of this class.\n*\n* @param configs - The config of Drash Server\n*/\n", "signature": "constructor(configs: Drash.Interfaces.ServerConfigs) { }", "member_type": "method" }, { "doc_block": "/**\n* Get the request object with more properties and methods.\n*\n* @param request - The request object.\n*\n* @return\n* Returns a Drash request object--hydrated with more properties and\n* methods than the ServerRequest object. These properties and methods are\n* used throughout the Drash request-resource-response lifecycle.\n*/\n", "signature": "public async getRequest(serverRequest: ServerRequest,): Promise<Drash.Http.Request> { }", "member_type": "method" }, { "doc_block": "/**\n* Handle an HTTP request from the Deno server.\n*\n* @param request - The request object.\n*\n* @return Returns a Promise of ResponseOutput\n*/\n", "signature": "public async handleHttpRequest(serverRequest: Drash.Http.Request,): Promise<Drash.Interfaces.ResponseOutput> { }", "member_type": "method" }, { "doc_block": "/**\n* Handle cases when an error is thrown when handling an HTTP request.\n*\n* @param request - The request object.\n* @param error - The error object.\n* @param resource - (optional) Pass in the resource that threw the error.\n* @param response - (optional) Pass in the response that threw the error.\n*\n* @return Returns a Promise of ResponseOutput\n*/\n", "signature": "public async handleHttpRequestError(request: Drash.Http.Request,error: Drash.Exceptions.HttpException,resource: Drash.Http.Resource | null = null,response: Drash.Http.Response | null = null,): Promise<Drash.Interfaces.ResponseOutput> { }", "member_type": "method" }, { "doc_block": "/**\n* Handle HTTP requests for the favicon. This method only exists to\n* short-circuit favicon requests--preventing the requests from clogging\n* the logs.\n*\n* @param request - The request object\n*\n* @return\n* Returns the response as stringified JSON. This is only used for unit\n* testing purposes.\n*/\n", "signature": "public handleHttpRequestForFavicon(request: Drash.Http.Request,): Drash.Interfaces.ResponseOutput { }", "member_type": "method" }, { "doc_block": "/**\n* Handle HTTP requests for static path assets.\n*\n* @param request - The request object\n*\n* @return\n* Returns the response as stringified JSON. This is only used for unit\n* testing purposes.\n*/\n", "signature": "public async handleHttpRequestForStaticPathAsset(request: Drash.Http.Request,): Promise<Drash.Interfaces.ResponseOutput> { }", "member_type": "method" }, { "doc_block": "/**\n* Run the Deno server at the hostname specified in the configs. This\n* method takes each HTTP request and creates a new and more workable\n* request object and passes it to\n* `Drash.Http.Server.handleHttpRequest()`.\n*\n* @param options - The HTTPOptions interface from https://deno.land/std/http/server.ts.\n*\n* @return Returns a Promise of the Deno server from the serve() call.\n*/\n", "signature": "public async run(options: HTTPOptions): Promise<DenoServer> { }", "member_type": "method" }, { "doc_block": "/**\n* Run the Deno server at the hostname specified in the configs as an\n* HTTPS Server. This method takes each HTTP request and creates a new and\n* more workable request object and passes it to\n* `Drash.Http.Server.handleHttpRequest()`.\n*\n* @param options - The HTTPSOptions interface from https://deno.land/std/http/server.ts.\n*\n* @return Returns a Promise of the Deno server from the serve() call.\n*/\n", "signature": "public async runTLS(options: HTTPSOptions): Promise<DenoServer> { }", "member_type": "method" }, { "doc_block": "/**\n* Close the server.\n*/\n", "signature": "public close(): void { }", "member_type": "method" }, { "doc_block": "/**\n* Add an HTTP resource to the server which can be retrieved at specific\n* URIs.\n*\n* Drash defines an HTTP resource according to the MDN Web docs\n* [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Identifying_resources_on_the_Web).\n*\n* @param resourceClass - A child object of the `Drash.Http.Resource` class.\n*/\n", "signature": "protected addHttpResource(resourceClass: Drash.Interfaces.Resource): void { }", "member_type": "method" }, { "doc_block": "/**\n* Add server-level and resource-level middleware.\n*\n* @param middleware - The middlewares to be added to the server\n*/\n", "signature": "protected addMiddleware(middlewares: any): void { }", "member_type": "method" }, { "doc_block": "/**\n* Add a static path for serving static assets like CSS files, JS files,\n* PDF files, etc.\n*\n* @param path - The path where the static assets are\n*/\n", "signature": "protected addStaticPath(path: string): void { }", "member_type": "method" }, { "doc_block": "/**\n* Execute server-level middleware before the request.\n*\n* @param request - The request object.\n* @param resource - The resource object.\n*/\n", "signature": "protected async executeMiddlewareServerLevelBeforeRequest(request: Drash.Http.Request,): Promise<void> { }", "member_type": "method" }, { "doc_block": "/**\n* Execute server-level middleware after the request.\n*\n* @param request - The request object.\n* @param resource - The resource object.\n*/\n", "signature": "protected async executeMiddlewareServerLevelAfterRequest(request: Drash.Http.Request,response: Drash.Http.Response | null,): Promise<void> { }", "member_type": "method" }, { "doc_block": "/**\n* Get an HTTP error response exception object.\n*\n* @param code - The code that should be used\n* @param message - The message it should be displayed\n*\n* @return A new http exception\n*/\n", "signature": "protected httpErrorResponse(code: number,message?: string,): Drash.Exceptions.HttpException { }", "member_type": "method" }, { "doc_block": "/**\n* Get the resource class.\n*\n* @param request - The request object.\n*\n* @return\n* Returns a `Drash.Http.Resource` object if the URL path of the request\n* can be matched to a `Drash.Http.Resource` object's paths.\n*\n* Returns `undefined` if a `Drash.Http.Resource` object can't be matched.\n*/\n", "signature": "protected getResourceClass(request: Drash.Http.Request,): Drash.Interfaces.Resource | undefined { }", "member_type": "method" }, { "doc_block": "/**\n* Is the request targeting a static path?\n*\n* @param request - The request object\n*\n* @return\n* Returns true if the request targets a static path.\n*/\n", "signature": "protected requestTargetsStaticPath(serverRequest: ServerRequest): boolean { }", "member_type": "method" }, { "doc_block": "/**\n* Log a debug message\n*\n* @param message - Message to log\n*/\n", "signature": "protected logDebug(message: string): void { }", "member_type": "method" } ] }, "Interfaces": { "LogLevelStructure": [ { "doc_block": "/**\n* Contains the type of LogLevelStructure\n* @remarks\n* name: string\n*\n* The name of the log level (e.g., \"debug\").\n*\n* rank: number\n*\n* The rank of the log level. See the\n* Drash.Dictionaries.LogLevels.LogLevel enum member to see the ranking\n* structure of the log levels.\n*/\n", "signature": "export interface LogLevelStructure { }", "member_type": "method" } ], "LoggerConfigs": [ { "doc_block": "/**\n* Contains the type of LoggerConfigs\n* @remarks\n* enabled: boolean\n*\n* Is the logger enabled? This is useful if you have a config file that\n* can toggle this option between `true` and `false`.\n*\n* file?: string\n*\n* The filename to log to (used in Drash.CoreLoggers.FileLogger).\n*\n* level?: string\n*\n* Options are:\n*\n* all\n* trace\n* debug\n* info\n* warn\n* error\n* fatal\n* off\n*\n* Defaults to \"debug\".\n*\n* tag_string?: string\n*\n* A string with tags. Tags must be wrapped in brackets in order for the\n* logger classes to properly identify them. For example,\n*\n* {some_tag} | {some_tag} * {some_tag} [{some_tag}]`.\n*\n* tag_string_fns?: any\n*\n* This takes an object of key-value pairs where the key is the name of\n* the tag defined in the `tag_string` config. This object is used to\n* replace tags in the `tag_string` config by matching keys to tags and\n* replacing tags with the values of the keys. For example, if\n* `tag_string` was `{my_cool_tag}` and `tags_string_fns.my_cool_tag`\n* returns `\"HELLO\"`, then `{my_cool_tag}` would be replaced with\n* `HELLO`.\n*\n* test?: boolean\n*\n* Is the logger running in a test process? Setting this to true will\n* silence the console logger from outputting to the console so you can\n* test without actually logging to the console.\n*/\n", "signature": "export interface LoggerConfigs { }", "member_type": "method" } ], "ParsedRequestBody": [ { "doc_block": "/**\n* Contains the type of ParsedRequestBody\n* @remarks\n* content_type: any|undefined\n*\n* The Content-Type of the request body. For example, if the body is\n* JSON, then the Content-Type should be application/json.\n*\n* data: any|undefined\n*\n* The data passed in the body of the request.\n*/\n", "signature": "export interface ParsedRequestBody { }", "member_type": "method" } ], "ServerConfigs": [ { "doc_block": "/**\n* Contains the type of ServerConfigs\n* @remarks\n* directory?: string\n*\n* The path to the directory of the server on the filesystem. This is\n* used when resolving static paths, so make sure you have this set\n* correctly if you are serving static paths. A quick way to implement\n* this could be the following:\n*\n* directory: `${await Deno.realpath('.')}`\n*\n* logger?: Drash.CoreLoggers.ConsoleLogger | Drash.CoreLoggers.FileLogger\n*\n* The server's logger. For example:\n*\n* logger: new Drash.CoreLoggers.ConsoleLogger({\n* enabled: true,\n* level: \"debug\",\n* tag_string: \"{date} | {level} |\",\n* tag_string_fns: {\n* date: function() {\n* return new Date().toISOString().replace(\"T\", \" \");\n* },\n* },\n* })\n*\n* memory_allocation?: {\n* multipart_form_data?: number\n* }\n* The amount of memory to allocate to certain parts of the codebase.\n* For example, the multipart reader uses a default of 10MB, but you can\n* override that default by specifying the following:\n*\n* memory_allocation: {\n* multipart_form_data: 128 // This would be translated to 128MB\n* }\n*\n* middleware?: any\n*\n* The middleware that the server should use. Server-level middleware\n* should be placed in middleware.server_level. Resource-level\n* middleware should be placed in middleware.resource_level. For\n* example:\n*\n* middleware: {\n* resource_level: { ... },\n* server_level: { ... }\n* }\n*\n* pretty_links?: boolean\n*\n* Enabling pretty links allows your Drash server to check whether or\n* not an index.html file exists in a static directory. For example, if\n* /public/app/index.html exists, then you can go to /public/app and it\n* will serve the index.html in that static directory.\n*\n* resources?: any\n*\n* An array of resources that the server should register. Passing in 0\n* resources means clients can't access anything on the server--because\n* there aren't any resources.\n*\n* response_output?: string\n*\n* The fallback response Content-Type that the server should use. The\n* response_output MUST be a proper MIME type. For example, the\n* following would have the server default to JSON responses:\n*\n* response_output: \"application/json\"\n*\n* static_paths?: string[]\n*\n* An array of static paths. Static paths are made public to clients.\n* This means they can access anything in static paths. For example, if\n* you have /public as a static path, then clients can look at things\n* under your /path/to/your/server/public directory.\n*\n* views_path?: string\n*\n* A string that contains the path to the views directory from\n* your project directory. This must exist if the `views_renderer` property\n* is set by you. Only needs to be set if you plan to return HTML\n*\n* views_path: \"/public/views/\"\n*\n* template_engine?: boolean\n*\n* True if you wish to use Drash's own template engine to render html files.\n* The `views_path` property must be set if this is set to true\n*\n* const server = new Drash.Http.Server({\n* ...\n* template_engine: true\n* })\n*/\n", "signature": "export interface ServerConfigs { }", "member_type": "method" } ] }, "Loggers": { "ConsoleLogger": [ { "doc_block": "/**\n* This logger allows you to log messages to the console.\n*/\n", "signature": "export class ConsoleLogger extends Logger { }", "member_type": "method" }, { "doc_block": "/**\n* Construct an object of this class.\n*\n* @param configs - Config used for Logging\n*/\n", "signature": "constructor(configs: Drash.Interfaces.LoggerConfigs) { }", "member_type": "method" }, { "doc_block": "/**\n* Write a log message to the console.\n*\n* This method is not intended to be called directly. It is already used\n* in the base class (Logger) and automatically called.\n*\n* @param logMethodLevelDefinition - Method to be Logged\n* @param message - The message to be logged\n*\n* @returns Returns the log message which is used for unit testing purposes. Returns void since the logger just logs to the console.\n*/\n", "signature": "public write(logMethodLevelDefinition: Drash.Interfaces.LogLevelStructure,message: string,): string | void { }", "member_type": "method" } ], "FileLogger": [ { "doc_block": "/**\n* This logger allows you to log messages to a file.\n*/\n", "signature": "export class FileLogger extends Logger { }", "member_type": "method" }, { "doc_block": "/**\n* The file this logger will write log messages to.\n*/\n", "signature": "protected file: string = \"tmp_log.log\";", "member_type": "method" }, { "doc_block": "/**\n* Construct an object of this class.\n*\n* @param configs - Config used for Logging\n*/\n", "signature": "constructor(configs: Drash.Interfaces.LoggerConfigs) { }", "member_type": "method" }, { "doc_block": "/**\n* Write a log message to this.file.\n*\n* This method is not intended to be called directly. It is already used\n* in the base class (Logger) and automatically called.\n*\n* @param logMethodLevelDefinition - Method to be Logged\n* @param message - The message to be logged\n*\n* @returns Returns the log message which is used for unit testing purposes. Returns void since this logger just writes to a file.\n*/\n", "signature": "public write(logMethodLevelDefinition: Drash.Interfaces.LogLevelStructure,message: string,): string | void { }", "member_type": "method" } ], "Logger": [ { "doc_block": "/**\n* This Logger is the base logger class for all logger classes.\n*/\n", "signature": "export abstract class Logger { }", "member_type": "method" }, { "doc_block": "/**\n* @param configs - Config used for Logging\n*/\n", "signature": "protected configs: Drash.Interfaces.LoggerConfigs;", "member_type": "method" }, { "doc_block": "/**\n* The level of the log message currently being written.\n*/\n", "signature": "protected current_log_message_level_name: string = \"\";", "member_type": "method" }, { "doc_block": "/**\n* @doc-blocks-to-json ignore-doc-block\n*/\n", "signature": "protected test: boolean = false;", "member_type": "method" }, { "doc_block": "/**\n* Construct an object of this class.\n*\n* @param configs - Config used for Logging\n*/\n", "signature": "constructor(configs: Drash.Interfaces.LoggerConfigs) { }", "member_type": "method" }, { "doc_block": "/**\n* Write a log message. All extended classes must implement this method.\n* See Drash.CoreLoggers.ConsoleLogger/FileLogger for examples.\n*\n* @param logMethodLevelDefinition {@link ./interfaces/log_level_structures.ts#LogLevelStructure | Interface of Log}\n* @param message - The message to be logged\n*\n* @returns Return varies based on child class implementation.\n*/\n", "signature": "abstract write(logMethodLevelDefinition: Drash.Interfaces.LogLevelStructure,message: string,): string | void;", "member_type": "method" }, { "doc_block": "/**\n* Output a DEBUG level log message.\n*\n* @param message - The log message.\n*/\n", "signature": "public debug(message: string): string | void { }", "member_type": "method" }, { "doc_block": "/**\n* Output an ERROR level log message.\n*\n* @param message - The log message.\n*/\n", "signature": "public error(message: string): string | void { }", "member_type": "method" }, { "doc_block": "/**\n* Output a FATAL level log message.\n*\n* @param message - The log message.\n*/\n", "signature": "public fatal(message: string): string | void { }", "member_type": "method" }, { "doc_block": "/**\n* Output an INFO level log message.\n*\n* @param message - The log message.\n*/\n", "signature": "public info(message: string): string | void { }", "member_type": "method" }, { "doc_block": "/**\n* Output a TRACE level log message.\n*\n* @param message - The log message.\n*/\n", "signature": "public trace(message: string): string | void { }", "member_type": "method" }, { "doc_block": "/**\n* Output a WARN level log message.\n*\n* @param message - The log message.\n*/\n", "signature": "public warn(message: string): string | void { }", "member_type": "method" }, { "doc_block": "/**\n* Get the parsed version of the raw tag string.\n*\n* @return The tag string\n*/\n", "signature": "protected getTagStringParsed(): string { }", "member_type": "method" }, { "doc_block": "/**\n* Send the message to the write method (which should be in the child\n* class). Also, do some prechecks before sending to see if the log\n* message should be written.\n*\n* @param logMethodLevelDefinition {@link ./interfaces/log_level_structures.ts#LogLevelStructure | The dictionary definition of the log message's level.}\n*\n* @param message - The log message.\n*\n* @return Returns the log message which is used for unit testing purposes.\n*/\n", "signature": "protected sendToWriteMethod(logMethodLevelDefinition: Drash.Interfaces.LogLevelStructure,message: string,): string | void { }", "member_type": "method" } ], "Server": "" }, "Services": { "HttpService": [ { "doc_block": "/**\n* This class helps perform HTTP-related processes.\n*/\n", "signature": "export class HttpService { }", "member_type": "method" }, { "doc_block": "/**\n* Checks if the incoming request accepts the type(s) in the parameter.\n* This method will check if the requests `Accept` header contains\n* the passed in types\n*\n* @param request - The request object containing the Accept header.\n* @param type - The content-type/mime-type(s) to check if the request accepts it\n*\n* @remarks\n* Below are examples of how this method is called from the request object\n* and used in resources:\n*\n* ```ts\n* // YourResource.ts - assume the request accepts \"text/html\"\n* const isAccepted = this.request.accepts(\"text/html\"); // \"text/html\"\n* // or can also pass in an array and will match on the first one found\n* const isAccepted = this.request.accepts([\"text/html\", \"text/xml\"]); // \"text/html\"\n* // and will return false if not found\n* const isAccepted = this.request.accepts(\"text/xml\"); // false\n* ```\n* @return False if the request doesn't accept any of the passed in types,\n* or the content type that was matches\n*/\n", "signature": "public accepts(request: Drash.Http.Request,type: string | string[],): boolean | string { }", "member_type": "method" }, { "doc_block": "/**\n* Get a MIME type for a file based on its extension.\n*\n* @param filePath - The file path in question.\n* @param fileIsUrl - (optional) Is the file path a URL to a file? Defaults to false.\n* If the file path is a URL, then this method will make sure the URL\n* query string is not included while doing a lookup of the file's\n* extension.\n*\n* @return Returns the name of the MIME type based on the extension of the\n* file path .\n*/\n", "signature": "public getMimeType(filePath: string | undefined,fileIsUrl: boolean = false,): null | string { }", "member_type": "method" } ] }}