Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/royalicing/lofi-schema-elm
Friendly syntax for creating schemas, output to Swift, React PropTypes, Elm, Golang, MongoDB, and more
https://github.com/royalicing/lofi-schema-elm
elm golang joi mongoose mongoose-schema mysql proptypes react schema swift
Last synced: about 1 month ago
JSON representation
Friendly syntax for creating schemas, output to Swift, React PropTypes, Elm, Golang, MongoDB, and more
- Host: GitHub
- URL: https://github.com/royalicing/lofi-schema-elm
- Owner: BurntCaramel
- Created: 2017-04-01T05:04:55.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-02T05:59:38.000Z (over 6 years ago)
- Last Synced: 2024-10-07T21:04:39.087Z (about 1 month ago)
- Topics: elm, golang, joi, mongoose, mongoose-schema, mysql, proptypes, react, schema, swift
- Language: JavaScript
- Homepage: https://schema.lofi.design
- Size: 546 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# #lofi #schema in Elm
Low fidelity schemas. Write with a friendly syntax and convert to other forms easily.
## Interactive demo
I’ve made an [online tool to convert #lofi schemas](https://schema.lofi.design/). Convert to React PropTypes, Mongoose schemas, Joi validations, and MySQL commands.
## Basic usage
```elm
import Html exposing (Html, section, h2, pre, text)
import Lofi.Parse exposing (parseElement)
import Lofi.Schema exposing (Schema, fromElement)
import Lofi.Schema.Output.MySQL as MySQL
import Lofi.Schema.Output.Mongoose as Mongoose
import Lofi.Schema.Output.Joi as Joi
import Lofi.Schema.Output.ReactProps as ReactProps
import Lofi.Schema.Output.Swift as Swift
import Lofi.Schema.Output.Elm as Elm
import Lofi.Schema.Output.Go as Gotype alias Model =
{ collectionName : String
, individualName : String
, lines : List String
}model : Model
model =
{ collectionName = "Users"
, individualName = "User"
, lines =
[ "First name"
, "Middle name #optional"
, "Last name #text #max: 255"
, "Email #email"
, "Date of birth #date"
, "Last signed in at #time #now"
, "Favorite number #number #default: 7"
]
}view : Model -> Html Msg
view model =
let
elements =
List.map parseElement model.linesschema : Schema
schema =
{ collectionName = model.collectionName
, individualName = model.individualName
, items = List.map fromElement elements
}
in
section []
[ article []
[ h2 [] [ text "React PropTypes" ]
, pre [] [ text (ReactProps.createPropTypesCode schema) ]
]
, article []
[ h2 [] [ text "Mongoose" ]
, pre [] [ text (Mongoose.createModelCode schema) ]
]
, article []
[ h2 [] [ text "Swift" ]
, pre [] [ text (Swift.createStructCode schema) ]
]
, article []
[ h2 [] [ text "Elm" ]
, pre [] [ text (Elm.createTypeAliasCode schema) ]
]
, article []
[ h2 [] [ text "Golang" ]
, pre [] [ text (Go.createStructCode schema) ]
]
, article []
[ h2 [] [ text "Joi" ]
, pre [] [ text (Joi.createSchemaCode schema) ]
]
, article []
[ h2 [] [ text "MySQL" ]
, pre [] [ text (MySQL.createTableCommand schema) ]
, pre [] [ text (MySQL.insertRowCommand schema) ]
]
]
```