summaryrefslogtreecommitdiff
path: root/src/server/api/endpoints/stats.ts
diff options
context:
space:
mode:
authorAkihiko Odaki <nekomanma@pixiv.co.jp>2018-03-29 01:20:40 +0900
committerAkihiko Odaki <nekomanma@pixiv.co.jp>2018-03-29 01:54:41 +0900
commit90f8fe7e538bb7e52d2558152a0390e693f39b11 (patch)
tree0f830887053c8f352b1cd0c13ca715fd14c1f030 /src/server/api/endpoints/stats.ts
parentImplement remote account resolution (diff)
downloadsharkey-90f8fe7e538bb7e52d2558152a0390e693f39b11.tar.gz
sharkey-90f8fe7e538bb7e52d2558152a0390e693f39b11.tar.bz2
sharkey-90f8fe7e538bb7e52d2558152a0390e693f39b11.zip
Introduce processor
Diffstat (limited to 'src/server/api/endpoints/stats.ts')
-rw-r--r--src/server/api/endpoints/stats.ts48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/server/api/endpoints/stats.ts b/src/server/api/endpoints/stats.ts
new file mode 100644
index 0000000000..a6084cd17a
--- /dev/null
+++ b/src/server/api/endpoints/stats.ts
@@ -0,0 +1,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:
+ * posts_count:
+ * description: count of all posts of misskey
+ * type: number
+ * users_count:
+ * 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({
+ posts_count: postsCount,
+ users_count: usersCount
+ });
+});