Sharkey/src/server/api/endpoints/charts/user/reactions.ts
2021-06-08 14:09:32 +09:00

35 lines
789 B
TypeScript

import $ from 'cafy';
import define from '../../../define';
import { ID } from '@/misc/cafy-id';
import { convertLog } from '../../../../../services/chart/core';
import { perUserReactionsChart } from '../../../../../services/chart';
export const meta = {
tags: ['charts', 'users', 'reactions'],
params: {
span: {
validator: $.str.or(['day', 'hour']),
},
limit: {
validator: $.optional.num.range(1, 500),
default: 30,
},
offset: {
validator: $.optional.nullable.num,
default: null,
},
userId: {
validator: $.type(ID),
}
},
res: convertLog(perUserReactionsChart.schema),
};
export default define(meta, async (ps) => {
return await perUserReactionsChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null, ps.userId);
});