mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-21 22:59:07 +00:00
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import Express, {
|
|
ExpressRequest,
|
|
ExpressResponse,
|
|
ExpressRouter,
|
|
} from 'CommonServer/Utils/Express';
|
|
const router: ExpressRouter = Express.getRouter();
|
|
import Response from 'CommonServer/Utils/Response';
|
|
import Exception from 'Common/Types/Exception/Exception';
|
|
import ClusterKeyAuthorization from 'CommonServer/Middleware/ClusterKeyAuthorization';
|
|
import RealtimeService from '../Services/RealtimeService';
|
|
import ObjectID from 'Common/Types/ObjectID';
|
|
import { JSONObject } from 'Common/Types/JSON';
|
|
|
|
router.post(
|
|
':project-id/:event-type',
|
|
ClusterKeyAuthorization.isAuthorizedServiceMiddleware,
|
|
async (req: ExpressRequest, res: ExpressResponse) => {
|
|
try {
|
|
const body: JSONObject = req.body;
|
|
RealtimeService.send(
|
|
new ObjectID(req.params['projectId'] as string),
|
|
req.params['eventType'] as string,
|
|
body
|
|
);
|
|
return Response.sendEmptyResponse(req, res);
|
|
} catch (error) {
|
|
return Response.sendErrorResponse(req, res, error as Exception);
|
|
}
|
|
}
|
|
);
|
|
|
|
export default router;
|