Skip to content

Commit 3af237f

Browse files
use jsr instead of npm
1 parent 38cd7cc commit 3af237f

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

deno.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"imports": {
3-
"hono": "npm:hono",
4-
"mongodb": "npm:mongodb"
3+
"@db/mongo": "jsr:@db/mongo@^0.34.0",
4+
"@hono/hono": "jsr:@hono/hono@^4.11.1"
55
},
66
"fmt": {
77
"indentWidth": 4,

src/index.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Hono } from "hono";
2-
import { bearerAuth } from "hono/bearer-auth";
3-
import { logger } from "hono/logger";
4-
import { MongoClient } from "mongodb";
1+
import { Hono } from "@hono/hono";
2+
import { bearerAuth } from "@hono/hono/bearer-auth";
3+
import { logger } from "@hono/hono/logger";
4+
import { MongoClient } from "@db/mongo";
55

66
const app = new Hono();
77

@@ -12,16 +12,18 @@ interface TokenDoc {
1212
}
1313

1414
// Connect to MongoDB
15-
const client = new MongoClient(Deno.env.get("MONGODB_URI")!);
16-
client.connect(); // Make sure to connect before using
15+
const client = new MongoClient();
16+
client.connect(Deno.env.get("MONGODB_URI")!); // Make sure to connect before using
1717

18-
const db = client.db("ollama");
18+
const db = client.database("ollama");
1919

2020
function removeTrailingSlash(str: string): string {
2121
// Check if the string ends with a slash and remove it if present
2222
return str.endsWith("/") ? str.slice(0, -1) : str;
2323
}
2424

25+
const ollama_url = removeTrailingSlash(Deno.env.get("OLLAMA_URL")!);
26+
2527
app.use(logger());
2628

2729
app.use(
@@ -40,8 +42,6 @@ app.use(
4042
},
4143
}),
4244
async (c) => {
43-
const ollama_url = removeTrailingSlash(Deno.env.get("OLLAMA_URL")!);
44-
4545
try {
4646
const response = await fetch(`${ollama_url}${c.req.path}`, {
4747
method: c.req.method,

0 commit comments

Comments
 (0)