Update useValidate calls.

This commit is contained in:
Mike Cao 2023-09-29 20:24:48 -07:00
parent 5e3c135388
commit 0d9b6e8355
37 changed files with 38 additions and 106 deletions

View File

@ -28,9 +28,7 @@ export default async (
) => {
await useCors(req, res);
await useAuth(req, res);
req.yup = schema;
await useValidate(req, res);
await useValidate(schema, req, res);
if (req.method === 'GET') {
const { websiteId, startAt, endAt, event } = req.query;

View File

@ -28,9 +28,7 @@ export default async (
) => {
await useCors(req, res);
await useAuth(req, res);
req.yup = schema;
await useValidate(req, res);
await useValidate(schema, req, res);
if (req.method === 'GET') {
const { websiteId, startAt, endAt, field } = req.query;

View File

@ -26,9 +26,7 @@ export default async (
) => {
await useCors(req, res);
await useAuth(req, res);
req.yup = schema;
await useValidate(req, res);
await useValidate(schema, req, res);
if (req.method === 'GET') {
const { websiteId, startAt, endAt } = req.query;

View File

@ -37,9 +37,7 @@ export default async (
}
await useAuth(req, res);
req.yup = schema;
await useValidate(req, res);
await useValidate(schema, req, res);
const { currentPassword, newPassword } = req.body;
const { id } = req.auth.user;

View File

@ -21,9 +21,7 @@ export default async (
res: NextApiResponse,
) => {
await useCors(req, res);
req.yup = schema;
await useValidate(req, res);
await useValidate(schema, req, res);
if (req.method === 'GET') {
req.query.id = req.auth.user.id;

View File

@ -22,9 +22,7 @@ export default async (
) => {
await useCors(req, res);
await useAuth(req, res);
req.yup = schema;
await useValidate(req, res);
await useValidate(schema, req, res);
if (req.method === 'GET') {
req.query.id = req.auth.user.id;

View File

@ -23,9 +23,7 @@ export default async (
res: NextApiResponse<RealtimeInit>,
) => {
await useAuth(req, res);
req.yup = schema;
await useValidate(req, res);
await useValidate(schema, req, res);
if (req.method === 'GET') {
const { id: websiteId, startAt } = req.query;

View File

@ -46,9 +46,7 @@ export default async (
) => {
await useCors(req, res);
await useAuth(req, res);
req.yup = schema;
await useValidate(req, res);
await useValidate(schema, req, res);
const { id: reportId } = req.query;
const {

View File

@ -44,9 +44,7 @@ export default async (
) => {
await useCors(req, res);
await useAuth(req, res);
req.yup = schema;
await useValidate(req, res);
await useValidate(schema, req, res);
if (req.method === 'POST') {
const {

View File

@ -43,9 +43,7 @@ export default async (
) => {
await useCors(req, res);
await useAuth(req, res);
req.yup = schema;
await useValidate(req, res);
await useValidate(schema, req, res);
const {
user: { id: userId },

View File

@ -69,9 +69,7 @@ export default async (
) => {
await useCors(req, res);
await useAuth(req, res);
req.yup = schema;
await useValidate(req, res);
await useValidate(schema, req, res);
if (req.method === 'POST') {
const {

View File

@ -32,9 +32,7 @@ export default async (
) => {
await useCors(req, res);
await useAuth(req, res);
req.yup = schema;
await useValidate(req, res);
await useValidate(schema, req, res);
if (req.method === 'POST') {
const {

View File

@ -80,8 +80,7 @@ export default async (req: NextApiRequestCollect, res: NextApiResponse) => {
const { type, payload } = req.body;
req.yup = schema;
await useValidate(req, res);
await useValidate(schema, req, res);
if (await hasBlockedIp(req)) {
return forbidden(res);

View File

@ -25,8 +25,7 @@ export default async (
req: NextApiRequestQueryBody<ShareRequestQuery>,
res: NextApiResponse<ShareResponse>,
) => {
req.yup = schema;
await useValidate(req, res);
await useValidate(schema, req, res);
const { id: shareId } = req.query;

View File

@ -35,9 +35,7 @@ export default async (
res: NextApiResponse<Team>,
) => {
await useAuth(req, res);
req.yup = schema;
await useValidate(req, res);
await useValidate(schema, req, res);
const { id: teamId } = req.query;

View File

@ -20,9 +20,7 @@ const schema = {
export default async (req: NextApiRequestQueryBody<TeamUserRequestQuery>, res: NextApiResponse) => {
await useAuth(req, res);
req.yup = schema;
await useValidate(req, res);
await useValidate(schema, req, res);
if (req.method === 'DELETE') {
const { id: teamId, userId } = req.query;

View File

@ -21,8 +21,7 @@ export default async (
res: NextApiResponse,
) => {
await useAuth(req, res);
req.yup = schema;
await useValidate(req, res);
await useValidate(schema, req, res);
const { id: teamId } = req.query;

View File

@ -23,9 +23,7 @@ export default async (
res: NextApiResponse,
) => {
await useAuth(req, res);
req.yup = schema;
await useValidate(req, res);
await useValidate(schema, req, res);
const { id: teamId, websiteId } = req.query;

View File

@ -32,9 +32,7 @@ export default async (
res: NextApiResponse,
) => {
await useAuth(req, res);
req.yup = schema;
await useValidate(req, res);
await useValidate(schema, req, res);
const { id: teamId } = req.query;

View File

@ -30,9 +30,7 @@ export default async (
res: NextApiResponse<Team[] | Team>,
) => {
await useAuth(req, res);
req.yup = schema;
await useValidate(req, res);
await useValidate(schema, req, res);
const {
user: { id: userId },

View File

@ -21,9 +21,7 @@ export default async (
res: NextApiResponse<Team>,
) => {
await useAuth(req, res);
req.yup = schema;
await useValidate(req, res);
await useValidate(schema, req, res);
if (req.method === 'POST') {
const { accessCode } = req.body;

View File

@ -33,9 +33,7 @@ export default async (
res: NextApiResponse<User>,
) => {
await useAuth(req, res);
req.yup = schema;
await useValidate(req, res);
await useValidate(schema, req, res);
const {
user: { id: userId, isAdmin },

View File

@ -29,9 +29,7 @@ export default async (
) => {
await useCors(req, res);
await useAuth(req, res);
req.yup = schema;
await useValidate(req, res);
await useValidate(schema, req, res);
const { user } = req.auth;
const { id: userId } = req.query;

View File

@ -36,9 +36,7 @@ export default async (
) => {
await useCors(req, res);
await useAuth(req, res);
req.yup = schema;
await useValidate(req, res);
await useValidate(schema, req, res);
const { user } = req.auth;

View File

@ -27,9 +27,7 @@ export default async (
) => {
await useCors(req, res);
await useAuth(req, res);
req.yup = schema;
await useValidate(req, res);
await useValidate(schema, req, res);
const { user } = req.auth;
const { id: userId, page, query, includeTeams, onlyTeams } = req.query;

View File

@ -37,9 +37,7 @@ export default async (
res: NextApiResponse<User[] | User>,
) => {
await useAuth(req, res);
req.yup = schema;
await useValidate(req, res);
await useValidate(schema, req, res);
if (req.method === 'GET') {
if (!(await canViewUsers(req.auth))) {

View File

@ -22,9 +22,7 @@ export default async (
) => {
await useCors(req, res);
await useAuth(req, res);
req.yup = schema;
await useValidate(req, res);
await useValidate(schema, req, res);
const { id: websiteId } = req.query;

View File

@ -22,9 +22,7 @@ export default async (
) => {
await useCors(req, res);
await useAuth(req, res);
req.yup = schema;
await useValidate(req, res);
await useValidate(schema, req, res);
const { id: websiteId } = req.query;

View File

@ -34,9 +34,7 @@ export default async (
) => {
await useCors(req, res);
await useAuth(req, res);
req.yup = schema;
await useValidate(req, res);
await useValidate(schema, req, res);
const { id: websiteId, timezone, url } = req.query;
const { startDate, endDate, unit } = await parseDateRangeQuery(req);

View File

@ -36,9 +36,7 @@ export default async (
) => {
await useCors(req, res);
await useAuth(req, res);
req.yup = schema;
await useValidate(req, res);
await useValidate(schema, req, res);
const { id: websiteId } = req.query;

View File

@ -54,9 +54,7 @@ export default async (
) => {
await useCors(req, res);
await useAuth(req, res);
req.yup = schema;
await useValidate(req, res);
await useValidate(schema, req, res);
const {
id: websiteId,

View File

@ -50,9 +50,7 @@ export default async (
) => {
await useCors(req, res);
await useAuth(req, res);
req.yup = schema;
await useValidate(req, res);
await useValidate(schema, req, res);
const {
id: websiteId,

View File

@ -22,9 +22,7 @@ export default async (
) => {
await useCors(req, res);
await useAuth(req, res);
req.yup = schema;
await useValidate(req, res);
await useValidate(schema, req, res);
const { id: websiteId } = req.query;

View File

@ -22,8 +22,7 @@ export default async (
) => {
await useCors(req, res);
await useAuth(req, res);
req.yup = schema;
await useValidate(req, res);
await useValidate(schema, req, res);
const { id: websiteId } = req.query;

View File

@ -50,9 +50,7 @@ export default async (
) => {
await useCors(req, res);
await useAuth(req, res);
req.yup = schema;
await useValidate(req, res);
await useValidate(schema, req, res);
const {
id: websiteId,

View File

@ -20,9 +20,7 @@ const schema = {
export default async (req: NextApiRequestQueryBody<ValuesRequestQuery>, res: NextApiResponse) => {
await useCors(req, res);
await useAuth(req, res);
req.yup = schema;
await useValidate(req, res);
await useValidate(schema, req, res);
const { id: websiteId, type } = req.query;

View File

@ -34,8 +34,8 @@ export default async (
) => {
await useCors(req, res);
await useAuth(req, res);
req.yup = schema;
await useValidate(req, res);
await useValidate(schema, req, res);
const {
user: { id: userId },