fix: try to better handle directories and loading handlers both locally
and remotely
This commit is contained in:
parent
5d25afc329
commit
5ee654f280
3 changed files with 10 additions and 8 deletions
|
@ -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.0.11",
|
||||
"version": "0.0.12",
|
||||
"license": "MIT",
|
||||
"exports": {
|
||||
".": "./serverus.ts",
|
||||
|
|
|
@ -102,9 +102,12 @@ export class SERVER {
|
|||
this.controller = new AbortController();
|
||||
const { signal } = this.controller;
|
||||
|
||||
const HANDLERS_DIRECTORIES: string[] =
|
||||
Deno.env.get('SERVERUS_HANDLERS')?.split(/[;:]/g)?.filter((dir) => dir.length > 0)?.map((dir) => path.resolve(dir)) ??
|
||||
DEFAULT_HANDLER_DIRECTORIES;
|
||||
const HANDLERS_DIRECTORIES: string[] = Deno.env.get('SERVERUS_HANDLERS')
|
||||
?.split(/[;]/g)
|
||||
?.filter((dir) => dir.length > 0)
|
||||
?.map((dir) => {
|
||||
return dir.includes('://') ? dir : path.resolve(dir);
|
||||
}) ?? DEFAULT_HANDLER_DIRECTORIES;
|
||||
|
||||
for (const handler_directory of HANDLERS_DIRECTORIES) {
|
||||
const index_file = path.join(handler_directory, 'index.ts');
|
||||
|
|
|
@ -16,13 +16,12 @@ Deno.test({
|
|||
const old_handlers: string | undefined = Deno.env.get('SERVERUS_HANDLERS');
|
||||
|
||||
try {
|
||||
Deno.chdir('./tests/www');
|
||||
Deno.env.set(
|
||||
'SERVERUS_HANDLERS',
|
||||
`${path.join(path.dirname(path.resolve(path.fromFileUrl(import.meta.url))), 'handlers')}${
|
||||
old_handlers ? (';' + old_handlers) : ''
|
||||
}`
|
||||
`${import.meta.resolve('./handlers')}${old_handlers ? (';' + old_handlers) : ''}`
|
||||
);
|
||||
|
||||
Deno.chdir('./tests/www');
|
||||
test_server_info = await get_ephemeral_listen_server();
|
||||
|
||||
const response = await fetch(`http://${test_server_info.hostname}:${test_server_info.port}/echo/hello_world.foo`, {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue