UNPKG

rjweb-server

Version:

Easy and Robust Way to create a Web Server with Many Easy-to-use Features in NodeJS

55 lines (54 loc) 1.58 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var contentTypes_exports = {}; __export(contentTypes_exports, { default: () => RouteContentTypes }); module.exports = __toCommonJS(contentTypes_exports); class RouteContentTypes { /** Generate Content Type Block */ constructor(contentTypes = {}) { this.contentTypes = contentTypes; } /** * Add A File -> Content Type Mapping * @example * ``` * const controller = new Server({ }) * * controller.contentTypes((cT) => cT * .add('.png', 'image/png') * ) * ``` * @since 5.3.0 */ add(ending, contentType) { this.contentTypes[ending] = contentType; return this; } /** * Internal Method for Generating Content Types Object * @since 5.3.0 */ getData() { return { contentTypes: this.contentTypes }; } }