Skip to content
Snippets Groups Projects
Unverified Commit 038bd100 authored by syuilo's avatar syuilo
Browse files

Implement federation chart API

parent 3b5c3f08
No related branches found
No related tags found
No related merge requests found
import $ from 'cafy';
import getParams from '../../get-params';
import federationChart from '../../../../chart/federation';
export const meta = {
desc: {
'ja-JP': 'フェデレーションのチャートを取得します。'
},
params: {
span: $.str.or(['day', 'hour']).note({
desc: {
'ja-JP': '集計のスパン (day または hour)'
}
}),
limit: $.num.optional.range(1, 100).note({
default: 30,
desc: {
'ja-JP': '最大数。例えば 30 を指定したとすると、スパンが"day"の場合は30日分のデータが、スパンが"hour"の場合は30時間分のデータが返ります。'
}
}),
}
};
export default (params: any) => new Promise(async (res, rej) => {
const [ps, psErr] = getParams(meta, params);
if (psErr) throw psErr;
const stats = await federationChart.getChart(ps.span as any, ps.limit);
res(stats);
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment