Skip to content

Commit 75ebda7

Browse files
committed
Add API for abuse logging
1 parent 6b38082 commit 75ebda7

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

api/src/server.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { getCorsResponseHeaders } from './cors';
77
import { configureAppProxyTrust } from './trusted-xff-ip-setup';
88

99
import './connectivity-check';
10+
import { reportError } from './errors';
1011

1112
const app = express();
1213

@@ -62,7 +63,8 @@ apiRouter.options('*', (req, res) => {
6263
'/get-billing-data',
6364
'/update-team',
6465
'/update-team-size',
65-
'/cancel-subscription'
66+
'/cancel-subscription',
67+
'/log-abuse-report'
6668
].includes(req.path)) {
6769
// Account APIs are limited to our own hosts:
6870
const headers = getCorsResponseHeaders(event);
@@ -94,6 +96,16 @@ apiRouter.get('/redirect-paypro-to-thank-you', lambdaWrapper('redirect-paypro-to
9496
apiRouter.post('/update-team', lambdaWrapper('update-team'));
9597
apiRouter.post('/update-team-size', lambdaWrapper('update-team-size'));
9698
apiRouter.post('/cancel-subscription', lambdaWrapper('cancel-subscription'));
99+
apiRouter.post('/log-abuse-report', (req) => {
100+
reportError(`Abuse report`, {
101+
extraMetadata: {
102+
from: req.ip?.replace(/\./g, '-'),
103+
body: req.body
104+
}
105+
});
106+
107+
return { statusCode: 204 };
108+
});
97109

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

0 commit comments

Comments
 (0)