Skip to content

Commit d51a4b8

Browse files
committed
Upgrade to Mongoose 5.7.5 (breaking changes)
1 parent 966c59b commit d51a4b8

File tree

2 files changed

+29
-17
lines changed

2 files changed

+29
-17
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "MIT-Annotation-Data-Store",
2+
"name": "mit-annotation-data-store",
33
"version": "0.1.6",
44
"dependencies": {
55
"errorhandler": "^1.5.1",

web.js

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
// Setup
2+
3+
const uriFormat = require('mongodb-uri')
4+
function encodeMongoURI (urlString) {
5+
if (urlString) {
6+
let parsed = uriFormat.parse(urlString)
7+
urlString = uriFormat.format(parsed);
8+
}
9+
return urlString;
10+
};
11+
12+
213
var application_root = __dirname,
314
secret = process.env.SECRET,
415
port = process.env.PORT,
5-
db = process.env.DB,
16+
db = encodeMongoURI(process.env.DB),
617
consumer = process.env.CONSUMER,
718
version = process.env.VERSION,
819
path = require("path"),
@@ -30,6 +41,7 @@ var allowCrossDomain = function(req, res, next) {
3041
}
3142
};
3243

44+
3345
// Schemas
3446
var Schema = mongoose.Schema;
3547

@@ -171,8 +183,6 @@ var Annotation = new Schema({
171183
}
172184
});
173185

174-
var AnnotationModel = mongoose.model('Annotation', Annotation);
175-
176186
// DB
177187
mongoose.connect(db);
178188

@@ -183,13 +193,27 @@ app.use(express.urlencoded({
183193
}));
184194
app.use(express.json());
185195
app.use(methodOverride());
186-
196+
app.use(lessMiddleware(__dirname + '/public', {
197+
render:{
198+
compress: true
199+
}
200+
}));
201+
202+
app.use(express.static(path.join(application_root, "public")));
203+
app.use(errorhandler({
204+
dumpExceptions: true,
205+
showStack: true
206+
}));
207+
187208

188209
Annotation.pre('save', function(next) {
189210
this.id = this._id;
190211
next();
191212
});
192213

214+
var AnnotationModel = mongoose.model('Annotation', Annotation);
215+
216+
193217
// ROUTES
194218
app.get('/api', function(req, res) {
195219
res.send('Annotations API is running');
@@ -440,18 +464,6 @@ app.delete('/api/annotations/:id', tokenOK, function(req, res) {
440464
});
441465
});
442466

443-
// Middleware config
444-
app.use(lessMiddleware(__dirname + '/public', {
445-
render:{
446-
compress: true
447-
}
448-
}));
449-
450-
app.use(express.static(path.join(application_root, "public")));
451-
app.use(errorhandler({
452-
dumpExceptions: true,
453-
showStack: true
454-
}));
455467

456468
// Authentication
457469
function tokenOK(req, res, next) {

0 commit comments

Comments
 (0)