Comparing version 0.4.7 to 0.5.0
@@ -1,6 +0,4 @@ | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import { Http2SecureServer, Http2Server, Http2ServerRequest, Http2ServerResponse } from 'node:http2'; | ||
import { Request } from './request.js'; | ||
import { Response } from './response.js'; | ||
import { type Request } from './request.js'; | ||
import { type Response } from './response.js'; | ||
import { Router, __InternalRouter } from './router.js'; | ||
@@ -7,0 +5,0 @@ export * from './middleware/index.js'; |
@@ -1,2 +0,1 @@ | ||
/// <reference types="node" /> | ||
import type { Request } from '../request.js'; | ||
@@ -3,0 +2,0 @@ import type { Response } from '../response.js'; |
import type { Request } from '../request.js'; | ||
import type { Response } from '../response.js'; | ||
export declare function serveFiles(rootPath: string, options?: ServeFilesOptions): (req: Request, res: Response) => Promise<"next">; | ||
export declare function serveFile(filePath: string, options?: ServeFileOptions): (req: Request, res: Response) => Promise<"next">; | ||
export declare function serveFiles(rootPath: string, options?: ServeFilesOptions): (req: Request, res: Response) => Promise<void | "next">; | ||
export declare function serveFile(filePath: string, options?: ServeFileOptions): (req: Request, res: Response) => Promise<void | "next">; | ||
interface ServeFilesOptions { | ||
noCache?: boolean; | ||
allowedOmittedExtensions?: string[]; | ||
} | ||
@@ -8,0 +9,0 @@ interface ServeFileOptions { |
@@ -17,2 +17,9 @@ import { createHash } from 'node:crypto'; | ||
const skipCache = options?.noCache || req.headers['refresh-file'] == 'true'; | ||
if (options?.allowedOmittedExtensions) { | ||
for (const extension of options.allowedOmittedExtensions) { | ||
if (existsSync(assetPath + extension)) { | ||
return sendFile(req, res, { assetPath: assetPath + extension, skipCache }); | ||
} | ||
} | ||
} | ||
if (!existsSync(assetPath) || (await stat(assetPath)).isDirectory()) { | ||
@@ -40,3 +47,3 @@ return 'next'; | ||
const skipCache = options?.noCache || req.headers['refresh-file'] == 'true'; | ||
await sendFile(req, res, { assetPath: filePath, skipCache }); | ||
return sendFile(req, res, { assetPath: filePath, skipCache }); | ||
}; | ||
@@ -43,0 +50,0 @@ } |
@@ -1,6 +0,1 @@ | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import { IncomingMessage } from 'node:http'; | ||
@@ -7,0 +2,0 @@ import { Http2ServerRequest, IncomingHttpHeaders } from 'node:http2'; |
@@ -1,5 +0,1 @@ | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import { ServerResponse } from 'node:http'; | ||
@@ -6,0 +2,0 @@ import { Http2ServerResponse } from 'node:http2'; |
import { randomUUID } from 'node:crypto'; | ||
import { constants } from 'node:http2'; | ||
import { Readable, Writable } from 'node:stream'; | ||
import { finished } from 'node:stream/promises'; | ||
import { streamFinished } from './utilities/streams.js'; | ||
export class FluvialResponse extends Writable { | ||
@@ -222,3 +222,3 @@ get httpVersion() { | ||
this.end(); | ||
await finished(this.rawResponse); | ||
await streamFinished(this.rawResponse); | ||
return this; | ||
@@ -225,0 +225,0 @@ } |
@@ -82,12 +82,12 @@ import { type PathString, type PathMatcher } from './path-matching.js'; | ||
readonly component: string; | ||
get(this: __InternalRouter, path: PathMatcher, ...handlers: RequestHandler[]): Fluvial.Router; | ||
post(this: __InternalRouter, path: PathMatcher, ...handlers: RequestHandler[]): Fluvial.Router; | ||
put(this: __InternalRouter, path: PathMatcher, ...handlers: RequestHandler[]): Fluvial.Router; | ||
patch(this: __InternalRouter, path: PathMatcher, ...handlers: RequestHandler[]): Fluvial.Router; | ||
delete(this: __InternalRouter, path: PathMatcher, ...handlers: RequestHandler[]): Fluvial.Router; | ||
options(this: __InternalRouter, path: PathMatcher, ...handlers: RequestHandler[]): Fluvial.Router; | ||
head(this: __InternalRouter, path: PathMatcher, ...handlers: RequestHandler[]): Fluvial.Router; | ||
all(this: __InternalRouter, path: PathMatcher, ...handlers: RequestHandler[]): Fluvial.Router; | ||
route(this: __InternalRouter, path: PathMatcher): Fluvial.Route; | ||
use(this: __InternalRouter, pathOrHandler: PathMatcher | RequestHandler | Router, ...handlers: (RequestHandler | Router)[]): Fluvial.Router; | ||
get(this: __InternalRouter, path: PathMatcher, ...handlers: RequestHandler[]): Router; | ||
post(this: __InternalRouter, path: PathMatcher, ...handlers: RequestHandler[]): Router; | ||
put(this: __InternalRouter, path: PathMatcher, ...handlers: RequestHandler[]): Router; | ||
patch(this: __InternalRouter, path: PathMatcher, ...handlers: RequestHandler[]): Router; | ||
delete(this: __InternalRouter, path: PathMatcher, ...handlers: RequestHandler[]): Router; | ||
options(this: __InternalRouter, path: PathMatcher, ...handlers: RequestHandler[]): Router; | ||
head(this: __InternalRouter, path: PathMatcher, ...handlers: RequestHandler[]): Router; | ||
all(this: __InternalRouter, path: PathMatcher, ...handlers: RequestHandler[]): Router; | ||
route(this: __InternalRouter, path: PathMatcher): Route; | ||
use(this: __InternalRouter, pathOrHandler: PathMatcher | RequestHandler | Router, ...handlers: (RequestHandler | Router)[]): Router; | ||
catch(this: __InternalRouter, pathOrHandler: PathMatcher | ErrorHandler, ...handlers: ErrorHandler[]): void; | ||
@@ -97,4 +97,4 @@ /** | ||
*/ | ||
handleRequest(this: __InternalRouter, path: PathString, matchedPath: PathString, req: Request, res: Response, err?: unknown): Promise<void | 'next'>; | ||
__getMatchingRoute: (state: __RouterState) => Generator<__InternalRoute>; | ||
handleRequest(this: __InternalRouter, path: PathString, matchedPath: PathString, req: Request, res: Response, err?: unknown): Promise<void | "next">; | ||
__getMatchingRoute: __InternalRouter["__getMatchingRoute"]; | ||
__addRoute(this: __InternalRouter, method: HandlerHttpMethods | null, path: PathMatcher, ...handlers: (RequestHandler | ErrorHandler | Router)[]): Fluvial.__InternalRoute; | ||
@@ -101,0 +101,0 @@ }; |
{ | ||
"name": "fluvial", | ||
"version": "0.4.7", | ||
"version": "0.5.0", | ||
"description": "Fluvial: A light http/2 server framework, similar to Express", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"files": [ | ||
@@ -31,21 +32,17 @@ "dist/**/*", | ||
"devDependencies": { | ||
"@types/mime": "^3.0.1", | ||
"@types/node": "^20.4.1", | ||
"@vitest/coverage-c8": "^0.28.1", | ||
"pnpm": "^7.26.0", | ||
"rimraf": "^4.1.2", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^5.1.6", | ||
"vite": "^4.0.4", | ||
"vitest": "^0.28.1" | ||
"@types/node": "^22.4.1", | ||
"pnpm": "^9.7.1", | ||
"ts-node": "^10.9.2", | ||
"typescript": "^5.5.4" | ||
}, | ||
"dependencies": { | ||
"mime": "^3.0.0" | ||
"mime": "^4.0.4" | ||
}, | ||
"scripts": { | ||
"compile": "tsc -b", | ||
"test": "vitest", | ||
"test:coverage": "pnpm test --coverage", | ||
"prepublish": "pnpm test run && pnpm compile" | ||
"ex": "pnpm tsx", | ||
"compile": "tsc --project tsconfig.src.json", | ||
"test": "pnpm ex --tsconfig=tsconfig.test.json --test src/**/*.test.ts", | ||
"test:coverage": "pnpm ex --tsconfig=tsconfig.test.json --test --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=dist/lcov.info --test-reporter=tap --test-reporter-destination=dist/tap.info src/**/*.test.ts", | ||
"prepublish": "pnpm test && pnpm compile" | ||
} | ||
} |
@@ -0,0 +0,0 @@ # Fluvial |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
215320
4
53
1539
+ Addedmime@4.0.4(transitive)
- Removedmime@3.0.0(transitive)
Updatedmime@^4.0.4