File size: 1,485 Bytes
3206347
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
49
50
51
52
53
import { Router } from 'express';
import asyncHandler from 'express-async-handler';
import { authenticateUser } from '../../../helpers/authentication.js';
import { authorizeUser } from '../../../helpers/authorization.js';
import checkIsCloud from '../../../helpers/check-is-cloud.js';
import getCurrentUserAction from '../../../controllers/api/v1/users/get-current-user.js';
import getUserTrialAction from '../../../controllers/api/v1/users/get-user-trial.ee.js';
import getAppsAction from '../../../controllers/api/v1/users/get-apps.js';
import getInvoicesAction from '../../../controllers/api/v1/users/get-invoices.ee.js';
import getSubscriptionAction from '../../../controllers/api/v1/users/get-subscription.ee.js';
import getPlanAndUsageAction from '../../../controllers/api/v1/users/get-plan-and-usage.ee.js';

const router = Router();

router.get('/me', authenticateUser, asyncHandler(getCurrentUserAction));

router.get(
  '/:userId/apps',
  authenticateUser,
  authorizeUser,
  asyncHandler(getAppsAction)
);

router.get(
  '/invoices',
  authenticateUser,
  checkIsCloud,
  asyncHandler(getInvoicesAction)
);

router.get(
  '/:userId/trial',
  authenticateUser,
  checkIsCloud,
  asyncHandler(getUserTrialAction)
);

router.get(
  '/:userId/subscription',
  authenticateUser,
  checkIsCloud,
  asyncHandler(getSubscriptionAction)
);

router.get(
  '/:userId/plan-and-usage',
  authenticateUser,
  checkIsCloud,
  asyncHandler(getPlanAndUsageAction)
);

export default router;