fix(striker-ui-api): generate db timestamp from date

main
Tsu-ba-me 2 years ago
parent b0e7859d2d
commit 410a5de48d
  1. 17
      striker-ui-api/src/lib/accessModule.ts

@ -3,7 +3,7 @@ import { readFileSync } from 'fs';
import { SERVER_PATHS } from './consts';
import { stderr as sherr, stdout as shout } from './shell';
import { date, stderr as sherr, stdout as shout } from './shell';
const formatQuery = (query: string) => query.replace(/\s+/g, ' ');
@ -129,8 +129,19 @@ const dbQuery = (query: string, options?: SpawnSyncOptions) => {
return execAnvilAccessModule(['--query', query], options);
};
const dbSubRefreshTimestamp = () =>
execModuleSubroutine('refresh_timestamp').stdout;
const dbSubRefreshTimestamp = () => {
let result: string;
try {
result = date('--rfc-3339', 'ns').trim();
} catch (shError) {
throw new Error(
`Failed to get timestamp for database use; CAUSE: ${shError}`,
);
}
return result;
};
const dbWrite = (query: string, options?: SpawnSyncOptions) => {
shout(formatQuery(query));

Loading…
Cancel
Save