tyfon-server

server-side code for TyFONs

Usage no npm install needed!

<script type="module">
  import tyfonServer from 'https://cdn.skypack.dev/tyfon-server';
</script>

README

tyfon-server

Create express routers or apps that expose your functions as endpoints automatically.

import { server } from 'tyfon-server';

server({
  getMessage: async () => 'Hellow World!'
}).listen(8000);

// 🚀 check it out on `localhost:8000/message`

👉 Learn more about TyFON


Installation

npm i tyfon-server

Usage

👉 Create a server:

import { server } from 'tyfon-server';

server({
  getMessage: async (name: string) => `Hellow ${name}!`
}).listen(8000);

// 🚀 check it out on `localhost:8000/message?0=World`

👉 Create a router:

import express from 'express';
import cors from 'cors';
import { json } from 'body-parser';
import { router } from 'tyfon-server';

const app = express();
app.use(cors());
app.use(json());
app.use('/funcs', router({
  getMessage: async (user: { name: string }) => `Hellow ${user.name}!`
});

app.listen(8000);

// 🚀 check it out on `localhost:8000/funcs/message?0={"name":"Jack"}`

tyfon-conventions is used to map function names to URL endpoints and Http methods. You can also provide SDK metadata that allows TyFON CLI to automatically build SDKs for your functions.

👉 Read this post for more information.