DocumentationEscape Hatches

Escape Hatches

We firmly believe that you shouldn’t need to escape out of Kaito’s control. It covers the 9.98/10 use cases of an API-oriented HTTP framework.

But, perhaps, say you need to setup a Webhook server for Stripe… Or want to add an OAuth callback handler. This previously has not been possible in Kaito.

Raw Routes

Kaito supports what we called “Raw Routes” which is direct access to the raw http request and response objects.

⚠️

Raw routes are not type safe, do not catch errors like regular routes nor provide regular Kaito req and res objects.

Raw routes are defined when you initialise your server. Below is an example of how to use raw routes.

const server = createServer({
	// ...
 
	rawRoutes: {
		GET: [
			{
				path: '/',
				handler: (req, res) => {
					res.end('Hello World');
				},
			},
 
			{
				path: '/test',
				handler: (req, res) => {
					res.end('Test');
				},
			},
		],
	},
});

Now, if you visit / or /test you will see the response from the raw route. Kaito has not handled them at all