joblike / joblike-service

Server side using nest.js
1 stars 1 forks source link

Add infra ability for flowId out of the box #1

Closed cawak closed 4 years ago

cawak commented 4 years ago

All of our APIs should have a standard for a response with the following structure:

{
    "meta": {
        "flowId": "12345",
        "time": 123456789
    },
    "data": {
    },
    "error" {
        "message": "an error happened!",
        "code": 123
    }:
}

In this task we should strive to create and infra for the "meta" part:

  1. flowId - is the eventId - it should be created by an interceptor / pipe. We should push it to a context so that it will be available by the appropriate session.
  2. time - should be an epoch time in millis. No time format issues anymore!
cawak commented 4 years ago

Server - Add infra ability for flowId out of the box

cawak commented 4 years ago

This task should be divided by request / response. The moment we got a request, we must trigger a metadata object which contains flowId value. This value should be reachable during the request handling. We will also use it while sending a response.

The second part is to generate this JSON. It should be easy once we will use interceptors (need to validate to use them and not pipes, middleware etc.).