From 648e3e3bbf7c1f0e8fc0bd6b7cdddd28837ab082 Mon Sep 17 00:00:00 2001 From: Tuan Dang Date: Sun, 18 Dec 2022 17:19:09 -0500 Subject: [PATCH] Continue developing log schema --- backend/src/models/log.ts | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/backend/src/models/log.ts b/backend/src/models/log.ts index 7078ae52f1..e3716ab847 100644 --- a/backend/src/models/log.ts +++ b/backend/src/models/log.ts @@ -2,11 +2,11 @@ import { Schema, model, Types } from 'mongoose'; export interface ILog { _id: Types.ObjectId; - user: Types.ObjectId; + user?: Types.ObjectId; workspace: Types.ObjectId; event: string; source: string; - ipAddress: string; + ipAddress?: string; } // TODO: need a way to store payload info for each @@ -14,6 +14,8 @@ export interface ILog { // which secret is being ref etc. +// user logged in + const logSchema = new Schema( { user: { @@ -24,17 +26,25 @@ const logSchema = new Schema( type: Schema.Types.ObjectId, ref: 'Workspace' }, - event: { + event: { // push, pull type: String, required: true }, - source: { // should this just be a payload attr? + payload: { // should this just be a payload attr? + numberOfSecrets: { + type: Number + }, + environment: { + type: String + } + }, + channel: { type: String, + enum: ['web', 'cli', 'auto'], required: true }, ipAddress: { // store in bytes? - type: String, - required: true + type: String } }, { timestamps: true