Skip to content

reload/nitro-models-validation-and-transformation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Working with models and named constructors

Example of Cat transformation

Cat Models:

    const remoteResponse = { id: 1, name: 'Whiskers', age: 18, breed: 'Siamese' } 

    // Create CatRemote
    const verifiedAndTypesafeRemoteCat = CatRemote.create(remoteResponse);
    console.log(verifiedAndTypesafeRemoteCat);
    // Output:
    // CatRemote { id: 1, name: 'Whiskers', age: 18, breed: 'Siamese' }

    // Create Cat
    const verifiedAndTypesafeCatSentToClient = Cat.create(verifiedAndTypesafeRemoteCat);
    console.log(verifiedAndTypesafeCatSentToClient);
    // Output:
    // Cat { name: 'Whiskers', ageCategory: 'Senior', breed: 'Siamese' }

About

This is a suggestion to structure models, validations and transformation in the BFF nitro version

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors