@flightdev/http 0.0.4 → 0.1.0
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 +62 -56
- package/LICENSE +0 -21
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,57 +1,63 @@
|
|
|
1
|
-
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@flightdev/http",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Ultra-fast HTTP server for Flight Framework - Built on Web Standards",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"flight",
|
|
7
|
+
"http",
|
|
8
|
+
"server",
|
|
9
|
+
"web-standards",
|
|
10
|
+
"edge"
|
|
11
|
+
],
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"author": "Flight Contributors",
|
|
14
|
+
"type": "module",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"import": "./dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./node": {
|
|
21
|
+
"types": "./dist/adapters/node.d.ts",
|
|
22
|
+
"import": "./dist/adapters/node.js"
|
|
23
|
+
},
|
|
24
|
+
"./bun": {
|
|
25
|
+
"types": "./dist/adapters/bun.d.ts",
|
|
26
|
+
"import": "./dist/adapters/bun.js"
|
|
27
|
+
},
|
|
28
|
+
"./deno": {
|
|
29
|
+
"types": "./dist/adapters/deno.d.ts",
|
|
30
|
+
"import": "./dist/adapters/deno.js"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"main": "./dist/index.js",
|
|
34
|
+
"types": "./dist/index.d.ts",
|
|
35
|
+
"files": [
|
|
36
|
+
"dist"
|
|
37
|
+
],
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsup",
|
|
40
|
+
"dev": "tsup --watch",
|
|
41
|
+
"test": "vitest run",
|
|
42
|
+
"test:watch": "vitest",
|
|
43
|
+
"lint": "eslint src/",
|
|
44
|
+
"clean": "rimraf dist",
|
|
45
|
+
"typecheck": "tsc --noEmit"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"radix3": "^1.1.0"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@types/node": "^22.0.0",
|
|
52
|
+
"rimraf": "^6.0.0",
|
|
53
|
+
"tsup": "^8.0.0",
|
|
54
|
+
"typescript": "^5.7.0",
|
|
55
|
+
"vitest": "^2.0.0"
|
|
56
|
+
},
|
|
57
|
+
"homepage": "https://github.com/EliosLT/FlightDev",
|
|
58
|
+
"repository": {
|
|
59
|
+
"url": "https://github.com/EliosLT/FlightDev.git",
|
|
60
|
+
"directory": "packages/http",
|
|
61
|
+
"type": "git"
|
|
62
|
+
}
|
|
57
63
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024-2026 Flight Contributors
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|