openhim-core
Version:
The OpenHIM core application that provides logging and routing of http requests
67 lines (58 loc) • 1.54 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.EventModel = exports.EventModelAPI = exports.eventTypes = void 0;
var _mongoose = require("mongoose");
var _config = require("../config");
const eventTypes = ['channel', 'primary', 'route', 'orchestration']; // Active transaction events
//
// A short term collection for functions that require 'live' analysis of transactions
// e.g. alerting and the visualizer
//
// Events are more fine-grained than individual transactions
//
exports.eventTypes = eventTypes;
const EventsSchema = new _mongoose.Schema({
created: {
type: Date,
default: Date.now,
expires: '1h'
},
channelID: {
type: _mongoose.Schema.Types.ObjectId,
required: true
},
transactionID: {
type: _mongoose.Schema.Types.ObjectId,
required: true
},
type: {
type: String,
enum: exports.EventTypes
},
event: {
type: String,
enum: ['start', 'end']
},
name: String,
status: Number,
statusType: {
type: String,
enum: ['success', 'error']
},
// status string supported by visualizer (e.g. 'error' is red)
normalizedTimestamp: String,
mediator: String,
autoRetryAttempt: Number
});
EventsSchema.index({
created: 1
}, {
expireAfterSeconds: 3600
});
const EventModelAPI = _config.connectionAPI.model('Event', EventsSchema);
exports.EventModelAPI = EventModelAPI;
const EventModel = _config.connectionDefault.model('Event', EventsSchema);
exports.EventModel = EventModel;
//# sourceMappingURL=events.js.map