Removed getJsonBody.

This commit is contained in:
Mike Cao 2023-08-30 16:40:32 -07:00
parent a7ea202785
commit 620011a837
3 changed files with 5 additions and 13 deletions

View file

@ -130,11 +130,3 @@ export async function getClientInfo(req: NextApiRequestCollect, { screen }) {
return { userAgent, browser, os, ip, country, subdivision1, subdivision2, city, device };
}
export function getJsonBody<T>(req): T {
if ((req.headers['content-type'] || '').indexOf('text/plain') !== -1) {
return JSON.parse(req.body);
}
return req.body;
}

View file

@ -1,7 +1,7 @@
import { isUuid, secret, uuid } from 'lib/crypto';
import { getClientInfo, getJsonBody } from 'lib/detect';
import { getClientInfo } from 'lib/detect';
import { parseToken } from 'next-basics';
import { CollectRequestBody, NextApiRequestCollect } from 'pages/api/send';
import { NextApiRequestCollect } from 'pages/api/send';
import { createSession } from 'queries';
import cache from './cache';
import clickhouse from './clickhouse';
@ -22,7 +22,7 @@ export async function findSession(req: NextApiRequestCollect): Promise<{
city: any;
ownerId: string;
}> {
const { payload } = getJsonBody<CollectRequestBody>(req);
const { payload } = req.body;
if (!payload) {
throw new Error('Invalid payload.');