forked from FoundKeyGang/FoundKey
Implement federation chart API
This commit is contained in:
parent
3b5c3f086a
commit
038bd100b2
1 changed files with 33 additions and 0 deletions
33
src/server/api/endpoints/charts/federation.ts
Normal file
33
src/server/api/endpoints/charts/federation.ts
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
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);
|
||||||
|
});
|
Loading…
Reference in a new issue