Files
outline/app/models/ApiKey.ts

39 lines
673 B
TypeScript

import { isPast } from "date-fns";
import { computed, observable } from "mobx";
import Model from "./base/Model";
import Field from "./decorators/Field";
class ApiKey extends Model {
static modelName = "ApiKey";
@Field
@observable
id: string;
/**
* The user chosen name of the API key.
*/
@Field
@observable
name: string;
/**
* An optional datetime that the API key expires.
*/
@Field
@observable
expiresAt?: string;
secret: string;
/**
* Whether the API key has an expiry in the past.
*/
@computed
get isExpired() {
return this.expiresAt ? isPast(new Date(this.expiresAt)) : false;
}
}
export default ApiKey;