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';
|
2021-08-10 23:03:55 +02:00
|
|
|
import { allowQuery } from 'lib/auth';
|
2022-10-12 22:11:44 +02:00
|
|
|
import { useAuth, useCors } from 'lib/middleware';
|
2022-10-26 01:50:12 +02:00
|
|
|
import { TYPE_WEBSITE } from 'lib/constants';
|
2021-08-10 23:03:55 +02:00
|
|
|
|
|
|
|
export default async (req, res) => {
|
2022-10-12 22:11:44 +02:00
|
|
|
await useCors(req, res);
|
|
|
|
await useAuth(req, res);
|
|
|
|
|
2022-10-12 04:37:38 +02:00
|
|
|
const { id: websiteId } = req.query;
|
2021-08-10 23:03:55 +02:00
|
|
|
|
|
|
|
if (req.method === 'POST') {
|
2022-10-26 01:50:12 +02:00
|
|
|
if (!(await allowQuery(req, TYPE_WEBSITE))) {
|
2021-08-10 23:03:55 +02:00
|
|
|
return unauthorized(res);
|
|
|
|
}
|
|
|
|
|
|
|
|
await resetWebsite(websiteId);
|
|
|
|
|
|
|
|
return ok(res);
|
|
|
|
}
|
|
|
|
|
|
|
|
return methodNotAllowed(res);
|
|
|
|
};
|