Star

Created With

linkConventions

TyFON operates on a series of conventions. You need to follow some of them for it to work properly, some others you should generally know about. Following these conventions keeps the code clean, and allows TyFON to operate with no required configuration.


linkConventions You Must Follow

gavel Remote functions (and possibly their argument / return types) MUST be exported from index.ts. Nothing else should be exported from index.ts.

See Exampleschevron_right

Don't export internal stuff:

1linkexport~~~~~~ function internalFunction() { /* ... */ }


Don't export classes:

1linkexport~~~~~~ ~class~~~~~ ~A~ ~{~}~


If you have functions in other folders, export them from index.ts:

index.ts
1linkexport * from './src';


gavel Remote functions MUST be async or return a Promise.

See Exampleschevron_right

This is wrong:

1linkexport~~~~~~ ~const~~~~~ ~f~ ~=~ ~(~)~ ~=>~~ ~'Hellow World!'~~~~~~~~~~~~~~~;~

This is correct:

1linkexport const f = async () => 'Hellow World!';


gavel Argument types and return types MUST be plain JavaScript objects.

See Exampleschevron_right

This is wrong:

1linkclass A { ... }

2linkexport function f(a~:~ ~A~) { ... }

This is correct:

1linkinterface A { ... }

2linkexport function f(a: A) { ... }


linkConventions You Should Know

gavel Client SDK package will be named @api/<server-name>, where <server-name> comes from package.json on server-side code.


gavel If two client SDKs share the same name, the one installed later overwrites the former.

☝️ So always pick a proper name for your server-side code.


linkUnder the Hood Conventions

TyFON uses the following conventions to map functions to endpoints. Since it follows the same rules on client-side SDK, you typically don't need to worry about these rules.

gavel Functions are mapped to endpoints strictly based on their name:



ConventionsConventions You Must FollowConventions You Should KnowUnder the Hood Conventions

Home Conventions Error Handling

CLI Referencechevron_right
Advanced Usagechevron_right