Add reset website statistics to settings

This commit is contained in:
Chris Walsh 2021-08-10 14:03:55 -07:00
parent ae7186c32a
commit 6e128b2f38
No known key found for this signature in database
GPG key ID: 28EE0CCA6032019E
5 changed files with 143 additions and 0 deletions

View file

@ -0,0 +1,20 @@
import { resetWebsite } from 'lib/queries';
import { methodNotAllowed, ok, unauthorized } from 'lib/response';
import { allowQuery } from 'lib/auth';
export default async (req, res) => {
const { id } = req.query;
const websiteId = +id;
if (req.method === 'POST') {
if (!(await allowQuery(req))) {
return unauthorized(res);
}
await resetWebsite(websiteId);
return ok(res);
}
return methodNotAllowed(res);
};