Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tootallnate/fetch-server


https://github.com/tootallnate/fetch-server

Last synced: 22 days ago
JSON representation

Awesome Lists containing this project

README

        

Deploy to a Vercel API endpoint:

```ts
// api/hello.ts

import fetchServer from 'fetch-server';

export default fetchServer(async req => {
console.log(req.url);
console.log(req.headers.get('x-custom'));

return Response.json({ hello: 'world' });
});
```

Standalone:

```ts
// server.ts

import http from 'node:http';
import fetchServer from 'fetch-server';

const server = http.createServer(fetchServer(async req => {
console.log(req.url);
console.log(req.headers.get('x-custom'));

return Response.json({ hello: 'world' });
}));

server.listen(3000);
```