diff --git a/src/router/watcher.router.ts b/src/router/watcher.router.ts index 92a0ed4..9b0597a 100644 --- a/src/router/watcher.router.ts +++ b/src/router/watcher.router.ts @@ -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) => { @@ -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; \ No newline at end of file