Skip to content

Commit

Permalink
Add API for abuse logging
Browse files Browse the repository at this point in the history
  • Loading branch information
pimterry committed Nov 11, 2024
1 parent 6b38082 commit a42aa80
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion api/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { getCorsResponseHeaders } from './cors';
import { configureAppProxyTrust } from './trusted-xff-ip-setup';

import './connectivity-check';
import { reportError } from './errors';

const app = express();

Expand Down Expand Up @@ -62,7 +63,8 @@ apiRouter.options('*', (req, res) => {
'/get-billing-data',
'/update-team',
'/update-team-size',
'/cancel-subscription'
'/cancel-subscription',
'/log-abuse-report'
].includes(req.path)) {
// Account APIs are limited to our own hosts:
const headers = getCorsResponseHeaders(event);
Expand Down Expand Up @@ -94,6 +96,16 @@ apiRouter.get('/redirect-paypro-to-thank-you', lambdaWrapper('redirect-paypro-to
apiRouter.post('/update-team', lambdaWrapper('update-team'));
apiRouter.post('/update-team-size', lambdaWrapper('update-team-size'));
apiRouter.post('/cancel-subscription', lambdaWrapper('cancel-subscription'));
apiRouter.post('/log-abuse-report', (req, res) => {
reportError(`Abuse report`, {
extraMetadata: {
from: req.ip?.replace(/\./g, '-'),
body: req.body
}
});

return res.status(204).send();
});

export function startApiServer() {
const server = app.listen(process.env.PORT ?? 3000, () => {
Expand Down

0 comments on commit a42aa80

Please sign in to comment.