oneuptime/CommonServer/Services/ApiKeyService.ts
Simon Larsen d9fb1b67da
fix lint
2022-08-16 22:48:03 +01:00

21 lines
685 B
TypeScript

import PostgresDatabase from '../Infrastructure/PostgresDatabase';
import Model from 'Model/Models/ApiKey';
import DatabaseService, { OnCreate } from './DatabaseService';
import CreateBy from '../Types/Database/CreateBy';
import ObjectID from 'Common/Types/ObjectID';
export class Service extends DatabaseService<Model> {
public constructor(postgresDatabase?: PostgresDatabase) {
super(Model, postgresDatabase);
}
protected override async onBeforeCreate(
createBy: CreateBy<Model>
): Promise<OnCreate<Model>> {
createBy.data.apiKey = ObjectID.generate();
return { createBy, carryForward: null };
}
}
export default new Service();