All Projects → just-sultanov → Clj Unifier

just-sultanov / Clj Unifier

Licence: mit
[DEPRECATED] A Clojure(Script) library for unified responses

Programming Languages

clojure
4091 projects
clojurescript
191 projects

Labels

Projects that are alternatives of or similar to Clj Unifier

Refraction
A guard that represents a central point of control in your application
Stars: ✭ 151 (+504%)
Mutual labels:  data-flow
eventkit
Event-driven data pipelines
Stars: ✭ 94 (+276%)
Mutual labels:  data-flow
richflow
A Node.js and JavaScript synchronous data pipeline processing, data sharing and stream processing library. Actionable & Transformable Pipeline data processing.
Stars: ✭ 17 (-32%)
Mutual labels:  data-flow
N8n
Free and open fair-code licensed node based Workflow Automation Tool. Easily automate tasks across different services.
Stars: ✭ 19,252 (+76908%)
Mutual labels:  data-flow
roda
Röda: A stream-oriented scripting language
Stars: ✭ 43 (+72%)
Mutual labels:  data-flow
hellhound
A set of libraries to create asynchronous, high performance, scalable and simple application.
Stars: ✭ 33 (+32%)
Mutual labels:  data-flow
Ngx Model
Angular Model. Simple state management with minimalistic API, one way data flow, multiple model support and immutable data exposed as RxJS Observable.
Stars: ✭ 137 (+448%)
Mutual labels:  data-flow
Store
Android Library for Async Data Loading and Caching
Stars: ✭ 3,593 (+14272%)
Mutual labels:  data-flow
realar
5 kB Advanced state manager for React
Stars: ✭ 41 (+64%)
Mutual labels:  data-flow
GVProf
GVProf: A Value Profiler for GPU-based Clusters
Stars: ✭ 25 (+0%)
Mutual labels:  data-flow
Cenit
🚀 Cenit IO - 100% open source integration Platform (iPaaS)
Stars: ✭ 186 (+644%)
Mutual labels:  data-flow
graflow
A graph stream library for Javascript
Stars: ✭ 53 (+112%)
Mutual labels:  data-flow
rule-engine
基于流程,事件驱动,可拓展,响应式,轻量级的规则引擎。
Stars: ✭ 165 (+560%)
Mutual labels:  data-flow
Redux First History
🎉 Redux First History - Redux history binding support react-router - @reach/router - wouter
Stars: ✭ 163 (+552%)
Mutual labels:  data-flow
Systemizer
A system design tool that allows you to simulate data flow of distributed systems.
Stars: ✭ 1,219 (+4776%)
Mutual labels:  data-flow
Flow View
is a visual editor for Dataflow programming
Stars: ✭ 148 (+492%)
Mutual labels:  data-flow
mutable
State containers with dirty checking and more
Stars: ✭ 32 (+28%)
Mutual labels:  data-flow
Xreact
reactive x react = xreact
Stars: ✭ 565 (+2160%)
Mutual labels:  data-flow
actionizer
Simple pub/sub for data flow like Redux.
Stars: ✭ 21 (-16%)
Mutual labels:  data-flow
react-wrangler
A react component for simple declarative state management with "one way data flow" and side effects
Stars: ✭ 16 (-36%)
Mutual labels:  data-flow

image:https://img.shields.io/github/license/just-sultanov/clj-unifier[license,link=LICENSE] image:https://codecov.io/gh/just-sultanov/clj-unifier/branch/master/graph/badge.svg[codecov,link=https://codecov.io/gh/just-sultanov/clj-unifier] image:https://github.com/just-sultanov/clj-unifier/workflows/build/badge.svg[build] image:https://github.com/just-sultanov/clj-unifier/workflows/deploy/badge.svg[deploy] image:https://img.shields.io/clojars/v/clj-unifier.svg[clojars,link=https://clojars.org/clj-unifier] image:https://cljdoc.org/badge/clj-unifier/clj-unifier[cljdoc,link=https://cljdoc.org/d/clj-unifier/clj-unifier/CURRENT]

Attention!

This library is DEPRECATED! Use the next library - link:https://github.com/just-sultanov/ninja.platform/blob/master/docs/ninja.tools/ninja.response.adoc[ninja.platform/response]

== clj-unifier

A Clojure(Script) library for unified responses.

=== Quick Start Guide

Add the following dependency in your project:

[source,clojure]

;; project.clj or build.boot [clj-unifier "0.0.15"]

;; deps.edn {:deps {clj-unifier {:mvn/version "0.0.15"}}}


=== Example

You can see a full example link:https://github.com/just-sultanov/clj-unifier/tree/master/examples/src/example[here].

[source,clojure]

(ns your.app (:require [unifier.response :as r] [unifier.response.http :as http]))

;;;; ;; Unified responses ;;;;

;; Unified success responses (r/as-success "data") ;; data with default response type ;; => #unifier.response.UnifiedSuccess{:type :unifier.response/success, :data "data", :meta nil}

