Git Product home page Git Product logo

deno-vicis's Introduction

Vicis

« Vicis 🧮 🦕 »

Presentation and transformation layer for data output in RESTful APIs.

•• Vicis Documentation •• JavaScript Repository •• Deno Repository ••

This is Deno analogue to these libraries: 🐘 Fractal for PHP, 💎 Roar for Ruby, 🍢 Marshmallow for Python.

Buy Me A Coffee Tests


💬 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
}

⚙️Install

Import from URL

// From URL
import { Vicis } from "https://deno.land/x/vicis/mod.ts";
// Bundled from URL
import { Vicis } from "https://deno.land/x/vicis/vicis.bundle.js";

Import from "importmap.json"

{
  "imports": {
    "vicis": "https://deno.land/x/vicis/mod.ts"
  }
}
import { Vicis } from "vicis";
deno run --importmap=importmap.json --unstable your-script.js

🗺️ My other projects

Full list here

deno-vicis's People

Contributors

r37r0m0d3l avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.