Skip to content

Commit

Permalink
feat: add test endpoint for sending notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
serezhaolshan committed Oct 8, 2024
1 parent 822ac1f commit 0b01159
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/router/watcher.router.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { DependencyContainer } from "tsyringe";
import { Application } from "express";
import { WatcherNetwork } from "../watcher";
import { NotificationService } from "../notification-sender";

const routes = (app: Application, container: DependencyContainer) => {

Expand Down Expand Up @@ -45,5 +46,19 @@ const routes = (app: Application, container: DependencyContainer) => {
"/api/v1/push-token",
watcherNetwork.updateWatcherPushToken.bind(watcherNetwork)
);

app.post("/api/v1/send-notification", (req, res) => {
const { title, body, pushToken, data } = req.body;
container.resolve(NotificationService).sendNotification({
title,
body,
pushToken,
data
}).then((result) => {
res.send(result);
}).catch((error) => {
res.status(500).send(error);
});
});
};
export default routes;

0 comments on commit 0b01159

Please sign in to comment.