-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
41 lines (37 loc) · 911 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const { API } = require("easy-api.ts");
const api = new API({
reverse: false,
dots: false
});
api.route({
url: '/color',
method: "GET",
code: `
$ignore[Check docs to see how does functions work ;)]
$if[$or[$query[hex]==null;$isValidHex[$query[hex]]==false];
$reply[
$setCode[400]
$setType[json]
$setBody[{
"error": "Invalid hex color code provided! Please provide a correct one."
}]
]
$break $ignore[IMPORTANT!!]
]
$createCanvas[
$setDimentions[512;512]
$color[$query[hex]]
$drawRect[0;0;512;512]
]
$reply[
$setCode[200]
$setType[canvas]
$setBody[$default]
]
`
})
// Lets load the handler...
api.load('./routes').then(() => {
console.log('Source loaded.')
api.connect({ port: process.env["PORT"] || 3000 })
})