mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Initial Typescript models.
This commit is contained in:
parent
04e9f06e93
commit
0aaba8cbd1
74 changed files with 1144 additions and 768 deletions
33
pages/api/websites/[id]/reset.ts
Normal file
33
pages/api/websites/[id]/reset.ts
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import { resetWebsite } from 'queries';
|
||||
import { methodNotAllowed, ok, unauthorized } from 'next-basics';
|
||||
import { allowQuery } from 'lib/auth';
|
||||
import { useAuth, useCors } from 'lib/middleware';
|
||||
import { TYPE_WEBSITE } from 'lib/constants';
|
||||
import { NextApiRequestQueryBody } from 'interface/api/nextApi';
|
||||
import { NextApiResponse } from 'next';
|
||||
|
||||
export interface WebsiteResetReqeustQuery {
|
||||
id: string;
|
||||
}
|
||||
|
||||
export default async (
|
||||
req: NextApiRequestQueryBody<WebsiteResetReqeustQuery>,
|
||||
res: NextApiResponse,
|
||||
) => {
|
||||
await useCors(req, res);
|
||||
await useAuth(req, res);
|
||||
|
||||
const { id: websiteId } = req.query;
|
||||
|
||||
if (req.method === 'POST') {
|
||||
if (!(await allowQuery(req, TYPE_WEBSITE))) {
|
||||
return unauthorized(res);
|
||||
}
|
||||
|
||||
await resetWebsite(websiteId);
|
||||
|
||||
return ok(res);
|
||||
}
|
||||
|
||||
return methodNotAllowed(res);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue