-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from uwblueprint/help-request-notifications/fixed
Help request notifications/fixed
- Loading branch information
Showing
49 changed files
with
3,603 additions
and
1,992 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { Request, Response, NextFunction } from "express"; | ||
import { validatePrimitive, getApiValidationError } from "./util"; | ||
|
||
export const createHelpRequestDtoValidator = async ( | ||
req: Request, | ||
res: Response, | ||
next: NextFunction, | ||
) => { | ||
if (!validatePrimitive(req.body.message, "string")) { | ||
return res.status(400).send(getApiValidationError("message", "string")); | ||
} | ||
if (!validatePrimitive(req.body.learner, "string")) { | ||
return res.status(400).send(getApiValidationError("learner", "string")); | ||
} | ||
if (!validatePrimitive(req.body.facilitator, "string")) { | ||
return res.status(400).send(getApiValidationError("facilitator", "string")); | ||
} | ||
if (!validatePrimitive(req.body.unit, "string")) { | ||
return res.status(400).send(getApiValidationError("unit", "string")); | ||
} | ||
if (!validatePrimitive(req.body.module, "string")) { | ||
return res.status(400).send(getApiValidationError("module", "string")); | ||
} | ||
if (!validatePrimitive(req.body.page, "string")) { | ||
return res.status(400).send(getApiValidationError("page", "string")); | ||
} | ||
return next(); | ||
}; | ||
|
||
export const updateHelpRequestDtoValidator = async ( | ||
req: Request, | ||
res: Response, | ||
next: NextFunction, | ||
) => { | ||
if ( | ||
req.body.unit !== undefined && | ||
!validatePrimitive(req.body.unit, "string") | ||
) { | ||
return res.status(400).send(getApiValidationError("unit", "string")); | ||
} | ||
if ( | ||
req.body.module !== undefined && | ||
!validatePrimitive(req.body.module, "string") | ||
) { | ||
return res.status(400).send(getApiValidationError("module", "string")); | ||
} | ||
if ( | ||
req.body.page !== undefined && | ||
!validatePrimitive(req.body.page, "string") | ||
) { | ||
return res.status(400).send(getApiValidationError("page", "string")); | ||
} | ||
if ( | ||
req.body.completed !== undefined && | ||
!validatePrimitive(req.body.completed, "boolean") | ||
) { | ||
return res.status(400).send(getApiValidationError("completed", "boolean")); | ||
} | ||
return next(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Request, Response, NextFunction } from "express"; | ||
import { validatePrimitive, getApiValidationError } from "./util"; | ||
|
||
export const getNotificationtDtoValidator = async ( | ||
req: Request, | ||
res: Response, | ||
next: NextFunction, | ||
) => { | ||
if ( | ||
req.body.skip !== undefined && | ||
!validatePrimitive(req.body.skip, "integer") | ||
) { | ||
return res.status(400).send(getApiValidationError("skip", "integer")); | ||
} | ||
if ( | ||
req.body.limit !== undefined && | ||
!validatePrimitive(req.body.limit, "integer") | ||
) { | ||
return res.status(400).send(getApiValidationError("limit", "integer")); | ||
} | ||
return next(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import mongoose, { Schema, Document, ObjectId } from "mongoose"; | ||
|
||
export interface CourseModule extends Document { | ||
id: string; | ||
displayIndex: number; | ||
title: string; | ||
pages: [ObjectId]; | ||
} | ||
|
||
export const CourseModuleSchema: Schema = new Schema({ | ||
title: { | ||
type: String, | ||
required: true, | ||
}, | ||
displayIndex: { | ||
type: Number, | ||
required: true, | ||
}, | ||
pages: [ | ||
{ | ||
type: Schema.Types.ObjectId, | ||
ref: "CoursePage", | ||
}, | ||
], | ||
}); | ||
|
||
/* eslint-disable no-param-reassign */ | ||
CourseModuleSchema.set("toJSON", { | ||
virtuals: true, | ||
versionKey: false, | ||
transform: (_doc: Document, ret: Record<string, unknown>) => { | ||
// eslint-disable-next-line no-underscore-dangle | ||
delete ret._id; | ||
}, | ||
}); | ||
|
||
export default mongoose.model<CourseModule>("CourseModule", CourseModuleSchema); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import mongoose, { Schema, Document } from "mongoose"; | ||
|
||
export type ElementSkeleton = { | ||
id: string; | ||
x: number; | ||
y: number; | ||
w: number; | ||
h: number; | ||
content: string; | ||
}; | ||
|
||
const ElementSkeletonSchema: Schema = new Schema({ | ||
x: { | ||
type: Number, | ||
required: true, | ||
}, | ||
y: { | ||
type: Number, | ||
required: true, | ||
}, | ||
w: { | ||
type: Number, | ||
required: true, | ||
}, | ||
h: { | ||
type: Number, | ||
required: true, | ||
}, | ||
content: { | ||
type: String, | ||
required: true, | ||
}, | ||
}); | ||
|
||
export type PageType = "Lesson" | "Activity"; | ||
|
||
export interface CoursePage extends Document { | ||
id: string; | ||
title: string; | ||
displayIndex: number; | ||
type: PageType; | ||
layout: [ElementSkeleton]; | ||
} | ||
|
||
export const CoursePageSchema: Schema = new Schema({ | ||
title: { | ||
type: String, | ||
required: true, | ||
}, | ||
displayIndex: { | ||
type: Number, | ||
required: true, | ||
}, | ||
type: { | ||
type: String, | ||
required: true, | ||
enum: ["Lesson", "Activity"], | ||
}, | ||
layout: { | ||
type: [ElementSkeletonSchema], | ||
required: true, | ||
}, | ||
}); | ||
|
||
/* eslint-disable no-param-reassign */ | ||
CoursePageSchema.set("toJSON", { | ||
virtuals: true, | ||
versionKey: false, | ||
transform: (_doc: Document, ret: Record<string, unknown>) => { | ||
// eslint-disable-next-line no-underscore-dangle | ||
delete ret._id; | ||
}, | ||
}); | ||
|
||
export default mongoose.model<CoursePage>("CoursePage", CoursePageSchema); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.