summaryrefslogtreecommitdiff
path: root/src/server/api/endpoints/stats.ts
blob: 719792d40d48b70506b2aaddb24939c51b3a81a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
 * Module dependencies
 */
import Post from '../models/post';
import User from '../models/user';

/**
 * @swagger
 * /stats:
 *   post:
 *     summary: Show the misskey's statistics
 *     responses:
 *       200:
 *         description: Success
 *         schema:
 *           type: object
 *           properties:
 *             postsCount:
 *               description: count of all posts of misskey
 *               type: number
 *             usersCount:
 *               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({
		postsCount: postsCount,
		usersCount: usersCount
	});
});