Skip to content

Commit 13f01ef

Browse files
authored
Merge pull request #21 from iolufemi/dev
Dev
2 parents 2aabaf4 + 6ea388f commit 13f01ef

31 files changed

+529
-513
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,6 @@ jspm_packages
3535

3636
# Optional REPL history
3737
.node_repl_history
38+
39+
#Mac
40+
.DS_Store

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ addons:
1212
packages:
1313
- mongodb-org-server
1414
node_js:
15-
- '7'
16-
- '6'
15+
- '8'
1716
before_script:
1817
- sleep 15
1918
- npm install -g gulp mocha gulp-cli codecov istanbul

Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ FROM node:carbon
22

33
WORKDIR /usr/src/app
44

5-
COPY ../package*.json ./
5+
COPY package*.json ./
66

77
RUN npm install
88

99
COPY . .
1010

11-
CMD [ "npm", "run", "clock" ]
11+
EXPOSE 8080
12+
13+
CMD [ "npm", "start" ]

TODO.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
### TODOs
22
| Filename | line # | TODO
33
|:------|:------:|:------
4-
| app.js | 62 | Write a complete Documentation for this project
4+
| app.js | 61 | Write a complete Documentation for this project
55
| config/index.js | 12 | Test for production and development senarios
66
| models/index.js | 14 | Automatically generate tests with the schema structure
7-
| routes/index.js | 298 | Test API versioning
8-
| routes/index.js | 299 | Test rate limiting
9-
| routes/index.js | 300 | Test complete route Loader test
10-
| routes/index.js | 301 | Test _sanitizeRequestUrl middleware function
11-
| routes/index.js | 302 | Test _allRequestData middleware function for default value scenario
12-
| routes/index.js | 303 | Test _enforceUserIdAndAppId middle function for when req.body is an array
13-
| routes/index.js | 304 | Make Log requests testable and write unit tests for it
14-
| routes/index.js | 305 | Develop the route loader into a separate node module to be publish on npm
15-
| routes/index.js | 306 | Develop all services onto separate node module to be publish on npm
16-
| services/logger/index.js | 36 | Test Error Handler
7+
| routes/index.js | 260 | Test API versioning
8+
| routes/index.js | 261 | Test rate limiting
9+
| routes/index.js | 262 | Test complete route Loader test
10+
| routes/index.js | 263 | Test _sanitizeRequestUrl middleware function
11+
| routes/index.js | 264 | Test _allRequestData middleware function for default value scenario
12+
| routes/index.js | 265 | Make Log requests testable and write unit tests for it
13+
| routes/index.js | 266 | Develop the route loader into a separate node module to be publish on npm
14+
| routes/index.js | 267 | Develop all services onto separate node module to be publish on npm
15+
| services/logger/index.js | 48 | Test Error Handler
16+
| services/request/index.js | 90 | Test request module

