Skip to content

Commit

Permalink
Merge branch 'release/1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
lykmapipo committed Dec 16, 2018
2 parents e20a487 + 53527c6 commit 3ddae1c
Show file tree
Hide file tree
Showing 12 changed files with 273 additions and 380 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 1.1.0 / 16-12-2018
- Build latest apidoc
- Force latest dependencies & audit fix
- Add taggable plugin

# 1.0.4 / 18-11-2018
- Force latest dependencies
- Improve role model unit spec
Expand Down
2 changes: 1 addition & 1 deletion docs/api_project.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ define({
"apidoc": "0.3.0",
"generator": {
"name": "apidoc",
"time": "2018-11-18T08:17:29.001Z",
"time": "2018-12-16T14:58:05.218Z",
"url": "http://apidocjs.com",
"version": "0.17.6"
}
Expand Down
2 changes: 1 addition & 1 deletion docs/api_project.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"apidoc": "0.3.0",
"generator": {
"name": "apidoc",
"time": "2018-11-18T08:17:29.001Z",
"time": "2018-12-16T14:58:05.218Z",
"url": "http://apidocjs.com",
"version": "0.17.6"
}
Expand Down
39 changes: 18 additions & 21 deletions examples/app.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,36 @@
'use strict';


/* ensure mongo uri */
/* ensure mongodb uri */
process.env.MONGODB_URI =
(process.env.MONGODB_URI || 'mongodb://localhost/emis-role');


/* dependencies */
const path = require('path');
const mongoose = require('mongoose');
const {
Role,
apiVersion,
info,
app
} = require(path.join(__dirname, '..'));
const async = require('async');
const { include } = require('@lykmapipo/include');
const { connect } = require('@lykmapipo/mongoose-common');
const { Role, info, app } = include(__dirname, '..');


/* connect to mongoose */
mongoose.connect(process.env.MONGODB_URI);
// establish mongodb connection
connect((error) => {

// seed roles
Role.seed((error, results) => {

Role.seed(( /*error, results*/ ) => {
// expose module info
app.get('/', (request, response) => {
response.status(200);
response.json(info);
});

/* expose module info */
app.get('/', (request, response) => {
response.status(200);
response.json(info);
});
// fire the app
app.start((error, env) => {
console.log(`visit http://0.0.0.0:${env.PORT}`);
});

/* fire the app */
app.start((error, env) => {
console.log(
`visit http://0.0.0.0:${env.PORT}/v${apiVersion}/roles`
);
});

});
4 changes: 2 additions & 2 deletions lib/role.http.router.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@


/* dependencies */
const path = require('path');
const _ = require('lodash');
const { getString } = require('@lykmapipo/env');
const { include } = require('@lykmapipo/include');
const Router = require('@lykmapipo/express-common').Router;


Expand All @@ -117,7 +117,7 @@ const PATH_SCHEMA = '/roles/schema/';


/* declarations */
const Role = require(path.join(__dirname, 'role.model'));
const Role = include(__dirname, 'role.model');
const router = new Router({
version: API_VERSION
});
Expand Down
19 changes: 10 additions & 9 deletions lib/role.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
const path = require('path');
const _ = require('lodash');
const async = require('async');
const mongoose = require('mongoose');
const { getString, getStrings } = require('@lykmapipo/env');
const { Schema, SchemaTypes } = require('@lykmapipo/mongoose-common');
const { model, SCHEMA_OPTIONS } = require('@lykmapipo/mongoose-common');
const actions = require('mongoose-rest-actions');
const { Permission } = require('@lykmapipo/permission');
const { Schema } = mongoose;
const { ObjectId } = Schema.Types;
const { ObjectId } = SchemaTypes;


/* constants */
Expand All @@ -42,11 +42,6 @@ const ROLE_SEED = getString('ROLE_SEED', 'roles');
const ADMINISTRATOR_ROLE_NAME =
getString('ADMINISTRATOR_ROLE_NAME', 'Administrator');
const POPULATION_MAX_DEPTH = 1;
const SCHEMA_OPTIONS = ({
timestamps: true,
emitIndexErrors: true,
collection: ROLE_COLLECTION_NAME
});
const OPTION_AUTOPOPULATE = ({
select: { name: 1, description: 1 },
maxDepth: POPULATION_MAX_DEPTH
Expand All @@ -71,6 +66,7 @@ const RoleSchema = new Schema({
* @property {boolean} enum - list of acceptable values
* @property {boolean} index - ensure database index
* @property {boolean} searchable - allow for searching
* @property {boolean} taggable - allow field use for tagging
* @property {object} fake - fake data generator options
*
* @author lally elias <lallyelias87@gmail.com>
Expand All @@ -86,6 +82,7 @@ const RoleSchema = new Schema({
enum: ROLE_TYPES,
index: true,
searchable: true,
taggable: true,
hide: true,
fake: true
},
Expand All @@ -103,6 +100,7 @@ const RoleSchema = new Schema({
* @property {boolean} index - ensure database index
* @property {boolean} unique - ensure unique database index
* @property {boolean} searchable - allow for searching
* @property {boolean} taggable - allow field use for tagging
* @property {object} fake - fake data generator options
*
* @author lally elias <lallyelias87@gmail.com>
Expand All @@ -120,6 +118,7 @@ const RoleSchema = new Schema({
index: true,
unique: true,
searchable: true,
taggable: true,
fake: {
generator: 'hacker',
type: 'noun'
Expand All @@ -137,6 +136,7 @@ const RoleSchema = new Schema({
* @property {boolean} uppercase - force upper-casing
* @property {boolean} index - ensure database index
* @property {boolean} searchable - allow for searching
* @property {boolean} taggable - allow field use for tagging
* @property {object} fake - fake data generator options
*
* @since 0.1.0
Expand All @@ -151,6 +151,7 @@ const RoleSchema = new Schema({
uppercase: true,
index: true,
searchable: true,
taggable: true,
fake: {
generator: 'hacker',
type: 'abbreviation'
Expand Down Expand Up @@ -471,4 +472,4 @@ RoleSchema.plugin(actions);


/* export role model */
module.exports = mongoose.model(ROLE_MODEL_NAME, RoleSchema);
module.exports = model(ROLE_MODEL_NAME, RoleSchema);
Loading

0 comments on commit 3ddae1c

Please sign in to comment.