import { DataSource } from 'typeorm';
import { MetaEntity } from '../../../entities';
import { GetMetaQuery } from '../../types';

export async function handleGetMeta(query: GetMetaQuery, dataSource: DataSource): Promise<string | null> {
  const meta = await dataSource.getRepository(MetaEntity).findOne({
    where: { key: query.payload.key }
  });

  return meta?.value ?? null;
}
