Skip to content

Commit

Permalink
fix: restored start stream endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Louis3797 committed Jun 6, 2024
1 parent 74162f3 commit d6e51bd
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
64 changes: 64 additions & 0 deletions apps/api/src/controller/stream.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,70 @@ export const createStream = async (
});
};

export const startStream = async (
req: Request<{ id: string }>,
res: Response<
TypedResponse<{
stream: Stream & {
streamer: Pick<
User,
| "id"
| "username"
| "dispname"
| "avatar_url"
| "followerCount"
| "promotionPoints"
| "level"
>;
};
}>
>
) => {
const { id } = req.params;
try {
const stream = await prismaClient.stream.update({
where: {
id
},
data: {
active: true
},
include: {
streamer: {
select: {
id: true,
username: true,
dispname: true,
promotionPoints: true,
level: true,
avatar_url: true,
followerCount: true
}
}
}
});

return res.status(httpStatus.OK).json({
success: true,
data: {
stream
},
error: []
});
} catch {
return res.status(httpStatus.BAD_REQUEST).json({
success: false,
data: null,
error: [
...createErrorObject(
httpStatus.INTERNAL_SERVER_ERROR,
"Stream couldnt be started, there was an internal sever error"
)
]
});
}
};

export const getRecommended = async (
_: Request,
res: Response<
Expand Down
2 changes: 2 additions & 0 deletions apps/api/src/routes/stream.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ streamRouter.get("/:id", streamController.getStreamInfo);

streamRouter.post("/create", streamController.createStream);

streamRouter.put("/:id/start", streamController.activateStream);

streamRouter.get("/recommended", streamController.getRecommended);

streamRouter.delete("/:id/delete", streamController.deleteStream);
Expand Down

0 comments on commit d6e51bd

Please sign in to comment.