https://github.com/r37r0m0d3l/deno-vicis
Presentation and transformation layer for data output in RESTful APIs.
https://github.com/r37r0m0d3l/deno-vicis
api json json-api responder responder-chain response rest serialization transformer
Last synced: about 1 month ago
JSON representation
Presentation and transformation layer for data output in RESTful APIs.
- Host: GitHub
- URL: https://github.com/r37r0m0d3l/deno-vicis
- Owner: r37r0m0d3l
- License: mit
- Created: 2020-06-30T22:49:42.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-08-13T12:38:35.000Z (almost 6 years ago)
- Last Synced: 2025-10-20T17:52:08.901Z (8 months ago)
- Topics: api, json, json-api, responder, responder-chain, response, rest, serialization, transformer
- Language: JavaScript
- Homepage: https://vicis.js.org
- Size: 66.4 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README

# « Vicis 🧮 🦕 »
Presentation and transformation layer for data output in RESTful APIs.
•• [Vicis Documentation](https://vicis.js.org) •• [JavaScript Repository](https://github.com/r37r0m0d3l/vicis) •• [Deno Repository](https://github.com/r37r0m0d3l/deno-vicis) ••
This is Deno analogue to these libraries: 🐘 [Fractal](https://fractal.thephpleague.com/) for PHP, 💎 [Roar](https://github.com/trailblazer/roar) for Ruby, 🍢 [Marshmallow](https://marshmallow.readthedocs.io/en/stable/) for Python.
[![Buy Me A Coffee][buymeacoffee-img]][buymeacoffee-url]

---
## 💬 Tl;dr
Code:
```js
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: "johnwick@gmail.com",
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:
```json
{
"confirmed": false,
"id": 54759309034942804,
"login": "johnwick@gmail.com",
"registered": true,
"url": null
}
```
## ⚙️Install
### Import from URL
```typescript
// 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"
```json
{
"imports": {
"vicis": "https://deno.land/x/vicis/mod.ts"
}
}
```
```typescript
import { Vicis } from "vicis";
```
```bash
deno run --importmap=importmap.json --unstable your-script.js
```
## 🗺️ My other projects
[Full list here](https://r37r0m0d3l.icu/open_source_map)

[buymeacoffee-url]: https://buymeacoffee.com/r37r0m0d3l
[buymeacoffee-img]: https://img.shields.io/badge/support-buymeacoffee-1E90FF.svg?&logo=buy-me-a-coffee&label=support