Skip to content

Commit

Permalink
Merge pull request #64 from joyja/auditFix
Browse files Browse the repository at this point in the history
fixed npm audit vulnerabilities
  • Loading branch information
joyja committed Sep 24, 2020
2 parents c10d05a + 0ec188f commit cbe6045
Show file tree
Hide file tree
Showing 26 changed files with 138 additions and 129 deletions.
4 changes: 2 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ module.exports = {
watchPlugins: [
require.resolve('jest-watch-select-projects'),
require.resolve('jest-watch-typeahead/filename'),
require.resolve('jest-watch-typeahead/testname')
]
require.resolve('jest-watch-typeahead/testname'),
],
}
31 changes: 20 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"express": "^4.17.1",
"graphql-yoga": "^1.18.3",
"jsonwebtoken": "^8.5.1",
"lodash": "^4.17.15",
"lodash": "^4.17.20",
"make-promises-safe": "^5.1.0",
"modbus-serial": "^8.0.1",
"mqtt": "^4.0.1",
Expand Down
32 changes: 16 additions & 16 deletions src/__tests__/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ describe(`User:`, () => {
const context = {
request: {
headers: {
authorization: `Bearer ${token}`
}
}
authorization: `Bearer ${token}`,
},
},
}
const user = await User.getUserFromContext(context)
expect(user.username).toBe(`admin`)
Expand All @@ -70,9 +70,9 @@ describe(`User:`, () => {
const context = {
connection: {
context: {
Authorization: `Bearer ${token}`
}
}
Authorization: `Bearer ${token}`,
},
},
}
const user = await User.getUserFromContext(context)
expect(user.username).toBe(`admin`)
Expand Down Expand Up @@ -106,9 +106,9 @@ describe(`User:`, () => {
const context = {
request: {
headers: {
authorization: `Bearer ${token}`
}
}
authorization: `Bearer ${token}`,
},
},
}
expect(
await User.changePassword(
Expand All @@ -123,26 +123,26 @@ describe(`User:`, () => {
const context = {
request: {
headers: {
authorization: `Bearer ${token}`
}
}
authorization: `Bearer ${token}`,
},
},
}
const user = await User.changePassword(context, 'password', 'newPassword')
expect(await bcrypt.compare(`newPassword`, user.password)).toBe(true)
})
test(`getUserFromContext without valid token returns an error.`, async () => {
const token = jwt.sign(
{
userId: 123
userId: 123,
},
`aSecret`
)
const context = {
request: {
headers: {
authorization: `Bearer ${token}`
}
}
authorization: `Bearer ${token}`,
},
},
}
expect(
await User.getUserFromContext(context).catch((e) => e)
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const {
ScanClass,
Device,
Service,
MqttSource
MqttSource,
} = require('../relations')
const fromUnixTime = require('date-fns/fromUnixTime')

Expand Down
6 changes: 3 additions & 3 deletions src/database/__tests__/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ TestModel.table = 'test'
describe(`executeQuery:`, () => {
test('Called with undefined params calls db.all with empty object.', () => {
const mockdb = {
all: jest.fn((sql, params, callback) => callback())
all: jest.fn((sql, params, callback) => callback()),
}
const sql = ``
const params = undefined
Expand All @@ -54,7 +54,7 @@ describe(`executeQuery:`, () => {

test('executeUpdate: Called with undefined params calls db.run with empty object.', () => {
const mockdb = {
run: jest.fn((sql, params, callback) => callback())
run: jest.fn((sql, params, callback) => callback()),
}
const sql = ``
const params = undefined
Expand Down Expand Up @@ -165,7 +165,7 @@ describe(`Model:`, () => {
const result = await new Promise((resolve, reject) => {
return db.run(
`INSERT INTO test (testField) VALUES ("testValue")`,
function(error) {
function (error) {
if (error) {
reject(error)
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/database/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const model = require('./model')

module.exports = {
...model
...model,
}
2 changes: 1 addition & 1 deletion src/device/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ module.exports = {
Modbus,
ModbusSource,
EthernetIP,
EthernetIPSource
EthernetIPSource,
}
2 changes: 1 addition & 1 deletion src/resolvers/DeviceConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ async function __resolveType(parent, args, context, info) {
}

module.exports = {
__resolveType
__resolveType,
}
4 changes: 2 additions & 2 deletions src/resolvers/MqttPrimaryHost.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const recordCount = async function(parent, args, context, info) {
const recordCount = async function (parent, args, context, info) {
return parent.getRecordCount()
}

module.exports = {
recordCount
recordCount,
}
2 changes: 1 addition & 1 deletion src/resolvers/Mutation/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ async function changePassword(root, args, context, info) {

module.exports = {
login,
changePassword
changePassword,
}
2 changes: 1 addition & 1 deletion src/resolvers/Mutation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ module.exports = {
...auth,
...tag,
...device,
...service
...service,
}
2 changes: 1 addition & 1 deletion src/resolvers/Mutation/service/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const mqtt = require('./mqtt')

module.exports = {
...mqtt
...mqtt,
}
2 changes: 1 addition & 1 deletion src/resolvers/Query/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ async function devices(root, args, context, info) {
}

module.exports = {
devices
devices,
}
2 changes: 1 addition & 1 deletion src/resolvers/Query/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ module.exports = {
...user,
...tag,
...device,
...service
...service,
}
2 changes: 1 addition & 1 deletion src/resolvers/Query/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ async function services(root, args, context, info) {
}

module.exports = {
services
services,
}
2 changes: 1 addition & 1 deletion src/resolvers/Query/tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ async function scanClasses(root, args, context, info) {

module.exports = {
tags,
scanClasses
scanClasses,
}
2 changes: 1 addition & 1 deletion src/resolvers/Query/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ async function user(root, args, context, info) {
}

module.exports = {
user
user,
}
2 changes: 1 addition & 1 deletion src/resolvers/Source.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ async function __resolveType(parent, args, context, info) {
}

module.exports = {
__resolveType
__resolveType,
}
4 changes: 2 additions & 2 deletions src/resolvers/Subscription/device.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const deviceUpdate = {
subscribe: (root, args, context) => {
return context.pubsub.asyncIterator(`deviceUpdate`)
}
},
}

module.exports = {
deviceUpdate
deviceUpdate,
}
2 changes: 1 addition & 1 deletion src/resolvers/Subscription/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ const service = require('./service')
module.exports = {
...device,
...service,
...tag
...tag,
}
Loading

0 comments on commit cbe6045

Please sign in to comment.