mirror of
https://github.com/umami-software/umami.git
synced 2026-02-11 16:17:13 +01:00
Convert send to TS.
This commit is contained in:
parent
e4c801e823
commit
2172dddd1c
4 changed files with 31 additions and 11 deletions
|
|
@ -8,7 +8,23 @@ import { secret } from 'lib/crypto';
|
|||
import { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { Resolver } from 'dns/promises';
|
||||
|
||||
export interface CollectRequestBody {
|
||||
payload: {
|
||||
data: { [key: string]: any };
|
||||
hostname: string;
|
||||
language: string;
|
||||
referrer: string;
|
||||
screen: string;
|
||||
title: string;
|
||||
url: string;
|
||||
website: string;
|
||||
name: string;
|
||||
};
|
||||
type: string;
|
||||
}
|
||||
|
||||
export interface NextApiRequestCollect extends NextApiRequest {
|
||||
body: CollectRequestBody;
|
||||
session: {
|
||||
id: string;
|
||||
websiteId: string;
|
||||
|
|
@ -23,6 +39,7 @@ export interface NextApiRequestCollect extends NextApiRequest {
|
|||
subdivision2: string;
|
||||
city: string;
|
||||
};
|
||||
headers: { [key: string]: any };
|
||||
}
|
||||
|
||||
export default async (req: NextApiRequestCollect, res: NextApiResponse) => {
|
||||
|
|
@ -32,7 +49,7 @@ export default async (req: NextApiRequestCollect, res: NextApiResponse) => {
|
|||
return ok(res);
|
||||
}
|
||||
|
||||
const { type, payload } = getJsonBody(req);
|
||||
const { type, payload } = getJsonBody<CollectRequestBody>(req);
|
||||
|
||||
if (type !== 'event') {
|
||||
return badRequest(res);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue