Skip to content

Commit 8559af1

Browse files
author
vikasrohit
authored
Merge pull request #244 from topcoder-platform/feature/org-config-final-fixes
Feature/org config final fixes
2 parents a466252 + 3a0db80 commit 8559af1

File tree

6 files changed

+410
-114
lines changed

6 files changed

+410
-114
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.

postman.json

Lines changed: 93 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"info": {
3-
"_postman_id": "e810fc27-5518-4cc5-8f90-6b1423c6b0b4",
3+
"_postman_id": "d9f6cae1-30c2-4c85-96c3-428b1f2fc08d",
44
"name": "tc-project-service",
55
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
66
},
@@ -3303,173 +3303,209 @@
33033303
},
33043304
{
33053305
"name": "Organization Config",
3306-
"description": "",
33073306
"item": [
33083307
{
33093308
"name": "Create organization config",
33103309
"request": {
3311-
"url": "{{api-url}}/v4/projects/metadata/orgConfig",
33123310
"method": "POST",
33133311
"header": [
33143312
{
33153313
"key": "Content-Type",
3316-
"value": "application/json",
3317-
"description": ""
3314+
"value": "application/json"
33183315
},
33193316
{
33203317
"key": "Authorization",
3321-
"value": "Bearer {{jwt-token}}",
3322-
"description": ""
3318+
"value": "Bearer {{jwt-token}}"
33233319
}
33243320
],
33253321
"body": {
33263322
"mode": "raw",
33273323
"raw": "{\r\n \"param\":{\r\n \"orgId\": \"20000013\",\r\n \"configName\": \"project_catalog_url\",\r\n \"configValue\": \"/projects/1\"\r\n }\r\n}"
33283324
},
3329-
"description": ""
3325+
"url": {
3326+
"raw": "{{api-url}}/v4/projects/metadata/orgConfig",
3327+
"host": [
3328+
"{{api-url}}"
3329+
],
3330+
"path": [
3331+
"v4",
3332+
"projects",
3333+
"metadata",
3334+
"orgConfig"
3335+
]
3336+
}
33303337
},
33313338
"response": []
33323339
},
33333340
{
3334-
"name": "List organization config",
3341+
"name": "List organization config - error without filter",
33353342
"request": {
3336-
"url": "{{api-url}}/v4/projects/metadata/orgConfig",
33373343
"method": "GET",
33383344
"header": [
33393345
{
33403346
"key": "Content-Type",
3341-
"value": "application/json",
3342-
"description": ""
3347+
"value": "application/json"
33433348
},
33443349
{
33453350
"key": "Authorization",
3346-
"value": "Bearer {{jwt-token}}",
3347-
"description": ""
3351+
"value": "Bearer {{jwt-token}}"
33483352
}
33493353
],
33503354
"body": {
33513355
"mode": "raw",
33523356
"raw": ""
33533357
},
3354-
"description": ""
3355-
},
3356-
"response": []
3357-
},
3358-
{
3359-
"name": "List organization config - filter",
3360-
"request": {
33613358
"url": {
3362-
"raw": "{{api-url}}/v4/projects/metadata/orgConfig?filter=orgId=in(20000010,20000013,20000015)%26configName%3Dproject_catalog_url",
3359+
"raw": "{{api-url}}/v4/projects/metadata/orgConfig",
33633360
"host": [
33643361
"{{api-url}}"
33653362
],
33663363
"path": [
33673364
"v4",
3365+
"projects",
3366+
"metadata",
33683367
"orgConfig"
3369-
],
3370-
"query": [
3371-
{
3372-
"key": "filter",
3373-
"value": "orgId=in(20000010,20000013,20000015)%26configName%3Dproject_catalog_url",
3374-
"equals": true,
3375-
"description": ""
3376-
}
3377-
],
3378-
"variable": []
3379-
},
3368+
]
3369+
}
3370+
},
3371+
"response": []
3372+
},
3373+
{
3374+
"name": "List organization config - filter",
3375+
"request": {
33803376
"method": "GET",
33813377
"header": [
33823378
{
33833379
"key": "Content-Type",
3384-
"value": "application/json",
3385-
"description": ""
3380+
"value": "application/json"
33863381
},
33873382
{
33883383
"key": "Authorization",
3389-
"value": "Bearer {{jwt-token}}",
3390-
"description": ""
3384+
"value": "Bearer {{jwt-token}}"
33913385
}
33923386
],
33933387
"body": {
33943388
"mode": "raw",
33953389
"raw": ""
33963390
},
3397-
"description": ""
3391+
"url": {
3392+
"raw": "{{api-url}}/v4/orgConfig?filter=orgId=in(20000010,20000013,20000015)%26configName%3Dproject_catalog_url",
3393+
"host": [
3394+
"{{api-url}}"
3395+
],
3396+
"path": [
3397+
"v4",
3398+
"orgConfig"
3399+
],
3400+
"query": [
3401+
{
3402+
"key": "filter",
3403+
"value": "orgId=in(20000010,20000013,20000015)%26configName%3Dproject_catalog_url"
3404+
}
3405+
]
3406+
}
33983407
},
33993408
"response": []
34003409
},
34013410
{
34023411
"name": "Get organization config",
34033412
"request": {
3404-
"url": "{{api-url}}/v4/projects/metadata/orgConfig/1",
34053413
"method": "GET",
34063414
"header": [
34073415
{
34083416
"key": "Content-Type",
3409-
"value": "application/json",
3410-
"description": ""
3417+
"value": "application/json"
34113418
},
34123419
{
34133420
"key": "Authorization",
3414-
"value": "Bearer {{jwt-token}}",
3415-
"description": ""
3421+
"value": "Bearer {{jwt-token}}"
34163422
}
34173423
],
34183424
"body": {
34193425
"mode": "raw",
34203426
"raw": ""
34213427
},
3422-
"description": ""
3428+
"url": {
3429+
"raw": "{{api-url}}/v4/projects/metadata/orgConfig/1",
3430+
"host": [
3431+
"{{api-url}}"
3432+
],
3433+
"path": [
3434+
"v4",
3435+
"projects",
3436+
"metadata",
3437+
"orgConfig",
3438+
"1"
3439+
]
3440+
}
34233441
},
34243442
"response": []
34253443
},
34263444
{
34273445
"name": "Update organization config",
34283446
"request": {
3429-
"url": "{{api-url}}/v4/projects/metadata/orgConfig/1",
34303447
"method": "PATCH",
34313448
"header": [
34323449
{
34333450
"key": "Content-Type",
3434-
"value": "application/json",
3435-
"description": ""
3451+
"value": "application/json"
34363452
},
34373453
{
34383454
"key": "Authorization",
3439-
"value": "Bearer {{jwt-token}}",
3440-
"description": ""
3455+
"value": "Bearer {{jwt-token}}"
34413456
}
34423457
],
34433458
"body": {
34443459
"mode": "raw",
34453460
"raw": "{\r\n \"param\":{\r\n \"configName\": \"project_catalog_url\"\r\n }\r\n}"
34463461
},
3447-
"description": ""
3462+
"url": {
3463+
"raw": "{{api-url}}/v4/projects/metadata/orgConfig/1",
3464+
"host": [
3465+
"{{api-url}}"
3466+
],
3467+
"path": [
3468+
"v4",
3469+
"projects",
3470+
"metadata",
3471+
"orgConfig",
3472+
"1"
3473+
]
3474+
}
34483475
},
34493476
"response": []
34503477
},
34513478
{
34523479
"name": "Delete organization config",
34533480
"request": {
3454-
"url": "{{api-url}}/v4/projects/metadata/orgConfig/1",
34553481
"method": "DELETE",
34563482
"header": [
34573483
{
34583484
"key": "Content-Type",
3459-
"value": "application/json",
3460-
"description": ""
3485+
"value": "application/json"
34613486
},
34623487
{
34633488
"key": "Authorization",
3464-
"value": "Bearer {{jwt-token}}",
3465-
"description": ""
3489+
"value": "Bearer {{jwt-token}}"
34663490
}
34673491
],
34683492
"body": {
34693493
"mode": "raw",
34703494
"raw": ""
34713495
},
3472-
"description": ""
3496+
"url": {
3497+
"raw": "{{api-url}}/v4/projects/metadata/orgConfig/1",
3498+
"host": [
3499+
"{{api-url}}"
3500+
],
3501+
"path": [
3502+
"v4",
3503+
"projects",
3504+
"metadata",
3505+
"orgConfig",
3506+
"1"
3507+
]
3508+
}
34733509
},
34743510
"response": []
34753511
}
@@ -5184,4 +5220,4 @@
51845220
]
51855221
}
51865222
]
5187-
}
5223+
}

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)