-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #269 from Chia-Network/feature/expose-label-api
feat: expose get all labels api
- Loading branch information
Showing
7 changed files
with
85 additions
and
75 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,21 @@ | ||
import { Label, Organization } from '../models'; | ||
|
||
import { assertHomeOrgExists } from '../utils/data-assertions'; | ||
|
||
export const findAll = async (req, res) => { | ||
try { | ||
await assertHomeOrgExists(); | ||
const homeOrg = await Organization.getHomeOrg(); | ||
|
||
return res.json( | ||
await Label.findAll({ | ||
where: { orgUid: homeOrg.orgUid }, | ||
}), | ||
); | ||
} catch (error) { | ||
res.status(400).json({ | ||
message: 'Can not retreive labels', | ||
error: error.message, | ||
}); | ||
} | ||
}; |
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
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,13 @@ | ||
'use strict'; | ||
|
||
import express from 'express'; | ||
|
||
import { LabelController } from '../../../controllers'; | ||
|
||
const LabelRouter = express.Router(); | ||
|
||
LabelRouter.get('/', (req, res) => { | ||
return LabelController.findAll(req, res); | ||
}); | ||
|
||
export { LabelRouter }; |