app.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ if (cluster.isMaster && config.env === 'production') {
3535
var app = express();
3636
var router = require('./routes');
3737
var express_enforces_ssl = require('express-enforces-ssl');
38-
var workers = require('./services/queue/workers');
3938

4039
if(config.trustProxy === 'yes'){
4140
app.enable('trust proxy');

clock/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM node:carbon
22

33
WORKDIR /usr/src/app
44

5-
COPY ../package*.json ./
5+
COPY ./package*.json ./
66

77
RUN npm install
88

config/development.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,10 @@ module.exports = {
3030
SQLHost: process.env.SQL_HOST || '192.168.99.100',
3131
SQLPort: process.env.SQL_PORT || 3306,
3232
SQLDriver: process.env.SQL_DRIVER || 'mysql', //'mysql'|'sqlite'|'postgres'|'mssql'
33-
SQLTimezone: process.env.SQL_TIMEZONE || '+01:00'
33+
SQLTimezone: process.env.SQL_TIMEZONE || '+01:00',
34+
clockTimezone: process.env.CLOCK_TIMEZONE || 'Africa/Lagos',
35+
workerConcurrency: process.env.WORKER_CONCURRENCY || '1',
36+
logglyToken: process.env.LOGGLY_TOKEN || false,
37+
logglySubdomain: process.env.LOGGLY_SUBDOMAIN || false,
38+
logglyTag: process.env.LOGGLY_TAG || false
3439
};

config/production.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,13 @@ module.exports = {
2727
SQLUsername: process.env.SQL_USERNAME || 'root',
2828
SQLPassword: process.env.SQL_PASSWORD || null,
2929
SQLDatabase: process.env.SQL_DATABASE || 'snipe',
30-
SQLHost: process.env.SQL_HOST || 'localhost',
30+
SQLHost: process.env.SQL_HOST || '192.168.99.100',
3131
SQLPort: process.env.SQL_PORT || 3306,
3232
SQLDriver: process.env.SQL_DRIVER || 'mysql', //'mysql'|'sqlite'|'postgres'|'mssql'
33-
SQLTimezone: process.env.SQL_TIMEZONE || '+01:00'
33+
SQLTimezone: process.env.SQL_TIMEZONE || '+01:00',
34+
clockTimezone: process.env.CLOCK_TIMEZONE || 'Africa/Lagos',
35+
workerConcurrency: process.env.WORKER_CONCURRENCY || '1',
36+
logglyToken: process.env.LOGGLY_TOKEN || false,
37+
logglySubdomain: process.env.LOGGLY_SUBDOMAIN || false,
38+
logglyTag: process.env.LOGGLY_TAG || false
3439
};

models/RequestLogs.js

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ var schemaObject = {
4949

5050
schemaObject.createdAt = {
5151
type: 'Date',
52-
default: Date.now
52+
default: Date.now,
53+
index: true
5354
};
5455

5556
schemaObject.updatedAt = {
@@ -59,12 +60,12 @@ schemaObject.updatedAt = {
5960

6061
schemaObject.owner = {
6162
type: db._mongoose.Schema.Types.ObjectId,
62-
ref: 'Users'
63+
ref: 'Accounts'
6364
};
6465

6566
schemaObject.createdBy = {
6667
type: db._mongoose.Schema.Types.ObjectId,
67-
ref: 'Users'
68+
ref: 'Accounts'
6869
};
6970

7071
schemaObject.client = {
@@ -165,20 +166,20 @@ Schema.post('find', function(result) {
165166
Schema.pre('update', function(next) {
166167

167168
// Indexing for search
168-
var ourDoc = this._update.$set;
169-
debug('What we are updating: ', ourDoc);
170-
ourDoc.model = collection;
171-
ourDoc.update = true;
172-
debug('what do we have here: ', ourDoc);
173-
if(ourDoc.updatedAt || ourDoc.tags){
174-
debug('updatedAt: ', ourDoc.updatedAt);
175-
debug('tags: ', ourDoc.tags);
176-
// Move along! Nothing to see here!!
177-
}else{
178-
// Dump it in the queue
179-
queue.create('searchIndex', ourDoc)
180-
.save();
181-
}
169+
var ourDoc = this._update;
170+
// debug('What we are updating: ', ourDoc);
171+
// ourDoc.model = collection;
172+
// ourDoc.update = true;
173+
// debug('what do we have here: ', ourDoc);
174+
// if(ourDoc.updatedAt || ourDoc.tags){
175+
// debug('updatedAt: ', ourDoc.updatedAt);
176+
// debug('tags: ', ourDoc.tags);
177+
// // Move along! Nothing to see here!!
178+
// }else{
179+
// // Dump it in the queue
180+
// queue.create('searchIndex', ourDoc)
181+
// .save();
182+
// }
182183
ourDoc.updatedAt = new Date(Date.now()).toISOString();
183184
next();
184185
});

models/Trash.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ var schemaObject = {
2222

2323
schemaObject.createdAt = {
2424
type: 'Date',
25-
default: Date.now
25+
default: Date.now,
26+
index: true
2627
};
2728

2829
schemaObject.updatedAt = {
@@ -32,12 +33,12 @@ schemaObject.updatedAt = {
3233

3334
schemaObject.owner = {
3435
type: db._mongoose.Schema.Types.ObjectId,
35-
ref: 'Users'
36+
ref: 'Accounts'
3637
};
3738

3839
schemaObject.deletedBy = {
3940
type: db._mongoose.Schema.Types.ObjectId,
40-
ref: 'Users'
41+
ref: 'Accounts'
4142
};
4243

4344
schemaObject.client = {
@@ -137,7 +138,7 @@ Schema.post('find', function(result) {
137138

138139
Schema.pre('update', function(next) {
139140
// Indexing for search
140-
var ourDoc = this._update.$set;
141+
var ourDoc = this._update;
141142
ourDoc.model = collection;
142143
ourDoc.update = true;
143144

0 commit comments

Comments
 (0)