0.0.4 • Published 8 years ago

u5-domain v0.0.4

Weekly downloads
5
License
ISC
Repository
-
Last release
8 years ago

What?

The idea is to describe a domain (classes, their properties and relationships) for a business application, so that other artefacts can be deduced from it.

This is probably not going to be a generic tool, but may be useful in our context / on our stack.

The aspects we try to cover here:

  • persistence
  • API
  • validation

Example

Say, we need orders and order items in our domain model. We may describe the domain model as follows:

const orderType = new DomainType({
  name: 'Order',
  fields: {
    id: DomainID,
    orderedByName: { type: DomainString, required: true },
    orderedByEmail: {
      type: DomainString,
      validate: v => /\S+@\S+\.\S+/.test(v) // TODO: don't validate email addresses like this in real life
    }
    tipInCents: DomainInt
  },
  belongsTo: {
    shop: 'Shop'
  }
})

// TODO: complete the example

const domainSchema = new DomainSchema([ orderType, shopType ])
import * as graphql from 'graphql'
const graphQLOrderType = domain.toGraphQLSchema(graphql, domainSchema)
0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago