remove flash server
This commit is contained in:
parent
3feb8d3b6b
commit
ca892eed6a
18
server.tsx
18
server.tsx
@ -2,13 +2,21 @@ import * as ESBuild from 'https://deno.land/x/esbuild@v0.17.4/mod.js';
|
||||
import * as MIME from "https://deno.land/std@0.180.0/media_types/mod.ts";
|
||||
import { debounce } from "https://deno.land/std@0.151.0/async/debounce.ts";
|
||||
import { parse as JSONC} from "https://deno.land/std@0.185.0/jsonc/mod.ts";
|
||||
import { toFileUrl } from "https://deno.land/std@0.185.0/path/mod.ts";
|
||||
import * as HTTP from "https://deno.land/std@0.185.0/http/server.ts"
|
||||
import SSR from "https://esm.sh/v113/preact-render-to-string@6.0.2";
|
||||
import Prepass from "https://esm.sh/preact-ssr-prepass@1.2.0";
|
||||
import * as Twind from "https://esm.sh/@twind/core@1.1.3";
|
||||
import React from "react";
|
||||
import * as Iso from "@eno/iso";
|
||||
|
||||
/**
|
||||
* things you cant do on deno deploy:
|
||||
* imports inside deno.json
|
||||
* dynamic imports
|
||||
* Deno.mainModule
|
||||
* Deno.serve
|
||||
*/
|
||||
|
||||
/**
|
||||
* Setup a transpiler.
|
||||
* @param inDevMode When true, starts a file-watcher
|
||||
@ -65,7 +73,7 @@ function Transpiler(inDevMode:boolean)
|
||||
|
||||
const Sockets:Set<WebSocket> = new Set();
|
||||
const SocketsBroadcast =(inData:string)=>{ for (const socket of Sockets){ socket.send(inData); } }
|
||||
const SocketsHandler = inDevMode ? (_req:Request)=>
|
||||
const SocketsHandler = inDevMode ? (_req:Request):false|Response=>
|
||||
{
|
||||
if(_req.headers.get("upgrade") == "websocket")
|
||||
{
|
||||
@ -86,7 +94,7 @@ function Transpiler(inDevMode:boolean)
|
||||
return false;
|
||||
}
|
||||
:
|
||||
()=>false;
|
||||
():false=>false;
|
||||
|
||||
const watcher =async()=>
|
||||
{
|
||||
@ -272,7 +280,7 @@ async function Server(App:React.FunctionComponent, TwindInst:Twind.Twind)
|
||||
}
|
||||
else if(App && TwindInst)
|
||||
{
|
||||
Deno.serve({ port: Deno.env.get("port")||3000 }, async(_req:Request) =>
|
||||
HTTP.serve(async(_req:Request) =>
|
||||
{
|
||||
const url:URL = new URL(_req.url);
|
||||
const pathParts = url.pathname.substring(1, url.pathname.endsWith("/") ? url.pathname.length-1 : url.pathname.length).split("/");
|
||||
@ -393,6 +401,6 @@ async function Server(App:React.FunctionComponent, TwindInst:Twind.Twind)
|
||||
console.log(error);
|
||||
return new Response(error, {status:404});
|
||||
}
|
||||
});
|
||||
}, { port: parseInt(Deno.env.get("port")||"3000" )});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user