• Overview
@angular/ssr/node

createNodeRequestHandler

function

Attaches metadata to the handler function to mark it as a special handler for Node.js environments.

API

  
    function createNodeRequestHandler<T extends NodeRequestHandlerFunction>(  handler: T): T;
  
  

createNodeRequestHandler

T

Attaches metadata to the handler function to mark it as a special handler for Node.js environments.

@paramhandlerT
  • The handler function to be defined and annotated.
@returnsT

Usage Notes

Usage in an Express application:

          
const app = express();export default createNodeRequestHandler(app);

Usage in a Hono application:

          
const app = new Hono();export default createNodeRequestHandler(async (req, res, next) => {  try {    const webRes = await app.fetch(createWebRequestFromNodeRequest(req));    if (webRes) {      await writeResponseToNodeResponse(webRes, res);    } else {      next();    }  } catch (error) {    next(error);  }}));

Usage in a Fastify application:

          
const app = Fastify();export default createNodeRequestHandler(async (req, res) => {  await app.ready();  app.server.emit('request', req, res);  res.send('Hello from Fastify with Node Next Handler!');}));
Jump to details