Added GET /remote/servertime API
This commit is contained in:
parent
799ce1b371
commit
5838f61db6
|
@ -53,4 +53,11 @@ class Remote
|
||||||
$this->logger->info('Record ' . $record . ' was changed via the changepw api.');
|
$this->logger->info('Record ' . $record . ' was changed via the changepw api.');
|
||||||
return $res->withStatus(204);
|
return $res->withStatus(204);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function servertime(Request $req, Response $res, array $args)
|
||||||
|
{
|
||||||
|
return $res->withJson([
|
||||||
|
'time' => time()
|
||||||
|
], 200);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ $app->group('/v1', function () {
|
||||||
$this->post('/sessions', '\Controllers\Sessions:post');
|
$this->post('/sessions', '\Controllers\Sessions:post');
|
||||||
|
|
||||||
$this->get('/remote/ip', '\Controllers\Remote:ip');
|
$this->get('/remote/ip', '\Controllers\Remote:ip');
|
||||||
|
$this->get('/remote/servertime', '\Controllers\Remote:servertime');
|
||||||
$this->get('/remote/updatepw', '\Controllers\Remote:updatePassword');
|
$this->get('/remote/updatepw', '\Controllers\Remote:updatePassword');
|
||||||
|
|
||||||
$this->group('', function () {
|
$this->group('', function () {
|
||||||
|
|
15
backend/test/tests/remote-servertime.js
Normal file
15
backend/test/tests/remote-servertime.js
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
const test = require('../testlib');
|
||||||
|
|
||||||
|
test.run(async function () {
|
||||||
|
await test('admin', async function (assert, req) {
|
||||||
|
var res = await req({
|
||||||
|
url: '/remote/servertime',
|
||||||
|
method: 'get'
|
||||||
|
});
|
||||||
|
|
||||||
|
const curTime = Math.floor(new Date() / 1000);
|
||||||
|
|
||||||
|
assert.equal(res.status, 200);
|
||||||
|
assert.true(Math.abs(curTime - res.data.time) < 2, 'Returned time is not within tolerance!');
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in a new issue