yumechi-no-kuni/src/server/api/endpoints/stats.ts

49 lines
992 B
TypeScript
Raw Normal View History

2017-08-12 01:17:03 -05:00
/**
* Module dependencies
*/
2018-03-29 06:32:18 -05:00
import Post from '../../../models/post';
import User from '../../../models/user';
2017-08-12 01:17:03 -05:00
/**
* @swagger
* /stats:
* post:
* summary: Show the misskey's statistics
* responses:
* 200:
* description: Success
* schema:
* type: object
* properties:
2018-03-29 00:48:47 -05:00
* postsCount:
2017-08-12 01:17:03 -05:00
* description: count of all posts of misskey
* type: number
2018-03-29 00:48:47 -05:00
* usersCount:
2017-08-12 01:17:03 -05:00
* description: count of all users of misskey
* type: number
*
* default:
* description: Failed
* schema:
* $ref: "#/definitions/Error"
*/
/**
* Show the misskey's statistics
*
* @param {any} params
* @return {Promise<any>}
*/
module.exports = params => new Promise(async (res, rej) => {
const postsCount = await Post
.count();
const usersCount = await User
.count();
res({
2018-03-29 00:48:47 -05:00
postsCount: postsCount,
usersCount: usersCount
2017-08-12 01:17:03 -05:00
});
});