Download src/modules/saasAccounting/saasAccounting.controller.js from moustafa7/gymco: direct link, hf CLI and curl.
- Browser
- Download file 1.25 kB
-
https://huggingface.co/spaces/moustafa7/gymco/resolve/main/src/modules/saasAccounting/saasAccounting.controller.js
- Command line
-
hf download hf://spaces/moustafa7/gymco/src/modules/saasAccounting/saasAccounting.controller.js
-
curl -L -o saasAccounting.controller.js https://huggingface.co/spaces/moustafa7/gymco/resolve/main/src/modules/saasAccounting/saasAccounting.controller.js
1.25 kB
| import { asyncHandler } from '../../common/middleware/asyncHandler.js'; | |
| import { getPagination, paginated } from '../../common/utils/pagination.js'; | |
| import { created, ok } from '../../common/utils/response.js'; | |
| import { saasAccountingRepository } from './saasAccounting.repository.js'; | |
| export const saasAccountingController = { | |
| summary: asyncHandler(async (_req, res) => { | |
| ok(res, await saasAccountingRepository.summary()); | |
| }), | |
| listExpenses: asyncHandler(async (req, res) => { | |
| const pagination = getPagination(req.query); | |
| const [items, total] = await saasAccountingRepository.listExpenses({ | |
| search: req.query.search, | |
| ...pagination, | |
| }); | |
| ok(res, paginated(items, total, pagination.page, pagination.limit)); | |
| }), | |
| createExpense: asyncHandler(async (req, res) => { | |
| created(res, await saasAccountingRepository.createExpense(req.body), 'SaaS expense recorded'); | |
| }), | |
| updateExpense: asyncHandler(async (req, res) => { | |
| ok(res, await saasAccountingRepository.updateExpense(req.params.id, req.body), 'SaaS expense updated'); | |
| }), | |
| removeExpense: asyncHandler(async (req, res) => { | |
| await saasAccountingRepository.softDeleteExpense(req.params.id); | |
| ok(res, null, 'SaaS expense deleted'); | |
| }), | |
| }; | |