-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
forgot to add the actual project stuff
- Loading branch information
1 parent
2a416ad
commit 6af91ae
Showing
2 changed files
with
147 additions
and
0 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,46 @@ | ||
import { Router } from "express"; | ||
//import { Role } from "../auth/auth-schemas"; | ||
|
||
import { StatusCode } from "status-code-enum"; | ||
|
||
import specification, { Tag } from "../../middleware/specification"; | ||
|
||
import { | ||
//ProjectSchema, | ||
ProjectsSchema, | ||
//ProjectMappingSchema, | ||
//PathTypeSchema, | ||
//TrackTypeSchema | ||
} from './projects-schema' | ||
|
||
//import { EventIdSchema, SuccessResponseSchema } from "../../common/schemas"; | ||
//import { z } from "zod"; | ||
import Models from "../../common/models"; | ||
//import { tryGetAuthenticatedUser } from "../../common/auth"; | ||
//import Config from "../../common/config"; | ||
//import crypto from "crypto"; | ||
|
||
const projectRouter = Router(); | ||
|
||
projectRouter.get( | ||
"/list/", | ||
specification({ | ||
method: "get", | ||
path: "/projects/list/", | ||
tag: Tag.PROJECTS, | ||
role: null, //staff only endpoint | ||
summary: "get list of all teams", | ||
responses: { | ||
[StatusCode.SuccessOK]: { | ||
description: "The projects", | ||
schema: ProjectsSchema, | ||
}, | ||
}, | ||
}), | ||
async(_req, res) => { | ||
const projects = await Models.Projects.find(); | ||
return res.status(StatusCode.SuccessOK).send({ projects: projects }); | ||
}, | ||
); | ||
|
||
export default projectRouter; |
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,101 @@ | ||
import { z } from "zod"; | ||
import { prop } from "@typegoose/typegoose"; | ||
import { UserIdSchema } from "../../common/schemas"; | ||
|
||
// path enum | ||
export enum PathType { | ||
BEGINNER = "BEGINNER", | ||
GENERAL = "GENERAL", | ||
PRO = "PRO" | ||
} | ||
export const PathTypeSchema = z.nativeEnum(PathType); | ||
|
||
// track enum | ||
export enum TrackType { | ||
SPONSOR_1 = "SPONSOR1", | ||
SPONSOR_2 = "SPONSOR2", | ||
SPONSOR_3 = "SPONSOR3" | ||
} | ||
export const TrackTypeSchema = z.nativeEnum(TrackType); | ||
|
||
// general interface for a project | ||
export class Project { | ||
@prop({ required: true}) | ||
public projectName: string; | ||
|
||
@prop({required: true}) | ||
public ownerId: string | ||
|
||
@prop({ | ||
required: true, | ||
type: () => String | ||
}) | ||
public teamMembers: string[] | ||
|
||
@prop({ | ||
required: true, | ||
enum: PathType | ||
}) | ||
public path: PathType | ||
|
||
@prop({ | ||
required: true, | ||
enum: TrackType | ||
}) | ||
public track: TrackType | ||
|
||
@prop({required: true}) | ||
public githubLink: string | ||
|
||
@prop({required: true}) | ||
public videoLink: string | ||
|
||
@prop({required: true}) | ||
public accessCode: string | ||
|
||
@prop({required: false}) | ||
public description: string | ||
|
||
} | ||
|
||
// interface for ownerId to userId mapping | ||
export class ProjectMapping { | ||
@prop({required: true}) | ||
public teamOwnerId: string | ||
|
||
@prop({required: true}) | ||
public userId: string | ||
} | ||
|
||
export const ProjectSchema = z | ||
.object({ | ||
projectName: z.string(), | ||
ownerId: UserIdSchema, | ||
teamMembers: z.array(UserIdSchema), | ||
path: PathTypeSchema, | ||
track: TrackTypeSchema, | ||
githubLink: z.string(), | ||
videoLink: z.string(), | ||
accessCode: z.string(), | ||
description: z.string().optional() | ||
}) | ||
.openapi("ProjectSchema", { | ||
description: "Information about a project" | ||
}) | ||
|
||
export const ProjectMappingSchema = z | ||
.object({ | ||
teamOwnerId: UserIdSchema, | ||
userId: UserIdSchema, | ||
}) | ||
.openapi("ProjectMappingSchema", { | ||
description: "Mapping team owner's ID to their teammates' userIDs" | ||
}) | ||
|
||
export const ProjectsSchema = z | ||
.object({ | ||
projects: z.array(ProjectSchema) | ||
}) | ||
.openapi("ProjectsSchema", { | ||
description: "all projects" | ||
}) |