umami/pages/api/websites/[id]/reset.js

21 lines
439 B
JavaScript
Raw Normal View History

2022-07-12 23:14:36 +02:00
import { resetWebsite } from 'queries';
2022-08-29 05:20:54 +02:00
import { methodNotAllowed, ok, unauthorized } from 'next-basics';
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);
};