Skip to content

Commit 1e76dca

Browse files
authored
Merge pull request #243 from phoenix303/final-fixes
Merging final fixes to the `feature/org-config-final-fixes` branch, not to `dev` for now.
2 parents a466252 + faf9578 commit 1e76dca

File tree

4 files changed

+292
-17
lines changed

4 files changed

+292
-17
lines changed

migrations/20190129_organization_config.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
--
55
CREATE TABLE org_config (
66
id bigint NOT NULL,
7-
orgId character varying(45) NOT NULL,
8-
configName character varying(45) NOT NULL,
9-
configValue character varying(512),
7+
"orgId" character varying(45) NOT NULL,
8+
"configName" character varying(45) NOT NULL,
9+
"configValue" character varying(512),
1010
"deletedAt" timestamp with time zone,
1111
"createdAt" timestamp with time zone,
1212
"updatedAt" timestamp with time zone,

package-lock.json

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/routes/orgConfig/list.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,30 @@
11
/**
22
* API to list organization config
33
*/
4+
import validate from 'express-validation';
5+
import Joi from 'joi';
46
import { middleware as tcMiddleware } from 'tc-core-library-js';
57
import models from '../../models';
68
import util from '../../util';
79

810
const permissions = tcMiddleware.permissions;
911

12+
const schema = {
13+
query: {
14+
filter: Joi.string().required(),
15+
},
16+
};
17+
1018
module.exports = [
19+
validate(schema),
1120
permissions('orgConfig.view'),
1221
(req, res, next) => {
1322
// handle filters
1423
const filters = util.parseQueryFilter(req.query.filter);
24+
// Throw error if orgId is not present in filter
25+
if (!filters.orgId) {
26+
return next(util.buildApiError('Missing filter orgId', 422));
27+
}
1528
if (!util.isValidFilter(filters, ['orgId', 'configName'])) {
1629
return util.handleError('Invalid filters', null, req, next);
1730
}

0 commit comments

Comments
 (0)