web-report/service/routes/reportor.ts
2023-08-21 15:36:10 +08:00

38 lines
819 B
TypeScript

import { RouteHandleFunction } from "../core/types";
import { listAppByUID } from "../service/app";
import { reportEvent } from "../service/report-service";
export const reportToServer: RouteHandleFunction = ({
param, res
}) => {
reportEvent(param).then(() => {
res.send('got and saved!')
}).catch((e: Error) => {
console.log(e)
res.send('got but not saved!')
});
}
export const appList: RouteHandleFunction = async ({
param, res
}) => {
const apps = await listAppByUID(1);
res.send({ code: 0, data: apps })
}
export const appEvent: RouteHandleFunction = async ({
query, res, param, body
}) => {
res.send({
query, param, body
})
}
export const eventData: RouteHandleFunction = ({
param, res
}) => {
res.send(JSON.stringify(param))
}