Popularity
0.4
Growing
Activity
3.8
-
9
1
1

Description

Presentation and transformation layer for data output in RESTful APIs.

Monthly Downloads: 0
Programming language: TypeScript
License: MIT License
Tags: API     REST     JSON     serialization     Transformer    
Latest version: v2.0.1

Vicis alternatives and similar libraries

Based on the "API" category.
Alternatively, view Vicis alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of Vicis or a related project?

Add another 'API' Library

README

[Vicis](.github/assets/banner.webp?raw=true "Vicis")

Β« Vicis Β»

Presentation and transformation layer for data output in RESTful APIs.

β€’β€’ Vicis Documentation β€’β€’ JavaScript Repository β€’β€’ Deno Repository β€’β€’

npm downloads stars types build lgtm

This is Node.js analogue to these libraries: 🐘 Fractal for PHP, πŸ’Ž Roar for Ruby, 🍒 Marshmallow for Python.


πŸ’¬ Tl;dr

Code:

import { Vicis } from "vicis";
const configuration = {
  cast: { _id: Vicis.INTEGER, registered: Vicis.FLAG },
  defaults: { confirmed: false },
  exclude: [/(?:password)/gi, /^(?:_)(?:_)?/],
  omit: ["createdAt", "updatedAt", "deletedAt"],
  rename: { _id: "id", email: "login" },
  replace: { url: null }
};
const model = {
  _id: "54759309034942804",
  email: "[email protected]",
  userPassword: "36e80092ff7f1ed72903cda9409b9d2c",
  registered: "1",
  url: "example.com",
  createdAt: "2020-01-01 01:23:45",
  __v: 1
};
const serializer = new Vicis(configuration);
serializer.data(model);
console.log(serializer.getData());

Output:

{
  "confirmed": false,
  "id": 54759309034942804,
  "login": "[email protected]",
  "registered": true,
  "url": null
}

πŸ—ΊοΈ My other projects

Full list here

<!-- Badges -->