diff --git a/vscode/settings.json b/.vscode/settings.json similarity index 100% rename from vscode/settings.json rename to .vscode/settings.json diff --git a/driver.ts b/driver.ts new file mode 100644 index 0000000..41f8753 --- /dev/null +++ b/driver.ts @@ -0,0 +1,16 @@ +import db from 'https://8000-gitpodsampl-templatetyp-gxqkxjx6j7m.ws-us93.gitpod.io/neo4j/neo4j-javascript-driver/5.0/packages/neo4j-driver-deno/lib/mod.ts'; +import type * as neo4j from 'https://8000-gitpodsampl-templatetyp-gxqkxjx6j7m.ws-us93.gitpod.io/neo4j/neo4j-javascript-driver/5.0/packages/neo4j-driver-deno/lib/mod.ts'; + +/** + * Create a new driver instance to connect to Neo4j + * @type {neo4j.Driver} + * @see https://neo4j.com/docs/api/javascript-driver/current/class/src/driver.js~Driver.html + * @see https://neo4j.com/docs/api/javascript-driver/current/global.html#Config + */ +const driver: neo4j.Driver = db.driver( + // ^ Does type inferencing work? + "", + db.auth.basic( "", "" ) +); + +export default driver; \ No newline at end of file diff --git a/test.ts b/test.ts new file mode 100644 index 0000000..d9cf1b4 --- /dev/null +++ b/test.ts @@ -0,0 +1,6 @@ +import { hasTransferables } from "https://8000-gitpodsampl-templatetyp-gxqkxjx6j7m.ws-us93.gitpod.io/okikio/transferables/main/src/index.ts"; + +console.log({ + hasTransferables + // ^ Does type inferencing work? +}) \ No newline at end of file diff --git a/webserver.ts b/webserver.ts index 32dbd03..6239096 100644 --- a/webserver.ts +++ b/webserver.ts @@ -1,29 +1,28 @@ -// Start listening on port 8080 of localhost. -const server = Deno.listen({ port: 8080 }); -console.log(`HTTP webserver running. Access it at: http://localhost:8080/`); +import { serve } from "https://deno.land/std@0.182.0/http/server.ts"; -// Connections to the server will be yielded up as an async iterable. -for await (const conn of server) { - // In order to not be blocking, we need to handle each connection individually - // in its own async function. - (async () => { - // This "upgrades" a network connection into an HTTP connection. - const httpConn = Deno.serveHttp(conn); - // Each request sent over the HTTP connection will be yielded as an async - // iterator from the HTTP connection. - for await (const requestEvent of httpConn) { - // The native HTTP server uses the web standard `Request` and `Response` - // objects. - const body = `Your user-agent is:\n\n${requestEvent.request.headers.get( - "user-agent", - ) ?? "Unknown"}`; - // The requestEvent's `.respondWith()` method is how we send the response - // back to the client. - requestEvent.respondWith( - new Response(body, { - status: 200, - }), - ); - } - })(); -} \ No newline at end of file +const DENO_TYPE_PATH = "/@deno-types" + +serve(async (req: Request) => { + let { pathname } = new URL(req.url); + + const url = new URL(pathname.replace(DENO_TYPE_PATH, ""), `https://raw.githubusercontent.com`); + const res = await fetch(url); + + const headers = Object.fromEntries([...res.headers]); + const typescriptTypes = new URL(DENO_TYPE_PATH + url.pathname, "https://8000-gitpodsampl-templatetyp-gxqkxjx6j7m.ws-us93.gitpod.io"); + const finalHeaders = { + ...headers, + ...Object.fromEntries([ + ["content-type", "text/typescript"], // pathname.startsWith(DENO_TYPE_PATH) ? "application/typescript" : + ['accept-ranges', 'bytes'], + ['access-control-allow-origin', '*'], + ['cache-control', 'max-age=30, public'], + ...(!pathname.startsWith(DENO_TYPE_PATH) ? [['x-typescript-types', typescriptTypes.toString()]] : []) + ]) + }; + + return new Response(await res.arrayBuffer(), { + headers: finalHeaders, + status: 200, + }); +}); \ No newline at end of file