Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/helpers/genRouteHandler.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LogFunction, ParamType } from 'dce-reactkit';
import { ParamType, LogFunction } from 'dce-reactkit';
/**
* Generate an express API route handler
* @author Gabe Abrams
Expand Down
20 changes: 16 additions & 4 deletions lib/helpers/genRouteHandler.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/helpers/genRouteHandler.js.map

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions lib/helpers/initServer.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/helpers/initServer.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dce-expresskit",
"version": "4.2.0",
"version": "4.2.1",
"description": "Shared functions, helpers, and tools for Harvard DCE Express-based servers",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
Expand All @@ -25,7 +25,7 @@
"@fortawesome/free-solid-svg-icons": "^6.7.2",
"@fortawesome/react-fontawesome": "^0.2.2",
"bootstrap": "^5.3.3",
"dce-reactkit": "4.0.0-beta-logreviewer.1",
"dce-reactkit": "^4.1.8",
"react": "^19.0.0"
},
"peerDependencies": {
Expand Down
24 changes: 19 additions & 5 deletions src/helpers/genRouteHandler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Import dce-reactkit
import {
getTimeInfoInET,
LogFunction,
Log,
LogType,
LogTypeSpecificInfo,
Expand All @@ -13,13 +12,14 @@ import {
ParamType,
ReactKitErrorCode,
LogSource,
LogFunction,
} from 'dce-reactkit';

// Import caccl
import { getLaunchInfo } from 'caccl/server';

// Import caccl functions
import initExpressKitCollections, { internalGetLogCollection, internalGetSelectAdminCollection } from './initExpressKitCollections';
import { internalGetLogCollection, internalGetSelectAdminCollection } from './initExpressKitCollections';

// Import shared types
import ExpressKitErrorCode from '../types/ExpressKitErrorCode';
Expand Down Expand Up @@ -619,13 +619,27 @@ const genRouteHandler = (
minute,
} = getTimeInfoInET();

// Get user info
let userId = (launchInfo ? launchInfo.userId : -1);
if (logOpts.userId) {
userId = logOpts.userId;
}
let userFirstName = (launchInfo ? launchInfo.userFirstName : 'unknown');
if (logOpts.userFirstName) {
userFirstName = logOpts.userFirstName;
}
let userLastName = (launchInfo ? launchInfo.userLastName : 'unknown');
if (logOpts.userLastName) {
userLastName = logOpts.userLastName;
}

// Main log info
const mainLogInfo: LogMainInfo = {
id: `${launchInfo ? launchInfo.userId : 'unknown'}-${Date.now()}-${Math.floor(Math.random() * 100000)}-${Math.floor(Math.random() * 100000)}`,
userFirstName: (launchInfo ? launchInfo.userFirstName : 'unknown'),
userLastName: (launchInfo ? launchInfo.userLastName : 'unknown'),
userFirstName,
userLastName,
userEmail: (launchInfo ? launchInfo.userEmail : 'unknown'),
userId: (launchInfo ? launchInfo.userId : -1),
userId,
isLearner: (launchInfo && !!launchInfo.isLearner),
isAdmin: (launchInfo && !!launchInfo.isAdmin),
isTTM: (launchInfo && !!launchInfo.isTTM),
Expand Down
11 changes: 11 additions & 0 deletions src/helpers/initServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ const initServer = (
* @param {string} [target] Target of the action (each app determines the list
* of targets) These are usually buttons, panels, elements, etc.
* @param {LogAction} [action] the type of action performed on the target
* @param {object} [overriddenUserInfo] object containing info to override
* @param {number} [opts.userId] overriding Canvas id of the user performing the action
* @param {string} [opts.userFirstName] overriding first name of the user performing the action
* @param {string} [opts.userLastName] overriding last name of the user performing the action
Comment on lines +68 to +70
Copy link

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter documentation refers to 'opts.userId' but the actual parameter is 'overriddenUserInfo.userId'. The documentation should be corrected to match the parameter structure.

Suggested change
* @param {number} [opts.userId] overriding Canvas id of the user performing the action
* @param {string} [opts.userFirstName] overriding first name of the user performing the action
* @param {string} [opts.userLastName] overriding last name of the user performing the action
* @param {number} [overriddenUserInfo.userId] overriding Canvas id of the user performing the action
* @param {string} [overriddenUserInfo.userFirstName] overriding first name of the user performing the action
* @param {string} [overriddenUserInfo.userLastName] overriding last name of the user performing the action

Copilot uses AI. Check for mistakes.
Comment on lines +68 to +70
Copy link

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter documentation refers to 'opts.userFirstName' but the actual parameter is 'overriddenUserInfo.userFirstName'. The documentation should be corrected to match the parameter structure.

Suggested change
* @param {number} [opts.userId] overriding Canvas id of the user performing the action
* @param {string} [opts.userFirstName] overriding first name of the user performing the action
* @param {string} [opts.userLastName] overriding last name of the user performing the action
* @param {number} [overriddenUserInfo.userId] overriding Canvas id of the user performing the action
* @param {string} [overriddenUserInfo.userFirstName] overriding first name of the user performing the action
* @param {string} [overriddenUserInfo.userLastName] overriding last name of the user performing the action

Copilot uses AI. Check for mistakes.
Comment on lines +68 to +70
Copy link

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter documentation refers to 'opts.userLastName' but the actual parameter is 'overriddenUserInfo.userLastName'. The documentation should be corrected to match the parameter structure.

Suggested change
* @param {number} [opts.userId] overriding Canvas id of the user performing the action
* @param {string} [opts.userFirstName] overriding first name of the user performing the action
* @param {string} [opts.userLastName] overriding last name of the user performing the action
* @param {number} [overriddenUserInfo.userId] overriding Canvas id of the user performing the action
* @param {string} [overriddenUserInfo.userFirstName] overriding first name of the user performing the action
* @param {string} [overriddenUserInfo.userLastName] overriding last name of the user performing the action

Copilot uses AI. Check for mistakes.
* @returns {Log}
*/
opts.app.post(
Expand All @@ -80,6 +84,7 @@ const initServer = (
errorStack: ParamType.StringOptional,
target: ParamType.StringOptional,
action: ParamType.StringOptional,
overriddenUserInfo: ParamType.JSONOptional,
},
handler: ({ params, logServerEvent }) => {
// Create log info
Expand All @@ -97,6 +102,9 @@ const initServer = (
code: params.errorCode,
stack: params.errorStack,
},
userId: (params.overriddenUserInfo ? params.overriddenUserInfo.userId : undefined),
userFirstName: (params.overriddenUserInfo ? params.overriddenUserInfo.userFirstName : undefined),
userLastName: (params.overriddenUserInfo ? params.overriddenUserInfo.userLastName : undefined),
}
// Action
: {
Expand All @@ -107,6 +115,9 @@ const initServer = (
metadata: params.metadata,
target: params.target,
action: params.action,
userId: (params.overriddenUserInfo ? params.overriddenUserInfo.userId : undefined),
userFirstName: (params.overriddenUserInfo ? params.overriddenUserInfo.userFirstName : undefined),
userLastName: (params.overriddenUserInfo ? params.overriddenUserInfo.userLastName : undefined),
}
);

Expand Down