UNPKG

easy-api.ts

Version:

A powerful library to create your own API with ease.

51 lines (45 loc) 1.07 kB
const { API } = require('../lib/main') // Create a new API instance. const api = new API({ dots: false, reverse: false }) // Adding an event. api.event({ name: 'ready', code: ` $xtry[ $begin[$log[okee]] $rescue[$log[RESCUE_EXECUTION]] $ensure[$log[ENSURE_EXECUTION]] ] ` }) api.addFunction(function toLowerCase(d, [text]) { return text.toLowerCase() }) // Adding the route. api.route({ url: '/accent', method: 'get', code: ` $createCanvas[ $setDimensions[1024;1024] $loadImage[avatar;link;$getQuery[avatar]] $drawImage[avatar;0;0;512;512] $let[accent;$imageAccentColor[avatar;0;0;512;512]] $color[$get[accent]] $drawRect[0;0;1024;1024] ] $reply[ $setCode[200] $setType[canvas] $setBody[%default%] ] ` }) // Connect to the API. api.connect({ host: 'localhost', port: 5000 })