-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: separate routes in standalone file
- Loading branch information
Showing
2 changed files
with
28 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import * as actual from './actual'; | ||
import express from 'express'; | ||
const router = express.Router(); | ||
|
||
router.get('/budget/:month', async (req, res) => { | ||
const budget = await actual.getBudgetAtMonth(req.params.month); | ||
res.status(200).json(budget); | ||
}); | ||
|
||
router.get('/accounts', async (_, res) => { | ||
const accounts = await actual.getAccounts(); | ||
res.status(200).json(accounts); | ||
}); | ||
|
||
router.get('/accounts/:accountid/transactions', async (req, res) => { | ||
const transactions = await actual.getTransactions(req.params.accountid); | ||
res.status(200).json(transactions); | ||
}); | ||
|
||
router.get('/transactions', async (req, res) => { | ||
const offbudget = req.query['offbudget'] === 'true'; | ||
const transactions = await actual.getAllTransactions(offbudget); | ||
res.status(200).json(transactions); | ||
}); | ||
|
||
export { router }; |