diff --git a/deno.json b/deno.json index 14d4ab1..e8cabfd 100644 --- a/deno.json +++ b/deno.json @@ -1,7 +1,7 @@ { "name": "@andyburke/serverus", "description": "A flexible HTTP server for mixed content. Throw static files, markdown, Typescript and (hopefully, eventually) more into a directory and serverus can serve it up a bit more like old-school CGI.", - "version": "0.11.3", + "version": "0.11.4", "license": "MIT", "exports": { ".": "./serverus.ts", diff --git a/handlers/static.ts b/handlers/static.ts index faa6a14..7104557 100644 --- a/handlers/static.ts +++ b/handlers/static.ts @@ -6,7 +6,7 @@ import * as fs from '@std/fs'; import * as path from '@std/path'; import * as media_types from '@std/media-types'; -import { SERVER } from '../server.ts'; +import { PRECHECK, SERVER } from '../server.ts'; import { getCookies } from '@std/http/cookie'; let PUT_PATHS_ALLOWED: string[] | undefined = undefined; @@ -18,7 +18,6 @@ export type HANDLER_METHOD = ( normalized_path: string, server: SERVER ) => Promise | Response | undefined; -export type PRECHECK = (request: Request, meta: Record) => Promise | Response | undefined; export const PRECHECKS: Partial> = {}; export const HANDLERS: Partial> = { HEAD: async (_request: Request, normalized_path: string, _server: SERVER): Promise => { diff --git a/handlers/typescript.ts b/handlers/typescript.ts index 009a401..25c4a0d 100644 --- a/handlers/typescript.ts +++ b/handlers/typescript.ts @@ -8,12 +8,7 @@ import { walk } from '@std/fs'; import { delay } from '@std/async/delay'; import * as path from '@std/path'; import { getCookies } from '@std/http/cookie'; - -/** A `PRECHECK` must take a `Request` and `meta` data and return a `Response` IF THERE IS A PROBLEM. */ -export type PRECHECK = ( - request: Request, - meta: Record -) => undefined | Response | Promise; +import { PRECHECK } from '@andyburke/serverus/server'; /** A `PRECHECK_TABLE` maps from HTTP methods to an array of `PRECHECK`s to be run. */ export type PRECHECKS_TABLE = Record<'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH', PRECHECK[]>; diff --git a/server.ts b/server.ts index 353c4be..1e591ec 100644 --- a/server.ts +++ b/server.ts @@ -56,6 +56,12 @@ export const DEFAULT_SERVER_OPTIONS: SERVER_OPTIONS = { logging: true }; +/** A `PRECHECK` must take a `Request` and `meta` data and return a `Response` IF THERE IS A PROBLEM. */ +export type PRECHECK = ( + request: Request, + meta: Record +) => undefined | Response | Promise; + /** * @method LOG_REQUEST Default request logger. *