Skip to content

Sample code on how to implement small CRUD REST API with TyRAS

Notifications You must be signed in to change notification settings

ty-ras/sample-crud

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

TyRAS Sample - CRUD REST API

This repository contains code implementing small CRUD REST API using TyRAS framework. The subfolders of git root contain standalone applications that contain BE code that is originally initialized using npx @ty-ras/start@latest command, and modified with minimal changes to host a CRUD REST API utilizing one validation framework.

Currently, the sample code exists of code for the following validation frameworks:

Differences Between Validation Frameworks

Of the validation framework variants mentioned above, currently only io-ts is the framework, which can do both encoding and decoding with a single validation object. This enables intuitive and simple definitions for situations when some data element is of one type in transit, and another type when in JS runtime.

One such example could be Date class, which is transmitted as JSON string with ISO timestamp format. The io-ts-types provides simple way to declare this in API protocol folder, and the TyRAS framework will automatically provide that kind of timestamp as Date to the endpoint methods. The zod and runtypes do not have similar functionality (zod comes close!), so with those frameworks the timestamp field is seen as string (zod example and runtypes example) also at runtime.

With these frameworks, if there is a need to perform the type conversion, it has to be done manually, like encodeThing function, and code inside update method, here in zod example, and here in runtypes example.

On the other hand, the io-ts is heavily paired with functional programming library fp-ts, and as such, is often not easy to use outside of functional programming code.

About

Sample code on how to implement small CRUD REST API with TyRAS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published