-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
160 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const mapRealm = require('./realm'); | ||
const mapGenericEntity = require('../../../../lib/mappers/generic-entity'); | ||
|
||
/** | ||
* @class RealmViewModel | ||
* @property {string} id | ||
* @property {string} name | ||
* @property {Date} createdAt | ||
* @property {Date} updatedAt | ||
*/ | ||
/** | ||
* Map a realm to detail response view model | ||
* @param {object} args | ||
* @param {RealmModel} args.realm The realm entity | ||
* @param {RealmLimitsModel} args.realmLimits The realm limits entity | ||
* @return {RealmViewModel} The realm view model | ||
*/ | ||
module.exports = ({realm, realmLimits}) => ({ | ||
...mapRealm(realm), | ||
limits: mapGenericEntity({ | ||
entity: realmLimits, | ||
propertyMap: { | ||
maxConnections: 'maxConnections', | ||
sessionMaxMessageRate: 'sessionMaxMessageRate', | ||
sessionMaxConnectionLifetime: 'sessionMaxConnectionLifetime', | ||
sessionMaxMessageSize: 'sessionMaxMessageSize', | ||
} | ||
}), | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,4 @@ const createLogger = require('./lib/logger'); | |
process.exit(1); | ||
} | ||
})(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const stripUndefined = require('../lib/strip-undefined'); | ||
|
||
/** | ||
* @typedef {Object} RealmLimitsModel Specialized set of realm settings focused on connections/sessions | ||
* @param {string} [id] | ||
* @param {string} realmId | ||
* @param {number} maxConnections Max number of simultaneously online connections | ||
* @param {number} sessionMaxMessageRate Max incoming publish rate per session per second | ||
* @param {number} sessionMaxConnectionLifetime Max lifetime of a connection in seconds | ||
* @param {number} sessionMaxMessageSize Max message payload size in bytes | ||
* @param {Date} [createdAt] | ||
* @param {Date} [updatedAt] | ||
*/ | ||
|
||
/** | ||
* @return {RealmLimitsModel} The generalized realm model | ||
*/ | ||
module.exports = ({ | ||
id, | ||
realmId, | ||
maxConnections, | ||
sessionMaxMessageRate, | ||
sessionMaxConnectionLifetime, | ||
sessionMaxMessageSize, | ||
createdAt, | ||
updatedAt, | ||
}) => stripUndefined({ | ||
id, | ||
realmId, | ||
maxConnections, | ||
sessionMaxMessageRate, | ||
sessionMaxConnectionLifetime, | ||
sessionMaxMessageSize, | ||
createdAt, | ||
updatedAt, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const createRealmLimitsModel = require('../models/realm-limits'); | ||
const createMongoRepository = require('./lib/mongo'); | ||
|
||
/** | ||
* Create realm repository. | ||
* | ||
* @param {Collection} collection Mongodb collection | ||
* @param {function} createModel Model factory | ||
* @return {RealmLimitsRepository} The created realm repository | ||
*/ | ||
module.exports = ({collection, createModel = createRealmLimitsModel}) => { | ||
const mongoRepo = createMongoRepository({collection, createModel}); | ||
|
||
/** | ||
* @class RealmLimitsRepository | ||
* @extends MongoRepository | ||
*/ | ||
return { | ||
...mongoRepo, | ||
}; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters