openhim-core
Version:
The OpenHIM core application that provides logging and routing of http requests
104 lines (90 loc) • 2.1 kB
JavaScript
var ErrorDetailsDef, OrchestrationMetadataDef, RequestDef, ResponseDef, RouteMetadataDef, Schema, TransactionSchema, connectionDefault, mongoose, server;
mongoose = require("mongoose");
server = require("../server");
connectionDefault = server.connectionDefault;
Schema = mongoose.Schema;
RequestDef = {
"host": String,
"port": String,
"path": String,
"headers": Object,
"querystring": String,
"body": String,
"method": String,
"timestamp": {
type: Date,
required: true
}
};
ResponseDef = {
"status": Number,
"headers": Object,
"body": String,
"timestamp": Date
};
ErrorDetailsDef = {
"message": String,
"stack": String
};
OrchestrationMetadataDef = {
"name": {
type: String,
required: true
},
"group": String,
"request": {
type: RequestDef,
required: false
},
"response": ResponseDef,
"error": ErrorDetailsDef
};
RouteMetadataDef = {
"name": {
type: String,
required: true
},
"request": RequestDef,
"response": ResponseDef,
"orchestrations": [OrchestrationMetadataDef],
"properties": Object,
"error": ErrorDetailsDef
};
TransactionSchema = new Schema({
"clientID": Schema.Types.ObjectId,
"clientIP": String,
"parentID": Schema.Types.ObjectId,
"childIDs": [Schema.Types.ObjectId],
"channelID": {
type: Schema.Types.ObjectId,
index: true
},
"request": RequestDef,
"response": ResponseDef,
"routes": [RouteMetadataDef],
"orchestrations": [OrchestrationMetadataDef],
"properties": Object,
"canRerun": {
type: Boolean,
"default": true
},
"autoRetry": {
type: Boolean,
"default": false
},
"autoRetryAttempt": Number,
"wasRerun": {
type: Boolean,
"default": false
},
"error": ErrorDetailsDef,
"status": {
type: String,
required: true,
index: true,
"enum": ['Processing', 'Failed', 'Completed', 'Successful', 'Completed with error(s)']
}
});
TransactionSchema.index("request.timestamp");
exports.Transaction = connectionDefault.model('Transaction', TransactionSchema);
//# sourceMappingURL=transactions.js.map