Skip to content

Commit 5b960d3

Browse files
Merge remote-tracking branch 'upstream/master'
2 parents 4ddedf8 + 39fb0d0 commit 5b960d3

30 files changed

+689
-202
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@ node_modules
2828

2929
# Emacs
3030
*~
31+
32+
# WebStorm/IntelliJ
33+
.idea

.travis.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
branches:
2+
only:
3+
- master
4+
language: node_js
5+
node_js:
6+
- "4.1"
7+
- "4.2"
8+
env:
9+
- MONGODB_VERSION=2.6.11
10+
- MONGODB_VERSION=3.0.8
11+
after_success: ./node_modules/.bin/codecov

Auth.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ var getAuthForSessionToken = function(config, sessionToken) {
6464
var obj = results[0]['user'];
6565
delete obj.password;
6666
obj['className'] = '_User';
67+
obj['sessionToken'] = sessionToken;
6768
var userObject = Parse.Object.fromJSON(obj);
6869
cache.setUser(sessionToken, userObject);
6970
return new Auth(config, false, userObject);

CONTRIBUTING.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
### Contributing to Parse Server
2+
3+
#### Pull Requests Welcome!
4+
5+
We really want Parse to be yours, to see it grow and thrive in the open source community.
6+
7+
##### Please Do's
8+
9+
* Please write tests to cover new methods.
10+
* Please run the tests and make sure you didn't break anything.
11+
12+
##### Code of Conduct
13+
14+
This project adheres to the [Open Code of Conduct][code-of-conduct]. By participating, you are expected to honor this code.
15+
[code-of-conduct]: http://todogroup.org/opencodeofconduct/#Parse Server/[email protected]
16+
17+

DatabaseAdapter.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ var adapter = ExportAdapter;
2020
var cache = require('./cache');
2121
var dbConnections = {};
2222
var databaseURI = 'mongodb://localhost:27017/parse';
23+
var appDatabaseURIs = {};
2324

2425
function setAdapter(databaseAdapter) {
2526
adapter = databaseAdapter;
@@ -29,11 +30,17 @@ function setDatabaseURI(uri) {
2930
databaseURI = uri;
3031
}
3132

33+
function setAppDatabaseURI(appId, uri) {
34+
appDatabaseURIs[appId] = uri;
35+
}
36+
3237
function getDatabaseConnection(appId) {
3338
if (dbConnections[appId]) {
3439
return dbConnections[appId];
3540
}
36-
dbConnections[appId] = new adapter(databaseURI, {
41+
42+
var dbURI = (appDatabaseURIs[appId] ? appDatabaseURIs[appId] : databaseURI);
43+
dbConnections[appId] = new adapter(dbURI, {
3744
collectionPrefix: cache.apps[appId]['collectionPrefix']
3845
});
3946
dbConnections[appId].connect();
@@ -44,5 +51,6 @@ module.exports = {
4451
dbConnections: dbConnections,
4552
getDatabaseConnection: getDatabaseConnection,
4653
setAdapter: setAdapter,
47-
setDatabaseURI: setDatabaseURI
54+
setDatabaseURI: setDatabaseURI,
55+
setAppDatabaseURI: setAppDatabaseURI
4856
};

ExportAdapter.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,21 @@ ExportAdapter.prototype.connect = function() {
3434
return this.connectionPromise;
3535
}
3636

37+
//http://regexr.com/3cncm
38+
if (!this.mongoURI.match(/^mongodb:\/\/((.+):(.+)@)?([^:@]+):{0,1}([^:]+)\/(.+?)$/gm)) {
39+
throw new Error("Invalid mongoURI: " + this.mongoURI)
40+
}
41+
var usernameStart = this.mongoURI.indexOf('://') + 3;
42+
var lastAtIndex = this.mongoURI.lastIndexOf('@');
43+
var encodedMongoURI = this.mongoURI;
44+
var split = null;
45+
if (lastAtIndex > 0) {
46+
split = this.mongoURI.slice(usernameStart, lastAtIndex).split(':');
47+
encodedMongoURI = this.mongoURI.slice(0, usernameStart) + encodeURIComponent(split[0]) + ':' + encodeURIComponent(split[1]) + this.mongoURI.slice(lastAtIndex);
48+
}
49+
3750
this.connectionPromise = Promise.resolve().then(() => {
38-
return MongoClient.connect(this.mongoURI);
51+
return MongoClient.connect(encodedMongoURI, {uri_decode_auth:true});
3952
}).then((db) => {
4053
this.db = db;
4154
});
@@ -232,7 +245,7 @@ ExportAdapter.prototype.handleRelationUpdates = function(className,
232245
}
233246

234247
if (op.__op == 'Batch') {
235-
for (x of op.ops) {
248+
for (var x of op.ops) {
236249
process(x, key);
237250
}
238251
}

FilesAdapter.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// Adapter classes must implement the following functions:
66
// * create(config, filename, data)
77
// * get(config, filename)
8+
// * location(config, req, filename)
89
//
910
// Default is GridStoreAdapter, which requires mongo
1011
// and for the API server to be using the ExportAdapter

GridStoreAdapter.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// Requires the database adapter to be based on mongoclient
55

66
var GridStore = require('mongodb').GridStore;
7+
var path = require('path');
78

89
// For a given config object, filename, and data, store a file
910
// Returns a promise
@@ -32,7 +33,16 @@ function get(config, filename) {
3233
});
3334
}
3435

36+
// Generates and returns the location of a file stored in GridStore for the
37+
// given request and filename
38+
function location(config, req, filename) {
39+
return (req.protocol + '://' + req.get('host') +
40+
path.dirname(req.originalUrl) + '/' + req.config.applicationId +
41+
'/' + encodeURIComponent(filename));
42+
}
43+
3544
module.exports = {
3645
create: create,
37-
get: get
46+
get: get,
47+
location: location
3848
};

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## parse-server
22

3+
[![Build Status](https://img.shields.io/travis/ParsePlatform/parse-server/master.svg?style=flat)](https://travis-ci.org/ParsePlatform/parse-server)
4+
[![Coverage Status](https://img.shields.io/codecov/c/github/ParsePlatform/parse-server/master.svg)](https://codecov.io/github/ParsePlatform/parse-server?branch=master)
5+
[![npm version](https://img.shields.io/npm/v/parse-server.svg?style=flat)](https://www.npmjs.com/package/parse-server)
6+
37
A Parse.com API compatible router package for Express
48

59
Read the announcement blog post here: http://blog.parse.com/announcements/introducing-parse-server-and-the-database-migration-tool/

RestQuery.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ function includePath(config, auth, response, path) {
434434
function findPointers(object, path) {
435435
if (object instanceof Array) {
436436
var answer = [];
437-
for (x of object) {
437+
for (var x of object) {
438438
answer = answer.concat(findPointers(x, path));
439439
}
440440
return answer;

0 commit comments

Comments
 (0)