mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-27 00:04:37 +08:00
* Migrate some utils to TS * Add argument type * Fix logic * Refactor math functions * Rename function
22 lines
455 B
TypeScript
22 lines
455 B
TypeScript
import db from "../init/db";
|
|
|
|
interface Log {
|
|
timestamp: number;
|
|
uid: string;
|
|
event: string;
|
|
message: string;
|
|
}
|
|
|
|
export default {
|
|
async log(event: string, message: any, uid?: string): Promise<void> {
|
|
const logsCollection = db.collection<Log>("logs");
|
|
|
|
console.log(new Date(), "\t", event, "\t", uid, "\t", message);
|
|
await logsCollection.insertOne({
|
|
timestamp: Date.now(),
|
|
uid,
|
|
event,
|
|
message,
|
|
});
|
|
},
|
|
};
|