Skip to content

Codebase

Artem Ivanec edited this page Oct 14, 2021 · 2 revisions

Data flow

Front end client makes a request to AIDBOX_URL directly, so you can not change entrypoints if you need specific behaviour, but you can add service which may be written on any language (currently we use NodeJS server sdk) to extend Aidbox's behaviour.

The following env variables let Aidbox server register and use your application service:

APP_ID
APP_SECRET
APP_URL
APP_PORT

Manifest

To register seeds, change schema, add custom operations, etc., you need to create a manifest. For example:

export const manifest = {
  resources: {
    Client: {
      'some-client-id': {
        'some-field': 'some-data',
      },
    },
    User: {
      'some-user-id': {
        'some-field': 'some-data',
      },
    },
  },
  operations: {
    'any name of operation': {
      method: 'GET',
      path: ['url-to-make-request'],
      handlerFn: async (request, { ctx }) => {
        return 'hello world';
      },
    },
  },
  entities: {
    Patient: {
      attrs: {
        some-attr: {
          type: 'boolean',
        },
      },
    },
  },
};

When application will start manifest will be uploaded to Aidbox server.

You can discover our current manifest

Add custom operations

You can add as much custom operations as you want, for example:

// operations-file
export const op = {
  method: 'POST',
  path: ['do-somehting-and-send-email'],
  handlerFn: async (request, { ctx }) => {
    // do somehting
    sendMail({
      from: 'test@test.our',
      to: 'test@test.your',
      subject: 'Hello World',
      html: `<html><p>Hello world</p></html>`,
    });
  },
};

// in manifest file
import * as operations from './operations-file'
const manifest = { ..., operations }

So from client you jsut need to send POST request to http://AIDBOX_URL/do-something-and-send-email.. Aidbox will redirect request to app. To make it work for example you may check our docker-compose file.

Clone this wiki locally