Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private convertToEnvelope(event: EventStore.ResolvedEvent): EventEnvelope {
const e = event.event;
const metadata = JSON.parse(e.metadata.toString());
const eventClass = requireByFQN(e.eventType);
return new EventEnvelope(
new Guid(e.eventId),
metadata.aggregateType, // aggregateType
metadata.aggregateId, // aggregateId
e.eventNumber, // version
deserialize(eventClass, e.data.toString()), // eventData
e.eventType, // eventType
metadata,
new Date(e.createdEpoch) // created
);
}
RequisitionParser.prototype.deserialize = function (requisitionJson) {
try {
return class_transformer_1.deserialize(requisition_1.Requisition, requisitionJson);
}
catch (e) {
throw new Error("Error parsing requisition: " + e);
}
};
return RequisitionParser;
deserialize (val: string, classConstructor: ClassConstructor): T {
return deserialize (classConstructor, val)
}
return this.requestApiTexted(url, params).map((result) => {
const timeseries = deserialize(Timeseries, result);
timeseries.url = apiUrl;
return timeseries;
});
}
options: ClassTransformOptions = { enableCircularCheck: true },
): T {
if (!json) {
return;
}
if (json instanceof cls) {
validateObjectSync(json);
return json as T;
}
let o;
if (_.isPlainObject(json)) {
o = plainToClass(cls, json as JSON, options);
} else if (_.isString(json)) {
o = deserialize(cls, json as string, options);
}
logger.debug(`deserializeSafely: ${r({ cls, o, json, options })}`);
validateObjectSync(o);
return o;
}
parse(mqttRequisition: string): any {
try {
return deserialize(MqttRequisition, mqttRequisition);
} catch (e) {
throw new Error("Error parsing mqttRequisition: " + e);
}
}
async signUp(@Arg("newUser") newUser: UserInput): Promise {
var json = JSON.stringify(newUser);
var user = deserialize(UserModel, json);
user.password = hashSync(newUser.password, 10);
var user = await this.userController.save(user);
return user;
}
}
public onSocketServerAction(action: { type: string; data: any }) {
if (!action || !action.type || !action.data) {
this.appLogger.winston.error(
`Error: Unable to process action`,
action
);
}
try {
const eventData: EventData = deserialize(
EventData,
JSON.stringify(action.data),
{
enableCircularCheck: true
}
);
const eventAction: EventAction = new EventAction();
eventAction.data = eventData;
eventAction.type = action.type;
const clientId = action.data.socket.id;
this.appLogger.winston.log(
'socket',
`Action Received: ${JSON.stringify(eventAction)}`
);
this.appLogger.winston.log(
'socket',
return this.requestApiTexted(url, params).map((result) => {
const timeseries = deserialize(Timeseries, result);
timeseries.url = apiUrl;
return timeseries;
});
}