Tinie 🪄
Tinie is tiny framework that simply converts JavaScript functions into Restful APIs inspired by Tanmoy741127/lumi
Feature
- Create Restful API route from javascript functions
- Validate parameter with type or types
- Tinie server wrtten with Fastify
How to start 🚀
$ npm install tinie
- Write functions and join function into Tinie
import Tinie from "tinie";
const calculator = (
operation: "add" | "subtract" | "multiply" | "divide" = "divide",
a: number,
b: number
) => {
switch (operation) {
case "add":
return a + b;
case "subtract":
return a - b;
case "multiply":
return a * b;
case "divide":
return a / b;
}
}
const calculatorParamTypes = {
operation: ["string"],
a: "number",
b: "number"
}
const tinie = new Tinie()
tinie.register(calculator, {
types: calculatorParamTypes
})
tinie.listen()
$ curl -X POST -H "Content-Type: application/json" -d '{"operation": "add", "a": 4, "b": 2}' http://127.0.0.1:3000/calculator
TODO