mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
fix: accounts types caching.
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
import { Service } from 'typedi';
|
||||
import { Request, Response, Router } from 'express';
|
||||
import { Service, Inject } from 'typedi';
|
||||
import { Request, Response, Router, NextFunction } from 'express';
|
||||
import asyncMiddleware from 'api/middleware/asyncMiddleware';
|
||||
import BaseController from 'api/controllers/BaseController';
|
||||
import AccountsTypesService from 'services/Accounts/AccountsTypesServices';
|
||||
|
||||
@Service()
|
||||
export default class AccountsTypesController extends BaseController{
|
||||
@Inject()
|
||||
accountsTypesService: AccountsTypesService;
|
||||
|
||||
/**
|
||||
* Router constructor.
|
||||
*/
|
||||
@@ -12,20 +16,22 @@ export default class AccountsTypesController extends BaseController{
|
||||
const router = Router();
|
||||
|
||||
router.get('/',
|
||||
asyncMiddleware(this.getAccountTypesList));
|
||||
|
||||
asyncMiddleware(this.getAccountTypesList.bind(this))
|
||||
);
|
||||
return router;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve accounts types list.
|
||||
*/
|
||||
async getAccountTypesList(req: Request, res: Response) {
|
||||
const { AccountType } = req.models;
|
||||
const accountTypes = await AccountType.query();
|
||||
async getAccountTypesList(req: Request, res: Response, next: NextFunction) {
|
||||
const { tenantId, user } = req;
|
||||
|
||||
return res.status(200).send({
|
||||
account_types: accountTypes,
|
||||
});
|
||||
try {
|
||||
const accountTypes = await this.accountsTypesService.getAccountsTypes(tenantId);
|
||||
return res.status(200).send({ account_types: accountTypes });
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user