UNPKG

easy-api.ts

Version:

A powerful library to create your own API with ease.

69 lines (61 loc) 2.38 kB
module.exports["route"] = { url: "/rankcard", method: "GET", code: ` $ignore[This is a custom function to send error, to avoid overcoding.] $function[sendError; $response[ $setCode[%param_0%] $setType[JSON] $setBody[{ "success": false, "error": true, "message": "%param_1%" }] ] ] $ignore[Checking all the querys.] $if[$or[$query[image]==null;$query[username]==null;$query[xp]==null;$query[total]==null;$query[level]==null]==true; $call[sendError;400;Missing query required parameters!] ] $if[$or[$isNumber[$query[xp]]==false;$isNumber[$query[total]]==false;$isNumber[$query[level]]==false;$query[xp]>$query[total]]==true; $call[sendError;400;Invalid number parameters provided!] ] $ignore[Creating the canvas.] $createCanvas[ $setDimensions[680;200] $ignore[Image checking.] $loadImage[image;url;$query[image]] $if[$isImage[image]==false; $call[sendError;400;Invalid avatar image!] ] $ignore[Drawing background rect.] $color[14171C] $drawRect[0;0;680;200;30] $ignore[Drawing the avatar.] $drawImage[image;50;15;170;170;90] $ignore[Bar drawing.] $color[808080] $opacity[70] $drawRect[255;130;360;35] $opacity[100] $color[253FCE] $drawRect[255;130;$calculate[($query[xp] / $query[total]) * 360];35] $ignore[Text drawing.] $font[15;DejaVu Sans] $color[FFFFFF] $drawText[XP: $query[xp];255;105;360;50;left;top] $drawText[GOAL: $query[total];500;105;360;50;left;top] $font[35;DejaVu Sans;bold] $drawText[$query[username]#$query[discriminator];255;20;360;25;left;top] $font[16;DejaVu Sans;bold] $drawText[LEVEL: $query[level];255;65;360;25;left;top] ] $ignore[Sending the canvas.] $reply[ $setCode[200] $setType[canvas] $setBody[%default%] ] ` }