1
0
mirror of https://github.com/hotomoe/hotomoe synced 2024-12-26 20:48:13 +09:00
hotomoe/packages/backend/src/server/api/endpoints/get-online-users-count.ts
tamaina fcfb5ef0a3
Fix ajv (#8333)
* wip

* ✌️

* use ajv/dist/core

* revert try

* clean up
2022-02-20 13:15:40 +09:00

28 lines
573 B
TypeScript

import { USER_ONLINE_THRESHOLD } from '@/const';
import { Users } from '@/models/index';
import { MoreThan } from 'typeorm';
import define from '../define';
export const meta = {
tags: ['meta'],
requireCredential: false,
} as const;
export const paramDef = {
type: 'object',
properties: {},
required: [],
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, paramDef, async () => {
const count = await Users.count({
lastActiveDate: MoreThan(new Date(Date.now() - USER_ONLINE_THRESHOLD)),
});
return {
count,
};
});