mirror of
https://github.com/bitwarden/directory-connector
synced 2025-12-05 23:53:21 +00:00
* Split jslib * Change hook to preinstall * Install gyp (ci) * Fix rebuild command * Review comments * Add tsconfig-paths-plugin to webpack.cli. * Bump jslib * Install old version of prebuild-install to bypass bug in pkg
30 lines
1.2 KiB
TypeScript
30 lines
1.2 KiB
TypeScript
import * as program from 'commander';
|
|
|
|
import { ConfigurationService } from '../services/configuration.service';
|
|
|
|
import { Response } from 'jslib-node/cli/models/response';
|
|
import { StringResponse } from 'jslib-node/cli/models/response/stringResponse';
|
|
|
|
export class LastSyncCommand {
|
|
constructor(private configurationService: ConfigurationService) { }
|
|
|
|
async run(object: string): Promise<Response> {
|
|
try {
|
|
switch (object.toLowerCase()) {
|
|
case 'groups':
|
|
const groupsDate = await this.configurationService.getLastGroupSyncDate();
|
|
const groupsRes = new StringResponse(groupsDate == null ? null : groupsDate.toISOString());
|
|
return Response.success(groupsRes);
|
|
case 'users':
|
|
const usersDate = await this.configurationService.getLastUserSyncDate();
|
|
const usersRes = new StringResponse(usersDate == null ? null : usersDate.toISOString());
|
|
return Response.success(usersRes);
|
|
default:
|
|
return Response.badRequest('Unknown object.');
|
|
}
|
|
} catch (e) {
|
|
return Response.error(e);
|
|
}
|
|
}
|
|
}
|