74 lines
No EOL
1.5 KiB
TypeScript
74 lines
No EOL
1.5 KiB
TypeScript
import { JSONPreset } from "lowdb/node"
|
|
import {UPDATE_INTERVAL} from "./consts.ts";
|
|
|
|
const defaultData: Database = {
|
|
metadata: {
|
|
title: "Default Status Page"
|
|
},
|
|
statuses: {
|
|
defaultData: {
|
|
displayName: "Default Data",
|
|
color: "#c64600",
|
|
description: "This status is part of the default schema"
|
|
}
|
|
},
|
|
services: {
|
|
example: {
|
|
displayName: "Example",
|
|
description: "This service is an example",
|
|
status: "defaultData"
|
|
}
|
|
},
|
|
contact: [{
|
|
name: "Example maintainer",
|
|
links: [{
|
|
name: "Example contact",
|
|
href: "mailto:example@example.com"
|
|
}],
|
|
additionalInfo: "This is an example contact info"
|
|
}]
|
|
}
|
|
export const database = await JSONPreset<Database>("database/database.json", defaultData)
|
|
|
|
setInterval(() => database.read(), UPDATE_INTERVAL)
|
|
|
|
export type Database = {
|
|
metadata: {
|
|
title: string,
|
|
},
|
|
statuses: {[key: string]: {
|
|
displayName: string,
|
|
color: string,
|
|
description: string,
|
|
}},
|
|
notices?: {
|
|
title: string,
|
|
description: string,
|
|
expectedStatus?: keyof Database["statuses"],
|
|
affectedServices?: (keyof Database["services"])[],
|
|
expectedDuration?: {
|
|
from: number,
|
|
to: number,
|
|
},
|
|
}[],
|
|
services: {[key: string]: {
|
|
displayName: string,
|
|
description: string,
|
|
status: keyof Database["statuses"],
|
|
link?: string,
|
|
updates?: {
|
|
time: number,
|
|
description: string,
|
|
author?: string,
|
|
}[],
|
|
}},
|
|
contact: {
|
|
name: string,
|
|
links: {
|
|
name: string,
|
|
href: string,
|
|
}[],
|
|
gravatarEmail?: string,
|
|
additionalInfo?: string,
|
|
}[],
|
|
} |