(r/as-success "data" "meta") ;; data and meta with default response type ;; => #unifier.response.UnifiedSuccess{:type :unifier.response/success, :data "data", :meta "meta"}

(r/as-success ::pass "data" "meta") ;; data and meta with user-defined response type ;; => #unifier.response.UnifiedSuccess{:type :your.app/pass, :data "data", :meta "meta"}

;; Unified error responses (r/as-error "data") ;; data with default response type ;; => #unifier.response.UnifiedError{:type :unifier.response/error, :data "data", :meta nil}

(r/as-error "data" "meta") ;; data and meta with default response type ;; => #unifier.response.UnifiedError{:type :unifier.response/error, :data "data", :meta "meta"}

(r/as-error ::fail "data" "meta") ;; data and meta with user-defined response type ;; => #unifier.response.UnifiedError{:type :your.app/fail, :data "data", :meta "meta"}

;;;; ;; Public API ;;;;

;; Predicates r/response? r/error?
r/success?

;; Getters r/get-type r/get-data r/get-meta

;; Setters r/set-type r/set-data r/set-meta

;; Helpers r/unwrap r/-> r/->> r/?-> r/?->>

;; HTTP r/link! r/link r/as-http

;;;; ;; Examples ;;;;

(defn create [email] (if-some [user (db/create email)] (r/as-success :user/created user {:i18n/key :user/created :i18n/params email}) (r/as-error :user/not-created email {:i18n/key :user/exists :i18n/params email})))

(defmulti execute (fn [{:cmd/keys [version name]}] [version name]))

(defmethod execute :default [{:as cmd :cmd/keys [version name]}] (r/as-unsupported cmd {:i18n/key ::unsupported :i18n/params [version name]}))

;;;; ;; Unified http responses ;;;;

(r/as-http (r/as-success "data")) ;; => {:status 200, :headers {}, :body {:type :unifier.response/success, :data "data", :meta nil}}

(r/as-http (r/as-error "data")) ;; => {:status 500, :headers {}, :body {:type :unifier.response/error, :data "data", :meta nil}}

;;;; ;; Available predefined unified success responses associated with http response types ;;;;

r/as-success -> :unifier.response/success -> :unifier.response.http/ok -> 200 r/as-created -> :unifier.response/created -> :unifier.response.http/created -> 201 r/as-deleted -> :unifier.response/deleted -> :unifier.response.http/no-content -> 204 r/as-accepted -> :unifier.response/accepted -> :unifier.response.http/accepted -> 202

;;;; ;; Available predefined unified error responses associated with http response types ;;;;

r/as-error -> :unifier.response/error -> :unifier.response.http/internal-server-error -> 500 r/as-exception -> :unifier.response/exception -> :unifier.response.http/internal-server-error -> 500 r/as-unknown -> :unifier.response/unknown -> :unifier.response.http/bad-request -> 400 r/as-warning -> :unifier.response/warning -> :unifier.response.http/bad-request -> 400 r/as-unavailable -> :unifier.response/unavailable -> :unifier.response.http/service-unavailable -> 503 r/as-interrupted -> :unifier.response/interrupted -> :unifier.response.http/bad-request -> 400 r/as-incorrect -> :unifier.response/incorrect -> :unifier.response.http/bad-request -> 400 r/as-unauthorized -> :unifier.response/unauthorized -> :unifier.response.http/unauthorized -> 401 r/as-forbidden -> :unifier.response/forbidden -> :unifier.response.http/forbidden -> 403 r/as-unsupported -> :unifier.response/unsupported -> :unifier.response.http/method-not-allowed -> 405 r/as-not-found -> :unifier.response/not-found -> :unifier.response.http/not-found -> 404 r/as-conflict -> :unifier.response/conflict -> :unifier.response.http/conflict -> 409 r/as-busy -> :unifier.response/busy -> :unifier.response.http/service-unavailable -> 503

=== Development

[source,bash]

Run REPL & connect from your IDE

$ make repl

=== Testing

[source,bash]

Run all tests

$ make test

Run Clojure tests

$ make test-clj

Run ClojureScript tests

$ make test-cljs

=== Deploy

[source,bash]

create a new git tag

available types patch, minor, major, minor-rc, major-rc, minor-release, major-release

$ make patch

push a new git tag

$ make release

=== Available commands

[source,bash]

$ make help help Show help clean Clean repl Run REPL lint Run linter test-cljs Run ClojureScript tests test-clj Run Clojure tests test Run tests jar Build jar install Install locally deploy Deploy to repository init Init first version patch Increment patch version minor Increment minor version major Increment major version minor-rc Increment minor-rc version major-rc Increment major-rc version minor-release Increment minor-release version major-release Increment major-release version release Release a new version

=== License

link:LICENSE[Copyright © 2019-2020 Ilshat Sultanov]

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].