easy-api.ts
Version:
A powerful library to create your own API with ease.
1 lines • 908 B
JavaScript
Object.defineProperty(exports,"__esModule",{value:!0});let tslib_1=require("tslib"),APIFunction_1=require("../../classes/structures/APIFunction"),Error_1=require("../../classes/structures/Error"),reply_1=tslib_1.__importDefault(require("./reply")),SEND_TYPES=["canvas","json","file","other","redirect"];class SetType extends APIFunction_1.APIFunction{name="$setType";description="Set the response type.";parameters=[{name:"Type",description:"Type for the response to be set.",type:APIFunction_1.ParamType.String,required:!0,rest:!1,defaultValue:null,allowedValues:SEND_TYPES}];usage="$setType[type]";returns=APIFunction_1.ParamType.Unknown;compile=!0;aliases=[];parent=new reply_1.default;async run(e,[r]){if(!SEND_TYPES.includes(r.toLowerCase()))throw new Error_1.EATS_Error("Invalid response type in: "+e.function?.name);e.parent.setInternalVar("NodeJS.ReplyType",r.toLowerCase())}}exports.default=SetType;