Error [ERR_STREAM_WRITE_AFTER_END]: write after end (NodeJS)

I’m trying to make an api endpoint using nodejs. When i hit the route using postman i got error. First time the code runs and then the server is crashed.

My code is:

const http = require('http');
const {handleReqRes} = require('./helpers/handleReqRes');

const app = {};

app.config = {
    port: 5000,
};

app.createServer = () => {
    const server = http.createServer(app.handleReqRes);
    server.listen(app.config.port, () => {
        console.log(`listening to port ${app.config.port}`);
    });
};

app.handleReqRes = handleReqRes;

app.createServer();

On terminal when i request anyting the error showing:

node:events:491
      throw er; // Unhandled 'error' event
      ^

Error [ERR_STREAM_WRITE_AFTER_END]: write after end
    at new NodeError (node:internal/errors:387:5)
    at ServerResponse.end (node:_http_outgoing:968:15)
    at IncomingMessage.<anonymous> (/home/rafid/Desktop/personal_akam/Node/raw_node_api/helpers/handleReqRes.js:52:13)
    at IncomingMessage.emit (node:events:525:35)
    at endReadableNT (node:internal/streams/readable:1358:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
Emitted 'error' event on ServerResponse instance at:
    at emitErrorNt (node:_http_outgoing:827:9)
    at processTicksAndRejections (node:internal/process/task_queues:84:21) {
  code: 'ERR_STREAM_WRITE_AFTER_END'
}```


Trying to make an api endpoint using nodejs.