Skip to content

Commit

Permalink
FSR-1055 | upgrade Node 18 and dependencies (#34)
Browse files Browse the repository at this point in the history
* update node on cap-xml

* first push

* removed unnessesary try catch

* replacing @hapi/joi with joi

* joi

* improving test coverage

* updated tests to use Promis.resolve

* removing a file
  • Loading branch information
nikiwycherley authored Nov 28, 2023
1 parent f9315f7 commit b7fde47
Show file tree
Hide file tree
Showing 10 changed files with 6,830 additions and 11,044 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Install nodejs
uses: actions/setup-node@v1
with:
node-version: "16.x"
node-version: "18.x"

- name: Install node dependencies
run: npm ci
Expand Down
2 changes: 1 addition & 1 deletion config/schema.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const Joi = require('@hapi/joi')
const Joi = require('joi')

module.exports = Joi.object({
aws: Joi.object().required().keys({
Expand Down
2 changes: 1 addition & 1 deletion lib/functions/getMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports.getMessage = async (event) => {

const ret = await service.getMessage(event.pathParameters.id)

if (!ret || !ret.rows || !Array.isArray(ret.rows) || ret.rows.length < 1 || !ret.rows[0].getmessage) {
if (!ret?.rows?.[0]?.getmessage) {
console.log('No message found for ' + event.pathParameters.id)
throw new Error('No message found')
}
Expand Down
4 changes: 2 additions & 2 deletions lib/functions/processMessage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict'

const xml2js = require('xml2js')
const moment = require('moment')
const AWSConfig = require('../../config/config.json').aws
const service = require('../helpers/service')
Expand All @@ -20,9 +19,10 @@ module.exports.processMessage = async (event) => {

// Add in the references field
const xmlMessage = event.bodyXml.replace('</scope>', '</scope>\n<references></references>')
const parseString = require('xml2js').parseString

const xmlResult = await new Promise((resolve, reject) => {
xml2js.parseString(xmlMessage, (err, value) => {
parseString(xmlMessage, function (err, value) {
if (err) return reject(err)
resolve(value)
})
Expand Down
6 changes: 3 additions & 3 deletions lib/helpers/schemas.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const Joi = require('@hapi/joi')
const Joi = require('joi')

const getMessageEventSchema = Joi.object({
pathParameters: Joi.object().required().keys({
Expand All @@ -12,6 +12,6 @@ const processMessageEventSchema = Joi.object({
})

module.exports = {
getMessageEventSchema: getMessageEventSchema,
processMessageEventSchema: processMessageEventSchema
getMessageEventSchema,
processMessageEventSchema
}
Loading

0 comments on commit b7fde47

Please sign in to comment.