Skip to content

Commit

Permalink
add route for GET /module/:moduleId
Browse files Browse the repository at this point in the history
  • Loading branch information
Behzad-rabiei committed Apr 13, 2024
1 parent df54165 commit 0f28988
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/services/module.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,19 @@ const getModuleByFilter = async (filter: object): Promise<HydratedDocument<IModu
return Module.findOne(filter);
};

/**
* Get module by id
* @param {Types.ObjectId} id
* @returns {Promise<HydratedDocument<IModule> | null>}
*/
const getModuleById = async (id: Types.ObjectId): Promise<HydratedDocument<IModule> | null> => {
return Module.findById(id);
};


export default {
createModule,
queryModules,
getModuleByFilter
getModuleByFilter,
getModuleById
};
3 changes: 2 additions & 1 deletion src/types/customTypes.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { ICommunity, IPlatform } from '@togethercrew.dev/db';
import { ICommunity, IModule, IPlatform } from '@togethercrew.dev/db';
import { HydratedDocument } from 'mongoose';
import 'express-serve-static-core';

declare module 'express-serve-static-core' {
interface Request {
platform?: HydratedDocument<IPlatform>;
module?: HydratedDocument<IModule>;
community?: HydratedDocument<ICommunity>;
user?: HydratedDocument<IUser>;
session?: Session & Partial<SessionData> & { [key: string]: any };
Expand Down
10 changes: 9 additions & 1 deletion src/validations/module.validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,16 @@ const getModules = {
}),
};

const getModule = {
params: Joi.object().keys({
moduleId: Joi.string().custom(objectId),
}),
};



export default {
createModule,
getModules
getModules,
getModule
};

0 comments on commit 0f28988

Please sign in to comment.