Skip to content
wrannaman edited this page Jun 10, 2019 · 2 revisions

sugar-generate APP Docs

sugar-generate can also create react components that will auto-magically talk to your generated back end.

  • this should go without saying but if you don't generate the api as well as the front end, the front end won't work because it has nothing to talk to...

Components

The basis of the app uses nextjs

Forms

There is a "create" form generated. It uses the schema to create the fields and validations.

Here is an example schema and the generated react component

  {
    "name": "user",
    "schema": {
      "name": {
        "type": "String",
        "default": ""
      },
      "email": {
        "type": "String",
        "trim": true,
        "required": true,
        "unique": true,
        "immutable": true,
        "htmlType": "email"
      },
      "intro": {
        "type": "Boolean",
        "default": false,
        "htmlType": "boolean"
      },
      "sub": {
        "one": {
          "type": "String",
          "trim": true,
          "required": true
        },
        "two": {
          "type": "String",
          "required": true
        },
        "three": {
          "type": "Number",
          "min": 0,
          "max": 1000,
          "htmlType": "number"
        }
      },
      "role": {
        "type": "String",
        "enum": ["user", "maker"],
        "default": "user",
        "htmlType": "radio"
      },
      "carrot": {
        "type": "String",
        "enum": ["sweet", "ugly"],
        "default": "ugly",
        "htmlType": "radio"
      }
    },
    "statics": {
      "statuses": ["created", "under_review", "listed", "deleted"],
      "status": {
        "active": "active",
        "inactive": "inactive",
        "deleted": "deleted"
      }
    }
  }

SugarKubes Generated App

Clone this wiki locally