mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-01-16 23:00:51 +00:00
21 lines
666 B
TypeScript
21 lines
666 B
TypeScript
import CreateBy from "../Types/Database/CreateBy";
|
|
import { OnCreate } from "../Types/Database/Hooks";
|
|
import DatabaseService from "./DatabaseService";
|
|
import ObjectID from "../../Types/ObjectID";
|
|
import Model from "../../Models/DatabaseModels/ApiKey";
|
|
import CaptureSpan from "../Utils/Telemetry/CaptureSpan";
|
|
export class Service extends DatabaseService<Model> {
|
|
public constructor() {
|
|
super(Model);
|
|
}
|
|
|
|
@CaptureSpan()
|
|
protected override async onBeforeCreate(
|
|
createBy: CreateBy<Model>,
|
|
): Promise<OnCreate<Model>> {
|
|
createBy.data.apiKey = ObjectID.generate();
|
|
return { createBy, carryForward: null };
|
|
}
|
|
}
|
|
|
|
export default new Service();
|