fix: remove debugging for path issues
fix: resolve handlers via an index
This commit is contained in:
parent
3fc77f009d
commit
5d25afc329
2 changed files with 3 additions and 9 deletions
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "@andyburke/serverus",
|
"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.",
|
"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.0.10",
|
"version": "0.0.11",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./serverus.ts",
|
".": "./serverus.ts",
|
||||||
|
|
10
server.ts
10
server.ts
|
@ -7,10 +7,7 @@ import * as colors from '@std/fmt/colors';
|
||||||
import * as path from '@std/path';
|
import * as path from '@std/path';
|
||||||
|
|
||||||
const DEFAULT_HANDLER_DIRECTORIES = [import.meta.resolve('./handlers')];
|
const DEFAULT_HANDLER_DIRECTORIES = [import.meta.resolve('./handlers')];
|
||||||
console.dir({
|
|
||||||
meta: import.meta,
|
|
||||||
DEFAULT_HANDLER_DIRECTORIES
|
|
||||||
});
|
|
||||||
/** A `HANDLER` must take a `Request` and return a `Response` if it can handle it. */
|
/** A `HANDLER` must take a `Request` and return a `Response` if it can handle it. */
|
||||||
type HANDLER = (request: Request) => Promise<Response | null | undefined> | Response | null | undefined;
|
type HANDLER = (request: Request) => Promise<Response | null | undefined> | Response | null | undefined;
|
||||||
|
|
||||||
|
@ -114,10 +111,7 @@ export class SERVER {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const handlers_index = await import(index_file);
|
const handlers_index = await import(index_file);
|
||||||
console.dir({
|
|
||||||
index_file,
|
|
||||||
handlers_index
|
|
||||||
});
|
|
||||||
for (const handler_name of Object.keys(handlers_index.default)) {
|
for (const handler_name of Object.keys(handlers_index.default)) {
|
||||||
const handler_module: HANDLER_MODULE = handlers_index.default[handler_name];
|
const handler_module: HANDLER_MODULE = handlers_index.default[handler_name];
|
||||||
if (typeof handler_module?.default !== 'function') {
|
if (typeof handler_module?.default !== 'function') {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue