Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 4a34548

Browse files
Merge branch 'Issue_639' into develop
2 parents a84d310 + 69ceaab commit 4a34548

File tree

4 files changed

+172
-58
lines changed

4 files changed

+172
-58
lines changed

docs/swagger.yaml

Lines changed: 124 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,73 @@ tags:
1212
description: "Template files to serve as reference for multitude of tasks"
1313
- name: "uploads"
1414
description: "Upload files for batch processing"
15-
- name: "skills"
16-
description: "Skills endpoints"
17-
externalDocs:
18-
description: "Proxy to EMSI skills"
19-
url: "https://api.emsidata.com/apis/skills-classification#get-search-for-skills"
2015
schemes:
2116
- "https"
2217
- "http"
2318
paths:
2419
/templates:
20+
get:
21+
summary: "Get all templates"
22+
description: |
23+
"Return all templates. You can filter by the name"
24+
tags:
25+
- "templates"
26+
operationId: "getTemplates"
27+
parameters:
28+
- name: "name"
29+
in: "query"
30+
description: "The name of templates"
31+
required: false
32+
type: "string"
33+
responses:
34+
"200":
35+
description: "Success"
36+
schema:
37+
type: array
38+
items:
39+
$ref: '#/definitions/Template'
40+
"400":
41+
$ref: "#/definitions/BadRequest"
42+
"401":
43+
$ref: "#/definitions/Unauthorized"
44+
"403":
45+
$ref: "#/definitions/Forbidden"
46+
"404":
47+
$ref: "#/definitions/NotFound"
48+
"500":
49+
$ref: "#/definitions/ServerError"
50+
security:
51+
- api_key: []
52+
x-swagger-router-controller: "Templates"
53+
54+
head:
55+
summary: "Get only status code for fetching all templates"
56+
description: "Equivalent to GET /templates, but returns only status codes"
57+
tags:
58+
- "templates"
59+
operationId: "headTemplates"
60+
parameters:
61+
- name: "name"
62+
in: "query"
63+
description: "The name of templates"
64+
required: false
65+
type: "string"
66+
responses:
67+
"200":
68+
description: "Success"
69+
"400":
70+
$ref: "#/definitions/BadRequest"
71+
"401":
72+
$ref: "#/definitions/Unauthorized"
73+
"403":
74+
$ref: "#/definitions/Forbidden"
75+
"404":
76+
$ref: "#/definitions/NotFound"
77+
"500":
78+
$ref: "#/definitions/ServerError"
79+
security:
80+
- api_key: []
81+
x-swagger-router-controller: "Templates"
2582
post:
2683
tags:
2784
- "templates"
@@ -89,6 +146,29 @@ paths:
89146
security:
90147
- api_key: []
91148
x-swagger-router-controller: "Templates"
149+
head:
150+
tags:
151+
- "templates"
152+
summary: "Get only status code for getting template"
153+
description: "Equivalent to GET /templates/:id, but returns only status codes"
154+
operationId: "headTemplateById"
155+
produces:
156+
- "application/json"
157+
parameters: []
158+
responses:
159+
"200":
160+
description: "Success"
161+
"401":
162+
$ref: "#/definitions/Unauthorized"
163+
"403":
164+
$ref: "#/definitions/Forbidden"
165+
"404":
166+
$ref: "#/definitions/NotFound"
167+
"500":
168+
$ref: "#/definitions/ServerError"
169+
security:
170+
- api_key: []
171+
x-swagger-router-controller: "Templates"
92172
/uploads:
93173
get:
94174
summary: "Get all uploads"
@@ -104,6 +184,11 @@ paths:
104184
required: false
105185
type: "string"
106186
default: "today's value"
187+
- name: "organizationId"
188+
in: "query"
189+
description: "The organization id to associate with"
190+
required: true
191+
type: "string"
107192
responses:
108193
"200":
109194
description: "Success"
@@ -121,6 +206,9 @@ paths:
121206
$ref: "#/definitions/NotFound"
122207
"500":
123208
$ref: "#/definitions/ServerError"
209+
security:
210+
- api_key: []
211+
x-swagger-router-controller: "Uploads"
124212

125213
head:
126214
summary: "Get only status code for fetching all uploads"
@@ -135,6 +223,11 @@ paths:
135223
required: false
136224
type: "string"
137225
default: "today's value"
226+
- name: "organizationId"
227+
in: "query"
228+
description: "The organization id to associate with"
229+
required: true
230+
type: "string"
138231
responses:
139232
"200":
140233
description: "Success"
@@ -148,6 +241,9 @@ paths:
148241
$ref: "#/definitions/NotFound"
149242
"500":
150243
$ref: "#/definitions/ServerError"
244+
security:
245+
- api_key: []
246+
x-swagger-router-controller: "Uploads"
151247

152248
post:
153249
tags:
@@ -217,6 +313,29 @@ paths:
217313
security:
218314
- api_key: []
219315
x-swagger-router-controller: "Uploads"
316+
head:
317+
tags:
318+
- "uploads"
319+
summary: "Get only status code for getting details of an upload"
320+
description: "Equivalent to GET /uploads/:id, but returns only status codes"
321+
operationId: "headUploadById"
322+
produces:
323+
- "application/json"
324+
parameters: []
325+
responses:
326+
"200":
327+
description: "Success"
328+
"401":
329+
$ref: "#/definitions/Unauthorized"
330+
"403":
331+
$ref: "#/definitions/Forbidden"
332+
"404":
333+
$ref: "#/definitions/NotFound"
334+
"500":
335+
$ref: "#/definitions/ServerError"
336+
security:
337+
- api_key: []
338+
x-swagger-router-controller: "Uploads"
220339
patch:
221340
tags:
222341
- "uploads"
@@ -254,37 +373,6 @@ paths:
254373
security:
255374
- api_key: []
256375
x-swagger-router-controller: "Uploads"
257-
/skills:
258-
get:
259-
tags:
260-
- "skills"
261-
summary: "Search for skills by name using the q query parameter"
262-
description: "Responds with the skills search result. Proxy api to EMSI"
263-
operationId: "getSkills"
264-
produces:
265-
- "application/json"
266-
parameters:
267-
- name: "q"
268-
in: "query"
269-
description: "The skill to search for. All special characters must be URL encoded, eg. \"C++ Progr\" should be encoded \"C%2B%2B%20Progr\""
270-
required: false
271-
type: "string"
272-
responses:
273-
"200":
274-
description: "Success"
275-
schema:
276-
$ref: "#/definitions/Skill"
277-
"401":
278-
$ref: "#/definitions/Unauthorized"
279-
"403":
280-
$ref: "#/definitions/Forbidden"
281-
"404":
282-
$ref: "#/definitions/NotFound"
283-
"500":
284-
$ref: "#/definitions/ServerError"
285-
security:
286-
- api_key: []
287-
x-swagger-router-controller: "Skills"
288376
securityDefinitions:
289377
api_key:
290378
type: "apiKey"
@@ -335,26 +423,6 @@ definitions:
335423
type: "string"
336424
description: "The organization id to associate new users with"
337425
- $ref: "#/definitions/AuditFields"
338-
Skill:
339-
allOf:
340-
- type: "object"
341-
properties:
342-
skills:
343-
type: "array"
344-
items:
345-
properties:
346-
type:
347-
type: string
348-
description: The skill type
349-
example: 'Hard Skill'
350-
id:
351-
type: string
352-
description: The skill id
353-
example: 'KS1200364C9C1LK3V5Q1'
354-
name:
355-
type: string
356-
description: The skill name
357-
example: 'C (Programming Language)'
358426
AuditFields:
359427
type: "object"
360428
required:

src/controllers/TemplateController.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,18 @@ async function getEntity (req, res) {
2323
res.send(result)
2424
}
2525

26+
/**
27+
* Get template
28+
* @param {Object} req the request
29+
* @param {Object} res the response
30+
*/
31+
async function getEntities (req, res) {
32+
const result = await service.getEntities(req.query)
33+
res.send(result)
34+
}
35+
2636
module.exports = {
2737
uploadEntity,
28-
getEntity
38+
getEntity,
39+
getEntities
2940
}

src/routes.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ module.exports = {
6262
auth: 'jwt',
6363
access: constants.AdminUser,
6464
scopes: [constants.Scopes.CreateTemplate, constants.Scopes.AllTemplate]
65+
},
66+
get: {
67+
controller: 'TemplateController',
68+
method: 'getEntities',
69+
auth: 'jwt',
70+
access: constants.AdminUser,
71+
scopes: [constants.Scopes.GetTemplate, constants.Scopes.AllTemplate]
6572
}
6673
},
6774
'/templates/:id': {

src/services/TemplateService.js

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,37 @@ uploadEntity.schema = {
5757
}).required()
5858
}
5959

60+
/**
61+
* Returns all templates (filtered by created date)
62+
* @param {Object} query the filter query
63+
* @returns {Object} the list of templates
64+
*/
65+
async function getEntities (query) {
66+
const filter = {}
67+
if (query.name) {
68+
filter.name = { contains: query.name }
69+
}
70+
const templates = await helper.getAll(config.AMAZON.DYNAMODB_TEMPLATE_TABLE, filter)
71+
const res = _.map(templates, (template) => {
72+
template = _.extend(
73+
_.omit(_.pickBy(template, _.isString), 'objectKey'), { url: helper.generateS3Url(template.objectKey) }
74+
)
75+
return template
76+
})
77+
return res
78+
}
79+
80+
getEntities.schema = {
81+
query: Joi.object().keys({
82+
from: Joi.string(),
83+
name: Joi.string()
84+
})
85+
}
86+
6087
module.exports = {
6188
getEntity,
62-
uploadEntity
89+
uploadEntity,
90+
getEntities
6391
}
6492

6593
logger.buildService(module.exports)

0 commit comments

Comments
 (0)