@flightdev/http 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -17
- package/package.json +7 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @flightdev/http
|
|
2
2
|
|
|
3
3
|
HTTP server for Flight Framework. Built on Web Standard APIs with radix-tree routing for maximum performance. Runs on Node.js, Bun, and Deno.
|
|
4
4
|
|
|
@@ -39,7 +39,7 @@ HTTP server for Flight Framework. Built on Web Standard APIs with radix-tree rou
|
|
|
39
39
|
## Installation
|
|
40
40
|
|
|
41
41
|
```bash
|
|
42
|
-
npm install @
|
|
42
|
+
npm install @flightdev/http
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
---
|
|
@@ -47,8 +47,8 @@ npm install @flight-framework/http
|
|
|
47
47
|
## Quick Start
|
|
48
48
|
|
|
49
49
|
```typescript
|
|
50
|
-
import { createServer } from '@
|
|
51
|
-
import { serve } from '@
|
|
50
|
+
import { createServer } from '@flightdev/http';
|
|
51
|
+
import { serve } from '@flightdev/http/node';
|
|
52
52
|
|
|
53
53
|
const app = createServer();
|
|
54
54
|
|
|
@@ -136,7 +136,7 @@ app.get('/files/*', (c) => {
|
|
|
136
136
|
### Type-Safe Parameters
|
|
137
137
|
|
|
138
138
|
```typescript
|
|
139
|
-
import type { Context } from '@
|
|
139
|
+
import type { Context } from '@flightdev/http';
|
|
140
140
|
|
|
141
141
|
interface UserParams {
|
|
142
142
|
id: string;
|
|
@@ -375,7 +375,7 @@ app.notFound((c) => {
|
|
|
375
375
|
### Throwing Errors
|
|
376
376
|
|
|
377
377
|
```typescript
|
|
378
|
-
import { HTTPException } from '@
|
|
378
|
+
import { HTTPException } from '@flightdev/http';
|
|
379
379
|
|
|
380
380
|
app.get('/protected', (c) => {
|
|
381
381
|
if (!c.get('user')) {
|
|
@@ -393,7 +393,7 @@ Organize routes into modules:
|
|
|
393
393
|
|
|
394
394
|
```typescript
|
|
395
395
|
// routes/users.ts
|
|
396
|
-
import { createServer } from '@
|
|
396
|
+
import { createServer } from '@flightdev/http';
|
|
397
397
|
|
|
398
398
|
export const users = createServer();
|
|
399
399
|
|
|
@@ -402,7 +402,7 @@ users.get('/:id', (c) => c.json({ id: c.params.id }));
|
|
|
402
402
|
users.post('/', (c) => c.json({ created: true }));
|
|
403
403
|
|
|
404
404
|
// main.ts
|
|
405
|
-
import { createServer } from '@
|
|
405
|
+
import { createServer } from '@flightdev/http';
|
|
406
406
|
import { users } from './routes/users';
|
|
407
407
|
|
|
408
408
|
const app = createServer();
|
|
@@ -423,8 +423,8 @@ app.route('/api/users', users);
|
|
|
423
423
|
### Node.js
|
|
424
424
|
|
|
425
425
|
```typescript
|
|
426
|
-
import { createServer } from '@
|
|
427
|
-
import { serve } from '@
|
|
426
|
+
import { createServer } from '@flightdev/http';
|
|
427
|
+
import { serve } from '@flightdev/http/node';
|
|
428
428
|
|
|
429
429
|
const app = createServer();
|
|
430
430
|
|
|
@@ -437,8 +437,8 @@ serve(app, {
|
|
|
437
437
|
### Bun
|
|
438
438
|
|
|
439
439
|
```typescript
|
|
440
|
-
import { createServer } from '@
|
|
441
|
-
import { serve } from '@
|
|
440
|
+
import { createServer } from '@flightdev/http';
|
|
441
|
+
import { serve } from '@flightdev/http/bun';
|
|
442
442
|
|
|
443
443
|
const app = createServer();
|
|
444
444
|
|
|
@@ -454,8 +454,8 @@ Bun.serve({
|
|
|
454
454
|
### Deno
|
|
455
455
|
|
|
456
456
|
```typescript
|
|
457
|
-
import { createServer } from '@
|
|
458
|
-
import { serve } from '@
|
|
457
|
+
import { createServer } from '@flightdev/http';
|
|
458
|
+
import { serve } from '@flightdev/http/deno';
|
|
459
459
|
|
|
460
460
|
const app = createServer();
|
|
461
461
|
|
|
@@ -468,7 +468,7 @@ Deno.serve({ port: 3000 }, app.fetch);
|
|
|
468
468
|
### Cloudflare Workers
|
|
469
469
|
|
|
470
470
|
```typescript
|
|
471
|
-
import { createServer } from '@
|
|
471
|
+
import { createServer } from '@flightdev/http';
|
|
472
472
|
|
|
473
473
|
const app = createServer();
|
|
474
474
|
|
|
@@ -486,7 +486,7 @@ export default {
|
|
|
486
486
|
Serve static files from a directory:
|
|
487
487
|
|
|
488
488
|
```typescript
|
|
489
|
-
import { serveStatic } from '@
|
|
489
|
+
import { serveStatic } from '@flightdev/http/static';
|
|
490
490
|
|
|
491
491
|
// Serve from 'public' directory
|
|
492
492
|
app.use('/static/*', serveStatic({ root: './public' }));
|
|
@@ -506,7 +506,7 @@ app.use('/assets/*', serveStatic({
|
|
|
506
506
|
Enable Cross-Origin Resource Sharing:
|
|
507
507
|
|
|
508
508
|
```typescript
|
|
509
|
-
import { cors } from '@
|
|
509
|
+
import { cors } from '@flightdev/http/cors';
|
|
510
510
|
|
|
511
511
|
// Allow all origins
|
|
512
512
|
app.use(cors());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flightdev/http",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "Ultra-fast HTTP server for Flight Framework - Built on Web Standards",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"flight",
|
|
@@ -45,6 +45,12 @@
|
|
|
45
45
|
"typescript": "^5.7.0",
|
|
46
46
|
"vitest": "^2.0.0"
|
|
47
47
|
},
|
|
48
|
+
"homepage": "https://github.com/EliosLT/FlightDev",
|
|
49
|
+
"repository": {
|
|
50
|
+
"url": "https://github.com/EliosLT/FlightDev.git",
|
|
51
|
+
"directory": "packages/http",
|
|
52
|
+
"type": "git"
|
|
53
|
+
},
|
|
48
54
|
"scripts": {
|
|
49
55
|
"build": "tsup",
|
|
50
56
|
"dev": "tsup --watch",
|