From 5dd743ec65fe3a48903ec71e9df577056290e284 Mon Sep 17 00:00:00 2001 From: Alan Plum Date: Mon, 9 Oct 2023 18:22:07 +0200 Subject: [PATCH] Implement GET _admin/time --- CHANGELOG.md | 2 ++ src/database.ts | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d20d95c..1eaf0743 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,8 @@ This driver uses semantic versioning: - Added `db.shutdown` to initiate a clean shutdown of the server +- Added `db.time` method to retrieve the server's system time + ## [8.4.1] - 2023-09-15 ### Fixed diff --git a/src/database.ts b/src/database.ts index 999bea95..9b3c4e2f 100644 --- a/src/database.ts +++ b/src/database.ts @@ -1866,6 +1866,19 @@ export class Database { }); } + /** + * Retrives the server's current system time in milliseconds with microsecond + * precision. + */ + time(): Promise { + return this.request( + { + path: "/_admin/time", + }, + (res) => res.body.time * 1000 + ); + } + /** * Returns a new {@link route.Route} instance for the given path (relative to the * database) that can be used to perform arbitrary HTTP requests. @@ -2081,6 +2094,7 @@ export class Database { setResponseQueueTimeSamples(responseQueueTimeSamples: number) { this._connection.setResponseQueueTimeSamples(responseQueueTimeSamples); } + //#endregion //#region auth