Merge pull request #312 from ParsePlatform/nlutsenko.babel
Add Babel.js compiler support.
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -30,4 +30,7 @@ node_modules
|
||||
*~
|
||||
|
||||
# WebStorm/IntelliJ
|
||||
.idea
|
||||
.idea
|
||||
|
||||
# Babel.js
|
||||
lib/
|
||||
|
||||
@@ -7,7 +7,7 @@ We really want Parse to be yours, to see it grow and thrive in the open source c
|
||||
##### Please Do's
|
||||
|
||||
* Take testing seriously! Aim to increase the test coverage with every pull request.
|
||||
* Run the tests for the file you are working on with `TESTING=1 (repo-root)/node_modules/jasmine/bin/jasmine.js spec/MyFile.spec.js`
|
||||
* Run the tests for the file you are working on with `npm test spec/MyFile.spec.js`
|
||||
* Run the tests for the whole project and look at the coverage report to make sure your tests are exhaustive by running `npm test` and looking at (project-root)/lcov-report/parse-server/FileUnderTest.js.html
|
||||
|
||||
##### Code of Conduct
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env node
|
||||
var express = require('express');
|
||||
var ParseServer = require("../index").ParseServer;
|
||||
var ParseServer = require("../lib/index").ParseServer;
|
||||
|
||||
var app = express();
|
||||
|
||||
|
||||
17
package.json
17
package.json
@@ -2,7 +2,7 @@
|
||||
"name": "parse-server",
|
||||
"version": "2.0.7",
|
||||
"description": "An express module providing a Parse-compatible API server",
|
||||
"main": "index.js",
|
||||
"main": "lib/index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ParsePlatform/parse-server"
|
||||
@@ -11,6 +11,7 @@
|
||||
"dependencies": {
|
||||
"apn": "^1.7.5",
|
||||
"aws-sdk": "~2.2.33",
|
||||
"babel-runtime": "^6.5.0",
|
||||
"bcrypt-nodejs": "0.0.3",
|
||||
"body-parser": "^1.14.2",
|
||||
"deepcopy": "^0.6.1",
|
||||
@@ -19,23 +20,29 @@
|
||||
"mime": "^1.3.4",
|
||||
"mongodb": "~2.1.0",
|
||||
"multer": "^1.1.0",
|
||||
"node-gcm": "^0.14.0",
|
||||
"parse": "^1.7.0",
|
||||
"randomstring": "^1.1.3",
|
||||
"node-gcm": "^0.14.0",
|
||||
"request": "^2.65.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-cli": "^6.5.1",
|
||||
"babel-core": "^6.5.1",
|
||||
"babel-istanbul": "^0.6.0",
|
||||
"babel-preset-es2015": "^6.5.0",
|
||||
"babel-register": "^6.5.1",
|
||||
"codecov": "^1.0.1",
|
||||
"deep-diff": "^0.3.3",
|
||||
"istanbul": "^0.4.2",
|
||||
"jasmine": "^2.3.2",
|
||||
"mongodb-runner": "^3.1.15"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "./node_modules/.bin/babel src/ -d lib/",
|
||||
"pretest": "MONGODB_VERSION=${MONGODB_VERSION:=3.0.8} mongodb-runner start",
|
||||
"test": "NODE_ENV=test TESTING=1 ./node_modules/.bin/istanbul cover --include-all-sources -x **/spec/** ./node_modules/.bin/jasmine",
|
||||
"test": "NODE_ENV=test TESTING=1 ./node_modules/.bin/babel-node ./node_modules/.bin/babel-istanbul cover -x **/spec/** ./node_modules/.bin/jasmine",
|
||||
"posttest": "mongodb-runner stop",
|
||||
"start": "./bin/parse-server"
|
||||
"start": "./bin/parse-server",
|
||||
"prepublish": "npm run build"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.1"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var APNS = require('../APNS');
|
||||
var APNS = require('../src/APNS');
|
||||
|
||||
describe('APNS', () => {
|
||||
it('can generate APNS notification', (done) => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var ExportAdapter = require('../ExportAdapter');
|
||||
var ExportAdapter = require('../src/ExportAdapter');
|
||||
|
||||
describe('ExportAdapter', () => {
|
||||
it('can be constructed', (done) => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var GCM = require('../GCM');
|
||||
var GCM = require('../src/GCM');
|
||||
|
||||
describe('GCM', () => {
|
||||
it('can generate GCM Payload without expiration time', (done) => {
|
||||
|
||||
@@ -251,6 +251,9 @@ describe('Parse.ACL', () => {
|
||||
equal(results.length, 1);
|
||||
var result = results[0];
|
||||
ok(result);
|
||||
if (!result) {
|
||||
return fail();
|
||||
}
|
||||
equal(result.id, object.id);
|
||||
equal(result.getACL().getReadAccess(user), true);
|
||||
equal(result.getACL().getWriteAccess(user), true);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// A bunch of different tests are in here - it isn't very thematic.
|
||||
// It would probably be better to refactor them into different files.
|
||||
|
||||
var DatabaseAdapter = require('../DatabaseAdapter');
|
||||
var DatabaseAdapter = require('../src/DatabaseAdapter');
|
||||
var request = require('request');
|
||||
|
||||
describe('miscellaneous', function() {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// These tests check the Installations functionality of the REST API.
|
||||
// Ported from installation_collection_test.go
|
||||
|
||||
var auth = require('../Auth');
|
||||
var cache = require('../cache');
|
||||
var Config = require('../Config');
|
||||
var DatabaseAdapter = require('../DatabaseAdapter');
|
||||
var auth = require('../src/Auth');
|
||||
var cache = require('../src/cache');
|
||||
var Config = require('../src/Config');
|
||||
var DatabaseAdapter = require('../src/DatabaseAdapter');
|
||||
var Parse = require('parse/node').Parse;
|
||||
var rest = require('../rest');
|
||||
var rest = require('../src/rest');
|
||||
|
||||
var config = new Config('test');
|
||||
var database = DatabaseAdapter.getDatabaseConnection('test');
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// Tests that involve sending password reset emails.
|
||||
|
||||
var request = require('request');
|
||||
var passwordCrypto = require('../password');
|
||||
var passwordCrypto = require('../src/password');
|
||||
|
||||
describe('Parse.User testing', () => {
|
||||
it("user sign up class method", (done) => {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// These tests check the "create" functionality of the REST API.
|
||||
var auth = require('../Auth');
|
||||
var cache = require('../cache');
|
||||
var Config = require('../Config');
|
||||
var DatabaseAdapter = require('../DatabaseAdapter');
|
||||
var auth = require('../src/Auth');
|
||||
var cache = require('../src/cache');
|
||||
var Config = require('../src/Config');
|
||||
var DatabaseAdapter = require('../src/DatabaseAdapter');
|
||||
var Parse = require('parse/node').Parse;
|
||||
var rest = require('../rest');
|
||||
var rest = require('../src/rest');
|
||||
var request = require('request');
|
||||
|
||||
var config = new Config('test');
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// These tests check the "find" functionality of the REST API.
|
||||
var auth = require('../Auth');
|
||||
var cache = require('../cache');
|
||||
var Config = require('../Config');
|
||||
var rest = require('../rest');
|
||||
var auth = require('../src/Auth');
|
||||
var cache = require('../src/cache');
|
||||
var Config = require('../src/Config');
|
||||
var rest = require('../src/rest');
|
||||
|
||||
var config = new Config('test');
|
||||
var nobody = auth.nobody(config);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// These tests check that the Schema operates correctly.
|
||||
var Config = require('../Config');
|
||||
var Schema = require('../Schema');
|
||||
var Config = require('../src/Config');
|
||||
var Schema = require('../src/Schema');
|
||||
var dd = require('deep-diff');
|
||||
|
||||
var config = new Config('test');
|
||||
@@ -252,7 +252,7 @@ describe('Schema', () => {
|
||||
it('refuses to add fields with invalid pointer types', done => {
|
||||
config.database.loadSchema()
|
||||
.then(schema => schema.addClassIfNotExists('NewClass', {
|
||||
foo: {type: 'Pointer'},
|
||||
foo: {type: 'Pointer'}
|
||||
}))
|
||||
.catch(error => {
|
||||
expect(error.code).toEqual(135);
|
||||
@@ -398,7 +398,7 @@ describe('Schema', () => {
|
||||
config.database.loadSchema()
|
||||
.then(schema => schema.addClassIfNotExists('NewClass', {
|
||||
geo1: {type: 'GeoPoint'},
|
||||
geo2: {type: 'GeoPoint'},
|
||||
geo2: {type: 'GeoPoint'}
|
||||
}))
|
||||
.catch(error => {
|
||||
expect(error.code).toEqual(Parse.Error.INCORRECT_TYPE);
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 2000;
|
||||
|
||||
var cache = require('../cache');
|
||||
var DatabaseAdapter = require('../DatabaseAdapter');
|
||||
var cache = require('../src/cache');
|
||||
var DatabaseAdapter = require('../src/DatabaseAdapter');
|
||||
var express = require('express');
|
||||
var facebook = require('../facebook');
|
||||
var ParseServer = require('../index').ParseServer;
|
||||
var facebook = require('../src/facebook');
|
||||
var ParseServer = require('../src/index').ParseServer;
|
||||
|
||||
var databaseURI = process.env.DATABASE_URI;
|
||||
var cloudMain = process.env.CLOUD_CODE_MAIN || './cloud/main.js';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var push = require('../push');
|
||||
var push = require('../src/push');
|
||||
|
||||
describe('push', () => {
|
||||
it('can check valid master key of request', (done) => {
|
||||
|
||||
@@ -16,7 +16,7 @@ var hasAllPODobject = () => {
|
||||
objACL.setPublicWriteAccess(false);
|
||||
obj.setACL(objACL);
|
||||
return obj;
|
||||
}
|
||||
};
|
||||
|
||||
var plainOldDataSchema = {
|
||||
className: 'HasAllPOD',
|
||||
@@ -35,7 +35,7 @@ var plainOldDataSchema = {
|
||||
aArray: {type: 'Array'},
|
||||
aGeoPoint: {type: 'GeoPoint'},
|
||||
aFile: {type: 'File'}
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
var pointersAndRelationsSchema = {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"*spec.js"
|
||||
],
|
||||
"helpers": [
|
||||
"../node_modules/babel-core/register.js",
|
||||
"helper.js"
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// These tests are unit tests designed to only test transform.js.
|
||||
|
||||
var transform = require('../transform');
|
||||
var transform = require('../src/transform');
|
||||
|
||||
var dummySchema = {
|
||||
data: {},
|
||||
|
||||
@@ -60,7 +60,7 @@ APNS.prototype.send = function(data, deviceTokens) {
|
||||
var generateNotification = function(coreData, expirationTime) {
|
||||
var notification = new apn.notification();
|
||||
var payload = {};
|
||||
for (key in coreData) {
|
||||
for (var key in coreData) {
|
||||
switch (key) {
|
||||
case 'alert':
|
||||
notification.setAlertText(coreData.alert);
|
||||
@@ -17,7 +17,7 @@
|
||||
var Parse = require('parse/node').Parse;
|
||||
var transform = require('./transform');
|
||||
|
||||
defaultColumns = {
|
||||
var defaultColumns = {
|
||||
// Contain the default columns for every parse object type (except _Join collection)
|
||||
_Default: {
|
||||
"objectId": {type:'String'},
|
||||
@@ -43,13 +43,13 @@ defaultColumns = {
|
||||
"GCMSenderId": {type:'String'},
|
||||
"timeZone": {type:'String'},
|
||||
"localeIdentifier": {type:'String'},
|
||||
"badge": {type:'Number'},
|
||||
"badge": {type:'Number'}
|
||||
},
|
||||
// The additional default columns for the _User collection (in addition to DefaultCols)
|
||||
_Role: {
|
||||
"name": {type:'String'},
|
||||
"users": {type:'Relation',className:'_User'},
|
||||
"roles": {type:'Relation',className:'_Role'},
|
||||
"roles": {type:'Relation',className:'_Role'}
|
||||
},
|
||||
// The additional default columns for the _User collection (in addition to DefaultCols)
|
||||
_Session: {
|
||||
@@ -58,9 +58,9 @@ defaultColumns = {
|
||||
"installationId": {type:'String'},
|
||||
"sessionToken": {type:'String'},
|
||||
"expiresAt": {type:'Date'},
|
||||
"createdWith": {type:'Object'},
|
||||
},
|
||||
}
|
||||
"createdWith": {type:'Object'}
|
||||
}
|
||||
};
|
||||
|
||||
// Valid classes must:
|
||||
// Be one of _User, _Installation, _Role, _Session OR
|
||||
@@ -221,7 +221,7 @@ Schema.prototype.addClassIfNotExists = function(className, fields) {
|
||||
error: invalidClassNameMessage(className),
|
||||
});
|
||||
}
|
||||
for (fieldName in fields) {
|
||||
for (var fieldName in fields) {
|
||||
if (!fieldNameIsValid(fieldName)) {
|
||||
return Promise.reject({
|
||||
code: Parse.Error.INVALID_KEY_NAME,
|
||||
@@ -240,18 +240,18 @@ Schema.prototype.addClassIfNotExists = function(className, fields) {
|
||||
_id: className,
|
||||
objectId: 'string',
|
||||
updatedAt: 'string',
|
||||
createdAt: 'string',
|
||||
createdAt: 'string'
|
||||
};
|
||||
for (fieldName in defaultColumns[className]) {
|
||||
validatedField = schemaAPITypeToMongoFieldType(defaultColumns[className][fieldName]);
|
||||
for (var fieldName in defaultColumns[className]) {
|
||||
var validatedField = schemaAPITypeToMongoFieldType(defaultColumns[className][fieldName]);
|
||||
if (validatedField.code) {
|
||||
return Promise.reject(validatedField);
|
||||
}
|
||||
mongoObject[fieldName] = validatedField.result;
|
||||
}
|
||||
|
||||
for (fieldName in fields) {
|
||||
validatedField = schemaAPITypeToMongoFieldType(fields[fieldName]);
|
||||
for (var fieldName in fields) {
|
||||
var validatedField = schemaAPITypeToMongoFieldType(fields[fieldName]);
|
||||
if (validatedField.code) {
|
||||
return Promise.reject(validatedField);
|
||||
}
|
||||
@@ -259,7 +259,6 @@ Schema.prototype.addClassIfNotExists = function(className, fields) {
|
||||
}
|
||||
|
||||
var geoPoints = Object.keys(mongoObject).filter(key => mongoObject[key] === 'geopoint');
|
||||
|
||||
if (geoPoints.length > 1) {
|
||||
return Promise.reject({
|
||||
code: Parse.Error.INCORRECT_TYPE,
|
||||
@@ -278,7 +277,7 @@ Schema.prototype.addClassIfNotExists = function(className, fields) {
|
||||
}
|
||||
return Promise.reject(error);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// Returns a promise that resolves successfully to the new schema
|
||||
// object or fails with a reason.
|
||||
@@ -42,7 +42,7 @@ function handleFind(req) {
|
||||
req.params.className, body.where, options)
|
||||
.then((response) => {
|
||||
if (response && response.results) {
|
||||
for (result of response.results) {
|
||||
for (var result of response.results) {
|
||||
if (result.sessionToken) {
|
||||
result.sessionToken = req.info.sessionToken || result.sessionToken;
|
||||
}
|
||||
@@ -34,8 +34,8 @@ function mongoFieldTypeToSchemaAPIType(type) {
|
||||
}
|
||||
|
||||
function mongoSchemaAPIResponseFields(schema) {
|
||||
fieldNames = Object.keys(schema).filter(key => key !== '_id' && key !== '_metadata');
|
||||
response = fieldNames.reduce((obj, fieldName) => {
|
||||
var fieldNames = Object.keys(schema).filter(key => key !== '_id' && key !== '_metadata');
|
||||
var response = fieldNames.reduce((obj, fieldName) => {
|
||||
obj[fieldName] = mongoFieldTypeToSchemaAPIType(schema[fieldName])
|
||||
return obj;
|
||||
}, {});
|
||||
@@ -21,7 +21,7 @@ var Parse = require('parse/node').Parse;
|
||||
// validate: true indicates that key names are to be validated.
|
||||
//
|
||||
// Returns an object with {key: key, value: value}.
|
||||
function transformKeyValue(schema, className, restKey, restValue, options) {
|
||||
export function transformKeyValue(schema, className, restKey, restValue, options) {
|
||||
options = options || {};
|
||||
|
||||
// Check if the schema is known since it's a built-in field.
|
||||
Reference in New Issue
Block a user