Koa middleware

node v10.24.1
version: 1.0.0
endpointsharetweet
const Koa = require( 'koa' ); const app = new Koa(); // Our most outer middleware, sending response to the user. app.use( async ( context, next ) => { await next(); // Passing control to the inner middleware. context.body = 'Hello World!'; } ); // Our most inner middleware, logging out request. app.use( async ( { request } ) => { console.log( 'Got request', request ); } ); app.listen( 3000 );
Loading…

no comments

    sign in to comment