aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/accounts.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-01-03 16:38:50 +0100
committerChocobozzz <me@florianbigard.com>2018-01-03 16:38:50 +0100
commit265ba139ebf56bbdc1c65f6ea4f367774c691fc0 (patch)
treec7c52d1ae48a35b8f9aa06a9fa2335a6ba502fd1 /server/controllers/api/accounts.ts
parent9bce811268cd74b402176ae9fcd8b77ac887576e (diff)
downloadPeerTube-265ba139ebf56bbdc1c65f6ea4f367774c691fc0.tar.gz
PeerTube-265ba139ebf56bbdc1c65f6ea4f367774c691fc0.tar.zst
PeerTube-265ba139ebf56bbdc1c65f6ea4f367774c691fc0.zip
Send account activitypub update events
Diffstat (limited to 'server/controllers/api/accounts.ts')
-rw-r--r--server/controllers/api/accounts.ts38
1 files changed, 38 insertions, 0 deletions
diff --git a/server/controllers/api/accounts.ts b/server/controllers/api/accounts.ts
new file mode 100644
index 000000000..aded581a5
--- /dev/null
+++ b/server/controllers/api/accounts.ts
@@ -0,0 +1,38 @@
1import * as express from 'express'
2import { getFormattedObjects } from '../../helpers/utils'
3import { asyncMiddleware, paginationValidator, setAccountsSort, setPagination } from '../../middlewares'
4import { accountsGetValidator, accountsSortValidator } from '../../middlewares/validators'
5import { AccountModel } from '../../models/account/account'
6
7const accountsRouter = express.Router()
8
9accountsRouter.get('/',
10 paginationValidator,
11 accountsSortValidator,
12 setAccountsSort,
13 setPagination,
14 asyncMiddleware(listAccounts)
15)
16
17accountsRouter.get('/:id',
18 asyncMiddleware(accountsGetValidator),
19 getAccount
20)
21
22// ---------------------------------------------------------------------------
23
24export {
25 accountsRouter
26}
27
28// ---------------------------------------------------------------------------
29
30function getAccount (req: express.Request, res: express.Response, next: express.NextFunction) {
31 return res.json(res.locals.account.toFormattedJSON())
32}
33
34async function listAccounts (req: express.Request, res: express.Response, next: express.NextFunction) {
35 const resultList = await AccountModel.listForApi(req.query.start, req.query.count, req.query.sort)
36
37 return res.json(getFormattedObjects(resultList.data, resultList.total))
38}