Skip to content

Instantly share code, notes, and snippets.

@ashutoshpw
Created September 29, 2021 08:29
Show Gist options
  • Save ashutoshpw/f38f4812a1c41010cb959e007fb3c51e to your computer and use it in GitHub Desktop.
Save ashutoshpw/f38f4812a1c41010cb959e007fb3c51e to your computer and use it in GitHub Desktop.
deno-test.js
import { MongoClient } from "https://deno.land/x/[email protected]/mod.ts";
const URI = "mongodb://127.0.0.1:27017";
addEventListener("fetch", async (event) => {
const client = new MongoClient();
try {
await client.connect(URI);
console.log("Database successfully connected");
} catch (err) {
console.log(err);
}
event.respondWith(
new Response("Hello world", {
status: 200,
headers: { "content-type": "text/plain" },
}),
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment