Skip to content

Commit

Permalink
Merge branch 'hotfix/2.7.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffsampaio committed Oct 21, 2021
2 parents 285f332 + 5ea5877 commit 7dcbd3e
Show file tree
Hide file tree
Showing 78 changed files with 1,262 additions and 1,490 deletions.
1,803 changes: 742 additions & 1,061 deletions package-lock.json

Large diffs are not rendered by default.

33 changes: 16 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,37 +57,36 @@
"express": "^4.17.1",
"helmet": "3.23.3",
"http-status-codes": "^2.1.4",
"inversify": "^5.1.1",
"inversify-express-utils": "^6.3.2",
"inversify": "^6.0.1",
"inversify-express-utils": "^6.4.3",
"moment": "^2.29.1",
"mongoose": "^5.12.13",
"mongoose": "^6.0.11",
"morgan": "^1.10.0",
"query-strings-parser": "^2.1.7",
"query-strings-parser": "^2.1.8",
"reflect-metadata": "^0.1.13",
"swagger-ui-express": "^4.1.6",
"winston": "^3.3.3",
"winston-daily-rotate-file": "^4.5.5"
},
"devDependencies": {
"@types/body-parser": "^1.19.0",
"@types/chai": "^4.2.18",
"@types/express": "^4.17.12",
"@types/mocha": "^8.2.2",
"@types/morgan": "^1.9.2",
"@types/swagger-ui-express": "^4.1.2",
"@types/body-parser": "^1.19.1",
"@types/chai": "^4.2.22",
"@types/express": "^4.17.13",
"@types/mocha": "^9.0.0",
"@types/morgan": "^1.9.3",
"@types/swagger-ui-express": "^4.1.3",
"chai": "^4.3.4",
"gulp": "^4.0.2",
"gulp-nodemon": "^2.5.0",
"gulp-tslint": "^8.1.4",
"gulp-typescript": "^6.0.0-alpha.1",
"mocha": "^9.0.0",
"mocha": "^9.1.3",
"nyc": "^15.1.0",
"sinon": "^7.5.0",
"sinon-mongoose": "^2.3.0",
"supertest": "^6.1.3",
"ts-node": "^10.0.0",
"sinon": "^11.1.2",
"supertest": "^6.1.6",
"ts-node": "^10.3.1",
"tslint": "^6.1.3",
"typedoc": "^0.20.36",
"typescript": "^4.3.2"
"typedoc": "^0.22.6",
"typescript": "^4.4.4"
}
}
2 changes: 1 addition & 1 deletion server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function initListener(): void {
process.on('SIGINT', async () => {
try {
await backgroundServices.stopServices()
} catch (err) {
} catch (err: any) {
logger.error(`There was an error stopping all background services. ${err.message}`)
} finally {
logger.debug('Background services successfully closed...')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class CreatePhysicalActivityValidator {

try {
CreateActivityValidator.validate(activity)
} catch (err) {
} catch (err: any) {
if (err.message !== 'REQUIRED_FIELDS') throw err
fields.push(err.description.split(','))
}
Expand Down
2 changes: 1 addition & 1 deletion src/application/domain/validator/create.sleep.validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class CreateSleepValidator {
try {
// Validate common attributes of the activity.
CreateActivityValidator.validate(sleep)
} catch (err) {
} catch (err: any) {
if (err.message !== 'REQUIRED_FIELDS') throw err
fields.push(err.description.split(','))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class PhysicalActivitySyncEventHandler implements IIntegrationEventHandle
try {
await this.updateOrCreate(event, item)
countSuccess++
} catch (err) {
} catch (err: any) {
this._logger.warn(`An error occurred while attempting `
.concat(`perform the operation with the ${event.event_name} name event. ${err.message}`)
.concat(err.description ? ' ' + err.description : ''))
Expand All @@ -42,7 +42,7 @@ export class PhysicalActivitySyncEventHandler implements IIntegrationEventHandle
this._logger.info(
`Action for event ${event.event_name} associated with patient with ID: ${event.physical_activity.user_id}`
.concat('successfully performed!'))
} catch (err) {
} catch (err: any) {
this._logger.error(`An error occurred while attempting `
.concat(`perform the operation with the ${event.event_name} name event. ${err.message}`)
.concat(err.description ? ' ' + err.description : ''))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class SleepSyncEventHandler implements IIntegrationEventHandler<SleepSync
.concat(err.description ? ' ' + err.description : ''))
})
countSuccess++
} catch (err) {
} catch (err: any) {
this._logger.warn(`An error occurred while attempting `
.concat(`perform the operation with the ${event.event_name} name event. ${err.message}`)
.concat(err.description ? ' ' + err.description : ''))
Expand All @@ -60,7 +60,7 @@ export class SleepSyncEventHandler implements IIntegrationEventHandler<SleepSync
this._logger.info(
`Action for event ${event.event_name} associated with patient with ID: ${event.sleep.user_id}`
.concat(' successfully performed!'))
} catch (err) {
} catch (err: any) {
this._logger.error(`An error occurred while attempting `
.concat(`perform the operation with the ${event.event_name} name event. ${err.message}`)
.concat(err.description ? ' ' + err.description : ''))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class UserDeleteEventHandler implements IIntegrationEventHandler<UserDele
}
this._logger.info(`Action for event ${event.event_name} successfully performed!`)
})
} catch (err) {
} catch (err: any) {
this._logger.error(`An error occurred while attempting `
.concat(`perform the operation with the ${event.event_name} name event. ${err.message}`)
.concat(err.description ? ' ' + err.description : ''))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class WeightSyncEventHandler implements IIntegrationEventHandler<WeightSy
const result: any = await this.updateOrCreate(event, item)
success.push(result)
countSuccess++
} catch (err) {
} catch (err: any) {
this._logger.warn(`An error occurred while attempting `
.concat(`perform the operation with the ${event.event_name} name event. ${err.message}`)
.concat(err.description ? ' ' + err.description : ''))
Expand All @@ -56,7 +56,7 @@ export class WeightSyncEventHandler implements IIntegrationEventHandler<WeightSy
this._logger.info(
`Action for event ${event.event_name} associated with patient with ID: ${event.weight.user_id}`
.concat('successfully performed!'))
} catch (err) {
} catch (err: any) {
this._logger.error(`An error occurred while attempting `
.concat(`perform the operation with the ${event.event_name} name event. ${err.message}`)
.concat(err.description ? ' ' + err.description : ''))
Expand Down
4 changes: 2 additions & 2 deletions src/application/service/measurement.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export class MeasurementService implements IMeasurementService {
const statusSuccess: StatusSuccess<any> = new StatusSuccess<any>(HttpStatus.CREATED, measurement)
statusSuccessArr.push(statusSuccess)
}
} catch (err) {
} catch (err: any) {
let statusCode: number = HttpStatus.INTERNAL_SERVER_ERROR
if (err instanceof ValidationException) statusCode = HttpStatus.BAD_REQUEST
if (err instanceof ConflictException) statusCode = HttpStatus.CONFLICT
Expand Down Expand Up @@ -307,7 +307,7 @@ export class MeasurementService implements IMeasurementService {
}
}
return Promise.resolve()
} catch (err) {
} catch (err: any) {
const patientId: string = data instanceof Array ? data[0].patient_id : data.patient_id
this._logger.error(`Error at publish last measurement from ${patientId}: ${err.message}`)
return Promise.resolve()
Expand Down
2 changes: 1 addition & 1 deletion src/application/service/physical.activity.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class PhysicalActivityService implements IPhysicalActivityService {
const statusSuccess: StatusSuccess<PhysicalActivity> =
new StatusSuccess<PhysicalActivity>(HttpStatus.CREATED, activityResult)
statusSuccessArr.push(statusSuccess)
} catch (err) {
} catch (err: any) {
let statusCode: number = HttpStatus.INTERNAL_SERVER_ERROR
if (err instanceof ValidationException) statusCode = HttpStatus.BAD_REQUEST
if (err instanceof ConflictException) statusCode = HttpStatus.CONFLICT
Expand Down
4 changes: 2 additions & 2 deletions src/application/service/sleep.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class SleepService implements ISleepService {
// Create a StatusSuccess object for the construction of the MultiStatus response.
const statusSuccess: StatusSuccess<Sleep> = new StatusSuccess<Sleep>(HttpStatus.CREATED, sleepResult)
statusSuccessArr.push(statusSuccess)
} catch (err) {
} catch (err: any) {
let statusCode: number = HttpStatus.INTERNAL_SERVER_ERROR
if (err instanceof ValidationException) statusCode = HttpStatus.BAD_REQUEST
if (err instanceof ConflictException) statusCode = HttpStatus.CONFLICT
Expand Down Expand Up @@ -219,7 +219,7 @@ export class SleepService implements ISleepService {
try {
const sleepUp: Sleep = await this._awakeningsTask.calculateAwakenings(sleep)
return Promise.resolve(sleepUp)
} catch (err) {
} catch (err: any) {
this._logger.error(`An error occurred while attempting calculate awakenings `
.concat(`for the sleep with id: ${sleep.id}. ${err.message}`)
.concat(err.description ? ' ' + err.description : ''))
Expand Down
4 changes: 2 additions & 2 deletions src/background/background.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class BackgroundService {

// Open RabbitMQ connection and perform tasks
this._startTasks()
} catch (err) {
} catch (err: any) {
return Promise.reject(new Error(`Error initializing services in background! ${err.message}`))
}
}
Expand All @@ -39,7 +39,7 @@ export class BackgroundService {
try {
await this._mongodb.dispose()
await this._subscribeTask.stop()
} catch (err) {
} catch (err: any) {
return Promise.reject(new Error(`Error stopping MongoDB! ${err.message}`))
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/background/task/publish.event.bus.task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class PublishEventBusTask implements IBackgroundTask {
public async stop(): Promise<void> {
try {
await this._eventBus.dispose()
} catch (err) {
} catch (err: any) {
return Promise.reject(new Error(`Error stopping PublishEventBusTask! ${err.message}`))
}
}
Expand Down Expand Up @@ -58,7 +58,7 @@ export class PublishEventBusTask implements IBackgroundTask {
.concat(`saved event by name ${event.event_name} and ID: ${event.id}`))
})
})
} catch (err) {
} catch (err: any) {
this._logger.error(`Error retrieving saved events: ${err.message}`)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/background/task/subscribe.event.bus.task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class SubscribeEventBusTask implements IBackgroundTask {
public async stop(): Promise<void> {
try {
await this._eventBus.dispose()
} catch (err) {
} catch (err: any) {
return Promise.reject(new Error(`Error stopping SubscribeEventBusTask! ${err.message}`))
}
}
Expand Down
10 changes: 1 addition & 9 deletions src/infrastructure/database/connection.factory.mongodb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@ import { IConnectionFactory, IDBOptions } from '../port/connection.factory.inter

@injectable()
export class ConnectionFactoryMongodb implements IConnectionFactory {
private _options = {
useNewUrlParser: true,
useCreateIndex: true,
useFindAndModify: false,
useUnifiedTopology: true
}

/**
* Create instance of MongoDB.
*
Expand All @@ -20,9 +13,8 @@ export class ConnectionFactoryMongodb implements IConnectionFactory {
* @return Promise<Connection>
*/
public createConnection(uri: string, options?: IDBOptions): Promise<Connection> {
this._options = { ...this._options, ...options }
return new Promise<Connection>((resolve, reject) => {
mongoose.connect(uri, this._options)
mongoose.connect(uri, options)
.then((result: Mongoose) => resolve(result.connection))
.catch(err => reject(err))
})
Expand Down
8 changes: 4 additions & 4 deletions src/infrastructure/database/schema/device.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ interface IDevice extends Mongoose.Document {
const deviceSchema = new Mongoose.Schema({
name: {
type: String,
required: 'Name of device is required!'
required: true
},
address: {
type: String,
required: 'Address of device is required!'
required: true
},
type: {
type: String,
required: 'Type of device is required!'
required: true
},
model_number: {
type: String
},
manufacturer: {
type: String,
required: 'Manufacturer of device is required!'
required: true
},
patient_id: { type: Schema.Types.ObjectId }
},
Expand Down
60 changes: 30 additions & 30 deletions src/infrastructure/database/schema/measurement.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,37 @@ interface IMeasurement extends Mongoose.Document {
}

const measurementSchema = new Mongoose.Schema({
value: { type: Number },
unit: {
type: String,
required: 'Unit of measurement is required!'
},
type: {
type: String,
required: 'Type of measurement is required!'
},
timestamp: {
type: Date,
index: true
},
device_id: {
type: Schema.Types.ObjectId,
ref: 'Device'
},
patient_id: {
type: String,
required: 'Id of patient associated with a measurement is required!',
index: true
},
meal: { type: String }, // Blood Glucose
systolic: { type: Number }, // Blood Pressure
diastolic: { type: Number },
pulse: { type: Number },
body_fat: { type: Number }, // Weight
annual_variation: { type: String },
hand: { type: String }, // HandGrip
leg: { type: String } // CalfCircumference
value: { type: Number },
unit: {
type: String,
required: true
},
type: {
type: String,
required: true
},
timestamp: {
type: Date,
index: true
},
device_id: {
type: Schema.Types.ObjectId,
ref: 'Device'
},
patient_id: {
type: String,
required: true,
index: true
},
meal: { type: String }, // Blood Glucose
systolic: { type: Number }, // Blood Pressure
diastolic: { type: Number },
pulse: { type: Number },
body_fat: { type: Number }, // Weight
annual_variation: { type: String },
hand: { type: String }, // HandGrip
leg: { type: String } // CalfCircumference
},
{
timestamps: { createdAt: 'created_at', updatedAt: false },
toJSON: {
Expand Down
2 changes: 1 addition & 1 deletion src/infrastructure/repository/base/base.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { Strings } from '../../../utils/strings'
@injectable()
export abstract class BaseRepository<T extends Entity, TModel> implements IRepository<T> {

protected constructor(
constructor(
readonly Model: any,
readonly mapper: IEntityMapper<T, TModel>,
readonly logger: ILogger
Expand Down
Loading

0 comments on commit 7dcbd3e

Please sign in to comment.