Form Express API

You can use Form Express API to link the client UI and your server data model.

Form Express API helps to perform the next requests:

Method URL Description
GET / Get form data
POST / Submit form data
POST /validation Validate form data


  const formApiBuilder = UIKernel.formExpressApi();    //initializes builder

Builder methods



Specify a form model which must implement Form Model Interface can be an instance or a constructor so that the Form Express Api will be able to use the provided data model to perform client requests.


Type Name Description
FormModel formModel Required. The instance of a Form model


Type Name Description
Function getModel Required. Function to be called with Express middleware’s req and res parameters returning a Form model instance.



Specify a function to be called when the response is ready.


Type Name Description
Function callback Optional. Function to be called with the result.

callbacks arguments:

Type Name Description
Any err Error caught from model methods
Any data Result returned by model methods


  const router = formApiBuilder.getRouter();

Creates an Express router object with middlewares performing requests specified above.

Usage example

Pass a model instance to Express API:

  import advertisersModel from 'somewhere';
  const router = UIKernel.formExpressApi()

Or use a constructor for that:

  import AdvertisersModel from 'somewhere';
  const router = UIKernel.formExpressApi()
    .model((req, res) => {
      return new AdvertisersModel(req.params.param1, res.locals.param2)

To interact with this API at front-end use Form XHR Model.

You can also customize your API with some additional methods, or perform a similar behaviour using other frameworks of course.

Example of customizing provided API with your own methods

  import model from 'somewhere';
  const router = UIKernel.formExpressApi()
    //here you can add performing of some other API requests:
    .get('/:additionalParamId', async (req, res, next) => {
      await model.getAdditionalInfo(req.params.additionalParamId);