Skip to content

Commit b60fcca

Browse files
authored
feat: support Deno 2 (#416)
* Update ci.yml * chore: some minor changes to make deno2 happy * apply deno fmt
1 parent 1ade65f commit b60fcca

File tree

7 files changed

+241
-202
lines changed

7 files changed

+241
-202
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Install Deno
2424
uses: denolib/setup-deno@master
2525
with:
26-
deno-version: 1.x.x
26+
deno-version: 2.x.x
2727

2828
- name: Log versions
2929
run: |

.github/workflows/jsr.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ jobs:
3333
3434
- name: Publish to JSR
3535
run: |
36-
deno publish
36+
deno publish

deps.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ export {
1616
Timestamp,
1717
UUID,
1818
} from "jsr:@lucsoft/web-bson@^0.3.1";
19-
export { crypto as stdCrypto } from "jsr:@std/crypto@^0.224.0/crypto";
20-
export { decodeBase64, encodeBase64 } from "jsr:@std/encoding@^0.224.0/base64";
21-
export { encodeHex } from "jsr:@std/encoding@^0.224.0/hex";
19+
export { crypto as stdCrypto } from "jsr:@std/crypto@^1.0.3/crypto";
20+
export { decodeBase64, encodeBase64 } from "jsr:@std/encoding@^1.0.5/base64";
21+
export { encodeHex } from "jsr:@std/encoding@^1.0.5/hex";

src/client.ts

+13-11
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ export class MongoClient {
4141
*
4242
* @param options Connection options or a MongoDB URI
4343
*/
44-
async connect(
45-
options: ConnectOptions | string,
46-
): Promise<Database> {
44+
async connect(options: ConnectOptions | string): Promise<Database> {
4745
try {
4846
const parsedOptions = typeof options === "string"
4947
? await parse(options)
@@ -59,8 +57,10 @@ export class MongoClient {
5957
this.#buildInfo = await this.runCommand(this.#defaultDbName, {
6058
buildInfo: 1,
6159
});
62-
} catch (e) {
63-
throw new MongoDriverError(`Connection failed: ${e.message || e}`);
60+
} catch (e: unknown) {
61+
throw new MongoDriverError(
62+
`Connection failed: ${e instanceof Error ? e.message : "unknown"}`,
63+
);
6464
}
6565
return this.database((options as ConnectOptions).db);
6666
}
@@ -71,12 +71,14 @@ export class MongoClient {
7171
* @param options Options to pass to the `listDatabases` command
7272
* @returns A list of databases including their name, size on disk, and whether they are empty
7373
*/
74-
async listDatabases(options: {
75-
filter?: Document;
76-
nameOnly?: boolean;
77-
authorizedCollections?: boolean;
78-
comment?: Document;
79-
} = {}): Promise<ListDatabaseInfo[]> {
74+
async listDatabases(
75+
options: {
76+
filter?: Document;
77+
nameOnly?: boolean;
78+
authorizedCollections?: boolean;
79+
comment?: Document;
80+
} = {},
81+
): Promise<ListDatabaseInfo[]> {
8082
const { databases } = await this.getCluster().protocol.commandSingle(
8183
"admin",
8284
{

src/error.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export class MongoRuntimeError extends MongoDriverError {
7373
super(message);
7474
}
7575

76-
get name(): string {
76+
override get name(): string {
7777
return "MongoRuntimeError";
7878
}
7979
}

0 commit comments

Comments
 (0)