Skip to content

Commit

Permalink
Merge pull request #25 from holidayextras/depsVersionUpForNode16
Browse files Browse the repository at this point in the history
Update to node 16 and hapi 21
  • Loading branch information
putvande authored May 3, 2023
2 parents c93edff + f7e8b54 commit 2bd5b76
Show file tree
Hide file tree
Showing 16 changed files with 8,087 additions and 3,134 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8
16
2 changes: 1 addition & 1 deletion lib/buildReject.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'
module.exports = function (error, context) {
return {
error: error,
error,
origin: 'pluginHarvest',
data: context
}
Expand Down
12 changes: 6 additions & 6 deletions lib/getBasket.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use strict'

var _ = require('lodash')
var Q = require('q')
var buildReject = require('./buildReject')
const _ = require('lodash')
const Q = require('q')
const buildReject = require('./buildReject')

module.exports = function GetBasket (harvest, harvestDb, options) {
var deferred = Q.defer()
const deferred = Q.defer()

try {
if (!options) {
Expand All @@ -27,12 +27,12 @@ module.exports = function GetBasket (harvest, harvestDb, options) {
// ******************************************************************************************
harvestDb.get(options.id, function (error, storedBasket) {
if (error) {
deferred.reject(buildReject(error, { code: 'H001', options: options }))
deferred.reject(buildReject(error, { code: 'H001', options }))
} else {
try {
deferred.resolve(harvest.getSharedBasket(storedBasket, options.tag))
} catch (harvestError) {
deferred.reject(buildReject(harvestError, { code: 'H002', options: options }))
deferred.reject(buildReject(harvestError, { code: 'H002', options }))
}
}
})
Expand Down
18 changes: 9 additions & 9 deletions lib/getBaskets.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
'use strict'

var _ = require('lodash')
var Q = require('q')
var buildReject = require('./buildReject')
const _ = require('lodash')
const Q = require('q')
const buildReject = require('./buildReject')

module.exports = function GetBaskets (harvest, harvestDb, options) {
var deferred = Q.defer()
var designDocument
var view
var params = {}
const deferred = Q.defer()
let designDocument
let view
const params = {}

// Used if we don't pass in timestamps for design documents that need them.
var currentTime = (new Date()).toISOString()
const currentTime = (new Date()).toISOString()

try {
if (!options) {
Expand Down Expand Up @@ -55,7 +55,7 @@ module.exports = function GetBaskets (harvest, harvestDb, options) {
// 2. Convert each to a shared basket structure based on the requested tag
// ******************************************************************************************
harvestDb.view(designDocument, view, params, function (error, document) {
var sharedBaskets = []
const sharedBaskets = []
if (error) {
deferred.reject(buildReject(error, options))
} else {
Expand Down
28 changes: 14 additions & 14 deletions lib/pluginHarvest.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
'use strict'

var getBasket = require('./getBasket')
var getBaskets = require('./getBaskets')
var postBasket = require('./postBasket')
var putBasket = require('./putBasket')
var postBasketVersion = require('./postBasketVersion')
var url = require('url')
const getBasket = require('./getBasket')
const getBaskets = require('./getBaskets')
const postBasket = require('./postBasket')
const putBasket = require('./putBasket')
const postBasketVersion = require('./postBasketVersion')
const url = require('url')

var Harvest = require('harvest')
const Harvest = require('harvest')

const register = function (server, pluginOptions) {
var config = server.methods.getService('harvest')
const config = server.methods.getService('harvest')

// If we have authentication credentials then lets do some http basic auth
if (config.authentication) {
config.auth = config.authentication.username + ':' + config.authentication.password
}

// Register the Harvest Database using url format to set up the connection details
var Nano = require('nano')(url.format(config))
var harvestDb = Nano.db.use('harvest')
const Nano = require('nano')(url.format(config))
const harvestDb = Nano.db.use('harvest')

server.expose('getBasket', function (options) {
return getBasket(Harvest, harvestDb, options)
Expand All @@ -35,9 +35,9 @@ const register = function (server, pluginOptions) {

server.expose('putBasket', function (options) {
return putBasket(Harvest, harvestDb, options)
.fail(() => {
return postBasket(Harvest, harvestDb, options)
})
.fail(() => {
return postBasket(Harvest, harvestDb, options)
})
})

server.expose('postBasketVersion', function (options) {
Expand All @@ -46,7 +46,7 @@ const register = function (server, pluginOptions) {
}

const pkg = require('../package.json')
const {version, name} = pkg
const { version, name } = pkg

exports.plugin = {
register,
Expand Down
14 changes: 7 additions & 7 deletions lib/postBasket.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use strict'

var _ = require('lodash')
var Q = require('q')
var buildReject = require('./buildReject')
const _ = require('lodash')
const Q = require('q')
const buildReject = require('./buildReject')

module.exports = function PostBasket (harvest, harvestDb, options) {
var deferred = Q.defer()
const deferred = Q.defer()

try {
if (!options) {
Expand All @@ -23,7 +23,7 @@ module.exports = function PostBasket (harvest, harvestDb, options) {
// 3. Get a shared basket to pass back
// ******************************************************************************************

var requestedBasket = {
const requestedBasket = {
tag: options.tag,
data: options.data
}
Expand All @@ -33,14 +33,14 @@ module.exports = function PostBasket (harvest, harvestDb, options) {
requestedBasket.version = options.version
}

var storedBasket = harvest.createBasket(requestedBasket)
const storedBasket = harvest.createBasket(requestedBasket)
harvestDb.insert(storedBasket, function (error, document) {
if (error) {
deferred.reject(buildReject(error, options))
} else {
try {
// Nano just replies back with ok:true so lets smash the id and rev onto the document that we asked to be stored.
var persistedBasket = {
const persistedBasket = {
_id: document.id,
_rev: document.rev
}
Expand Down
10 changes: 5 additions & 5 deletions lib/postBasketVersion.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use strict'

var _ = require('lodash')
var Q = require('q')
var buildReject = require('./buildReject')
const _ = require('lodash')
const Q = require('q')
const buildReject = require('./buildReject')

module.exports = function PostBasketVersion (harvest, harvestDb, options) {
var deferred = Q.defer()
const deferred = Q.defer()

try {
if (!options) {
Expand All @@ -25,7 +25,7 @@ module.exports = function PostBasketVersion (harvest, harvestDb, options) {
}

// The shared basket is in effect all the options passed in but lets keep both names for consistency for both our Hapi plugins and Harvest
var sharedBasket = options
const sharedBasket = options

// *****************************************************************************************
// Interaction Flow
Expand Down
10 changes: 5 additions & 5 deletions lib/putBasket.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use strict'

var _ = require('lodash')
var Q = require('q')
var buildReject = require('./buildReject')
const _ = require('lodash')
const Q = require('q')
const buildReject = require('./buildReject')

module.exports = function PutBasket (harvest, harvestDb, options) {
var deferred = Q.defer()
const deferred = Q.defer()

try {
if (!options) {
Expand All @@ -21,7 +21,7 @@ module.exports = function PutBasket (harvest, harvestDb, options) {
}

// The shared basket is in effect all the options passed in but lets keep both names for consistency for both our Hapi plugins and Harvest
var sharedBasket = options
const sharedBasket = options

// *****************************************************************************************
// Interaction Flow
Expand Down
Loading

0 comments on commit 2bd5b76

Please sign in to comment.