Skip to content

Commit

Permalink
forgot to add the actual project stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Aryan-Bahl committed Oct 28, 2024
1 parent 2a416ad commit 6af91ae
Show file tree
Hide file tree
Showing 2 changed files with 147 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/services/projects/projects-router.ts
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;
101 changes: 101 additions & 0 deletions src/services/projects/projects-schema.ts
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"
})

0 comments on commit 6af91ae

Please sign in to comment.