21 lines
750 B
TypeScript
21 lines
750 B
TypeScript
import { workSerializer } from '../../../shared/services/serialization/serializers/work';
|
|
import { Database, getConnection } from '../../core/database';
|
|
import { Work } from '../../entities/library/work';
|
|
import { answer } from '../ipc/annotations/answer';
|
|
|
|
export class EntityApiIpcController implements IpcController {
|
|
private constructor() {}
|
|
|
|
@answer(IpcChannel.ENTITY_GET_WORK)
|
|
public async getWork({ id }: { id: number }): Promise<WorkSerializedInterface> {
|
|
const connection = await getConnection(Database.LIBRARY);
|
|
const work = await connection.manager.getRepository(Work).findOneOrFail(id);
|
|
|
|
return workSerializer.serialize(work);
|
|
}
|
|
|
|
public get(): EntityApiIpcController {
|
|
return new EntityApiIpcController();
|
|
}
|
|
}
|