https://github.com/tootallnate/fetch-server
https://github.com/tootallnate/fetch-server
Last synced: 14 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/tootallnate/fetch-server
- Owner: TooTallNate
- Created: 2020-10-04T06:06:20.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-02-25T21:12:39.000Z (over 2 years ago)
- Last Synced: 2025-06-27T00:20:58.712Z (17 days ago)
- Language: TypeScript
- Homepage:
- Size: 17.6 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Deploy to a Vercel API endpoint:
```ts
// api/hello.tsimport 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.tsimport 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);
```