Skip to content

Commit 63bdbe4

Browse files
fix shit hopefully
1 parent 3af237f commit 63bdbe4

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ COPY . .
2525
EXPOSE 8000
2626

2727
# Command to run the application.
28-
CMD ["deno", "run", "start"]
28+
CMD ["deno", "task", "start"]

src/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,27 @@ interface TokenDoc {
1313

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

1819
const db = client.database("ollama");
20+
const collection = db.collection<TokenDoc>("tokens");
1921

2022
function removeTrailingSlash(str: string): string {
2123
// Check if the string ends with a slash and remove it if present
2224
return str.endsWith("/") ? str.slice(0, -1) : str;
2325
}
2426

25-
const ollama_url = removeTrailingSlash(Deno.env.get("OLLAMA_URL")!);
27+
const ollama_url_unedited = Deno.env.get("OLLAMA_URL")!;
28+
const ollama_url = removeTrailingSlash(ollama_url_unedited);
2629

2730
app.use(logger());
2831

2932
app.use(
3033
"*",
3134
bearerAuth({
3235
verifyToken: async (token, _c) => {
33-
const tokenDoc = await db.collection<TokenDoc>("tokens").findOne({
36+
const tokenDoc = await collection.findOne({
3437
token,
3538
});
3639

0 commit comments

Comments
 (0)