Skip to content

Commit

Permalink
Update useValidate calls.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecao committed Sep 30, 2023
1 parent 5e3c135 commit 0d9b6e8
Show file tree
Hide file tree
Showing 37 changed files with 38 additions and 106 deletions.
4 changes: 1 addition & 3 deletions src/pages/api/event-data/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions src/pages/api/event-data/fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions src/pages/api/event-data/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions src/pages/api/me/password.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions src/pages/api/me/teams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions src/pages/api/me/websites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions src/pages/api/realtime/[id].ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions src/pages/api/reports/[id].ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 1 addition & 3 deletions src/pages/api/reports/funnel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 1 addition & 3 deletions src/pages/api/reports/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
4 changes: 1 addition & 3 deletions src/pages/api/reports/insights.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 1 addition & 3 deletions src/pages/api/reports/retention.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions src/pages/api/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions src/pages/api/share/[id].ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 1 addition & 3 deletions src/pages/api/teams/[id]/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 1 addition & 3 deletions src/pages/api/teams/[id]/users/[userId].ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/pages/api/teams/[id]/users/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 1 addition & 3 deletions src/pages/api/teams/[id]/websites/[websiteId].ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 1 addition & 3 deletions src/pages/api/teams/[id]/websites/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 1 addition & 3 deletions src/pages/api/teams/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
4 changes: 1 addition & 3 deletions src/pages/api/teams/join.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions src/pages/api/users/[id]/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
4 changes: 1 addition & 3 deletions src/pages/api/users/[id]/teams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions src/pages/api/users/[id]/usage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 1 addition & 3 deletions src/pages/api/users/[id]/websites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions src/pages/api/users/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))) {
Expand Down
4 changes: 1 addition & 3 deletions src/pages/api/websites/[id]/active.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 1 addition & 3 deletions src/pages/api/websites/[id]/daterange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 1 addition & 3 deletions src/pages/api/websites/[id]/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 1 addition & 3 deletions src/pages/api/websites/[id]/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 1 addition & 3 deletions src/pages/api/websites/[id]/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 1 addition & 3 deletions src/pages/api/websites/[id]/pageviews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 1 addition & 3 deletions src/pages/api/websites/[id]/reports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 1 addition & 2 deletions src/pages/api/websites/[id]/reset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 1 addition & 3 deletions src/pages/api/websites/[id]/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 1 addition & 3 deletions src/pages/api/websites/[id]/values.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Loading

0 comments on commit 0d9b6e8

Please sign in to comment.