DenReg/registry/src/db.ts

32 lines
587 B
TypeScript
Raw Normal View History

2020-07-28 12:39:54 +00:00
import { Datastore } from "./deps.ts";
2020-07-28 13:56:02 +00:00
import { FS } from "./deps.ts";
await FS.ensureDir("./data");
2020-07-28 12:39:54 +00:00
export interface IPackage {
name: string;
2020-08-03 07:38:01 +00:00
owner: string;
description: string;
2020-07-28 12:39:54 +00:00
versions: string[];
2020-07-31 22:15:10 +00:00
deprecated: boolean;
2020-07-28 12:39:54 +00:00
}
export interface IApiKey {
user: string;
key: string;
createdAt: Date;
lastAccess?: Date;
lastIP?: string;
}
const db = {
package: new Datastore<IPackage>({
filename: "data/packages.json",
autoload: true,
}),
api_key: new Datastore<IApiKey>({
filename: "data/api_keys.json",
}),
};
2020-07-28 12:39:54 +00:00
export default db;