Package to extend express to respond structured json object

Usage no npm install needed!

<script type="module">
  import expressResponseConfig from '';


Express Response Config

Express Response is a tiny, zero dependencies module to allow to extend express.response object by adding user defined structure of response object.

Usage example

Install Express Response

npm install express-response-config

Define parameters object

const parameters = {
    responseName: 'myCustomResponse',
    responseObKeys = ['message', 'data']

In your bootstrap file (where express is imported) call express-response

const express = require('express')

const app = express()

Call your custom response in your handler

Now handler takes two parameters:

  • status code: integer
  • object with keys defined in bootstrap file
 myHandler = (req, res) => {
    return res.myCustomResponse(200, {
        message: 'my custom message',
        data: {
            a: 'b'

Please note:

  • Not all parameters defined in responseObKeys have to be use as response object keys
  • Any key used in response object, which has not been defined in responseObKeys will be ignored

Api will respond with:

    "message": "my custom message",
    "data": {
        "a": "b"