Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tootallnate/fetch-server
https://github.com/tootallnate/fetch-server
Last synced: 22 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/tootallnate/fetch-server
- Owner: TooTallNate
- Created: 2020-10-04T06:06:20.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-02-25T21:12:39.000Z (almost 2 years ago)
- Last Synced: 2024-10-24T02:44:28.252Z (3 months 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);
```