tyfon-server
TypeScript icon, indicating that this package has built-in type declarations

0.2.5 • Public • Published

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.



Readme

Keywords

none

Package Sidebar

Install

npm i tyfon-server

Weekly Downloads

1

Version

0.2.5

License

MIT

Unpacked Size

28 kB

Total Files

41

Last publish

Collaborators

  • lorean.victor