Skip to content

Commit

Permalink
feat: enable service
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanCassiere committed Jun 23, 2024
1 parent 2bd4321 commit fb84c6b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/v2/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ app.get("/:service_id", adminServiceValidation, async (c) => {
return c.json(getServiceOutputSchema.parse(service));
});

/**
* @private
* Disable a service, only accessible by admins
*/
app.delete("/:service_id", adminServiceValidation, async (c) => {
const reqServiceId = c.var.service!.id;
const serviceId = c.req.param("service_id");
Expand All @@ -114,4 +118,17 @@ app.delete("/:service_id", adminServiceValidation, async (c) => {
return c.json({ success: true, message: ENDPOINT_MESSAGES.ServiceDisabled });
});

/**
* @private
* Enable a service, only accessible by admins
*/
app.post("/:service_id/enable", adminServiceValidation, async (c) => {
const serviceId = c.req.param("service_id");

await db.update(servicesTable).set({ isActive: true }).where(eq(servicesTable.id, serviceId)).execute();

c.status(200);
return c.json({ success: true, message: ENDPOINT_MESSAGES.ServiceEnabled });
});

export default app;

0 comments on commit fb84c6b

Please sign in to comment.