All Projects → loreanvictor → tyfon

loreanvictor / tyfon

Licence: MIT License
typed functions over network

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to tyfon

bitrix
Bitrix24 REST API client that doesn't suck. Suffer no more.
Stars: ✭ 59 (+55.26%)
Mutual labels:  api-client
Workday.WebServices
Workday API clients
Stars: ✭ 18 (-52.63%)
Mutual labels:  api-client
Custom-Software-For-Xiaomi-Dafang
API and panel site for Xiaomi Dafang
Stars: ✭ 36 (-5.26%)
Mutual labels:  api-client
RESTEasy
REST API calls made easier
Stars: ✭ 12 (-68.42%)
Mutual labels:  api-client
doccano-client
A simple client wrapper for doccano API.
Stars: ✭ 52 (+36.84%)
Mutual labels:  api-client
HaloSharp
A C# wrapper for the Halo® 5 Game Data API.
Stars: ✭ 24 (-36.84%)
Mutual labels:  api-client
pcloud-sdk-js
pCloud's Javascript SDK
Stars: ✭ 62 (+63.16%)
Mutual labels:  api-client
primeuploads-py
An unoffcial python API client for primeuploads.com
Stars: ✭ 40 (+5.26%)
Mutual labels:  api-client
SignNowNodeSDK
The Official SignNow Node.js Client Library for interacting with SignNow REST API. Sign documents, request e-signatures, and build role-based workflows with multiple signers using this client.
Stars: ✭ 14 (-63.16%)
Mutual labels:  api-client
approveapi-go
A Go library for using ApproveAPI
Stars: ✭ 16 (-57.89%)
Mutual labels:  api-client
universal-translator
Demo app using Firebase and Google Cloud products to implement a "universal translator"
Stars: ✭ 37 (-2.63%)
Mutual labels:  cloud-functions
activecollab-feather-sdk
PHP SDK for ActiveCollab 5 and 6 API
Stars: ✭ 47 (+23.68%)
Mutual labels:  api-client
laravel-bitcoinrpc
Bitcoin JSON-RPC Service Provider for Laravel.
Stars: ✭ 83 (+118.42%)
Mutual labels:  api-client
protonmail-api
✉ Node.js API for ProtonMail
Stars: ✭ 108 (+184.21%)
Mutual labels:  api-client
ruby-ipfs-http-client
A client library for the IPFS HTTP API, implemented in Ruby.
Stars: ✭ 21 (-44.74%)
Mutual labels:  api-client
pyark
CyberArk Enterprise Password Vault API CLI tool
Stars: ✭ 25 (-34.21%)
Mutual labels:  api-client
genderize
Python client for the Genderize.io web service.
Stars: ✭ 59 (+55.26%)
Mutual labels:  api-client
helpscout-docs-api-php
DocsApi client for HelpScout
Stars: ✭ 21 (-44.74%)
Mutual labels:  api-client
webapi
WAI based library for web api
Stars: ✭ 27 (-28.95%)
Mutual labels:  api-client
healthchecksio
Update and display the status of your healthchecks.io checks.
Stars: ✭ 30 (-21.05%)
Mutual labels:  api-client

Typed Functions Over Network

version docs



Seamlessly use server-side TypeScript functions on the client.

// server:

export async function getMessage(name: string) {
  return `Hellow ${name}!`;
}
// client:

import { getMessage } from '@api/my-server';

getMessage('World').then(console.log):

👉 Read the docs.



Installation

TyFON is a singular CLI tool that runs on Node, so you need Node.js installed beforehand.

npm i -g tyfon



Usage

Read the docs for detailed usage information and a getting-started tutorial.


Server Side

Export your functions in index.ts:

export async const getMessage = name => `Hellow ${name}!`;

Now serve them:

tyfon serve

👉 Check it out on localhost:8000/message?0="World".



Client Side

Add the SDK on client side and use it:

tyfon i localhost:8000
import { getMessage } from '@api/my-server';

getMessage('World').then(console.log);

👉 The name my-server comes from package.json of your server code.



Syncing Updates

Use tyfon watch while working on server and client simultaneously:

tyfon watch -c <client-path>     # --> run this on server side code

Or sync updates manually (in other situations):

  • On server-side code, rebuild client SDK metadata and serve it again:
tyfon build                      # --> run this on server side code
tyfon serve                      # --> run this on server side code
  • On client-side code, update TyFONs you are using:
tyfon i                          # --> run this on client side code



Server Environment Variables

You can pass environment variables to tyfon serve command using -e option:

tyfon serve -e ENV=dev -e LOGS=verbose



Client Environments

It is common practice for client-code to use different API URLs for different environments (i.e. development, production, staging, etc). You can use the --env flag on tyfon i command to mark the environment a TyFON should be used in:

tyfon i https://my-server.cloud --env production
tyfon i https://staging.my-server.cloud --env staging
tyfon i localhost:8000 --env dev

Now for building client-code in production, use the following command:

tyfon i --env production        # --> this will install all generic TyFONs and all production TyFONs



Deploying

Run your TyFON in production mode:

tyfon serve --mode prod

Docker

Build a docker image and deploy it:

tyfon build --image my-server

docker tag my-server https://my-registry.cloud/my-server
docker push my-server

👉 docker MUST be installed for using this option.



Conventions

TyFON leans heavily towards the convention over configuration principle. It is pretty opinionated in how it wraps normal functions within API end-points and how code should be structured, for example it picks endpoint methods based on the name of the function, or it expects all API functions to be exported from index.ts from the root of the project.

👉 Read the docs.



CLI Commands



Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].