Code Monkey home page Code Monkey logo

cedar's Introduction

cedar PyPI version Build Status Coverage Status Codacy Badge

This is alpha-level stuff.

Cedar is a small web service declaration language. You declare your service using this language and then use that declaration to generate client and server code for a number of programming languages.

Goals

  • A single transport (http) and serialization format (json).
  • Simple, consolidated tooling. All functionality must live under this repository and must be distributed under one package.
  • Aim to be an 85% solution. Be the most simple thing that covers the widest array of use cases. Never add complexity for the sake of covering fringe use cases.
  • Generated source code must be idiomatic to the generated language.
  • Generated source code must be human-readable.

Installation

pip3 install cedar

Languages

Cedar currently targets Elm (clients) and Go (servers) source code.

Go

cedar generate go --help

Requirements

Generated Go code has no external dependencies, but it does require at least Go version 1.6.

Elm

cedar generate elm --help

Requirements

Generated Elm code currently requires Elm 0.17 and the following packages:

The Cedar language

A Cedar specification consists of one or more toplevel declarations. All toplevel declarations must be valid enums, unions, records or fns.

Example

enum Role { User, Mod, Admin }

record User {
  id Int
  email String
  role Role
}

fn getUsers() [User]
fn getUser(id Int) User?
fn deleteUser(id Int) Bool

Types

There are 5 builtin types: Bool, Int, Float, String and Timestamp.

List types are declared using the [t] syntax (eg. [String]), dict types are declared using the {String: t} syntax, and nullable types are declared using the t? syntax.

Enums

enum Status { Ready, Done, Failed }

Enums introduce new types (named after the enum) whose values are constrained to the tags defined in the enum. The tags inside an enum are serialized as strings. For example, a record attribute with the type Status can contain one of the following JSON values: "Ready", "Done" and "Failed".

Unions

union Resource { Post, Comment }

Unions join multiple types under a single new type.

Records

record Post {
  id Int
  title String
  content String
  publishedAt Timestamp
}

Functions

fn createPost(title String, content String, publishedAt Timestamp?) Post

Editor support

cedar's People

Contributors

bogdanp avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  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.