New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

parse-server

Package Overview
Dependencies
Maintainers
1
Versions
433
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parse-server - npm Package Compare versions

Comparing version 1.0.16 to 2.0.0

analytics.js

181

index.js

@@ -1,10 +0,173 @@

var rebuildAndStart = require('./rebuildAndStart')
var rebuild = require('./rebuild')
var start = require('./start')
var getConfig = require('./getConfig')
// ParseServer - open-source compatible API Server for Parse apps
var batch = require('./batch'),
bodyParser = require('body-parser'),
cache = require('./cache'),
DatabaseAdapter = require('./DatabaseAdapter'),
express = require('express'),
FilesAdapter = require('./FilesAdapter'),
middlewares = require('./middlewares'),
multer = require('multer'),
Parse = require('parse/node').Parse,
PromiseRouter = require('./PromiseRouter'),
request = require('request');
// Mutate the Parse object to add the Cloud Code handlers
addParseCloud();
// ParseServer works like a constructor of an express app.
// The args that we understand are:
// "databaseAdapter": a class like ExportAdapter providing create, find,
// update, and delete
// "filesAdapter": a class like GridStoreAdapter providing create, get,
// and delete
// "databaseURI": a uri like mongodb://localhost:27017/dbname to tell us
// what database this Parse API connects to.
// "cloud": relative location to cloud code to require
// "appId": the application id to host
// "masterKey": the master key for requests to this app
// "collectionPrefix": optional prefix for database collection names
// "fileKey": optional key from Parse dashboard for supporting older files
// hosted by Parse
// "clientKey": optional key from Parse dashboard
// "dotNetKey": optional key from Parse dashboard
// "restAPIKey": optional key from Parse dashboard
// "javascriptKey": optional key from Parse dashboard
function ParseServer(args) {
if (!args.appId || !args.masterKey) {
throw 'You must provide an appId and masterKey!';
}
if (args.databaseAdapter) {
DatabaseAdapter.setAdapter(args.databaseAdapter);
}
if (args.filesAdapter) {
FilesAdapter.setAdapter(args.filesAdapter);
}
if (args.databaseURI) {
DatabaseAdapter.setDatabaseURI(args.databaseURI);
}
if (args.cloud) {
addParseCloud();
require(args.cloud);
}
cache.apps[args.appId] = {
masterKey: args.masterKey,
collectionPrefix: args.collectionPrefix || '',
clientKey: args.clientKey || '',
javascriptKey: args.javascriptKey || '',
dotNetKey: args.dotNetKey || '',
restAPIKey: args.restAPIKey || '',
fileKey: args.fileKey || 'invalid-file-key'
};
// Initialize the node client SDK automatically
Parse.initialize(args.appId, args.javascriptKey || '', args.masterKey);
// This app serves the Parse API directly.
// It's the equivalent of https://api.parse.com/1 in the hosted Parse API.
var api = express();
// File handling needs to be before default middlewares are applied
api.use('/', require('./files').router);
// TODO: separate this from the regular ParseServer object
if (process.env.TESTING == 1) {
console.log('enabling integration testing-routes');
api.use('/', require('./testing-routes').router);
}
api.use(bodyParser.json({ 'type': '*/*' }));
api.use(middlewares.allowCrossDomain);
api.use(middlewares.allowMethodOverride);
api.use(middlewares.handleParseHeaders);
var router = new PromiseRouter();
router.merge(require('./classes'));
router.merge(require('./users'));
router.merge(require('./sessions'));
router.merge(require('./roles'));
router.merge(require('./analytics'));
router.merge(require('./push'));
router.merge(require('./installations'));
router.merge(require('./functions'));
batch.mountOnto(router);
router.mountOnto(api);
api.use(middlewares.handleParseErrors);
return api;
}
function addParseCloud() {
Parse.Cloud.Functions = {};
Parse.Cloud.Triggers = {
beforeSave: {},
beforeDelete: {},
afterSave: {},
afterDelete: {}
};
Parse.Cloud.define = function(functionName, handler) {
Parse.Cloud.Functions[functionName] = handler;
};
Parse.Cloud.beforeSave = function(parseClass, handler) {
var className = getClassName(parseClass);
Parse.Cloud.Triggers.beforeSave[className] = handler;
};
Parse.Cloud.beforeDelete = function(parseClass, handler) {
var className = getClassName(parseClass);
Parse.Cloud.Triggers.beforeDelete[className] = handler;
};
Parse.Cloud.afterSave = function(parseClass, handler) {
var className = getClassName(parseClass);
Parse.Cloud.Triggers.afterSave[className] = handler;
};
Parse.Cloud.afterDelete = function(parseClass, handler) {
var className = getClassName(parseClass);
Parse.Cloud.Triggers.afterDelete[className] = handler;
};
Parse.Cloud.httpRequest = function(options) {
var promise = new Parse.Promise();
var callbacks = {
success: options.success,
error: options.error
};
delete options.success;
delete options.error;
if (options.uri && !options.url) {
options.uri = options.url;
delete options.url;
}
request(options, (error, response, body) => {
if (error) {
if (callbacks.error) {
return callbacks.error(error);
}
return promise.reject(error);
} else {
if (callbacks.success) {
return callbacks.success(body);
}
return promise.resolve(body);
}
});
return promise;
};
global.Parse = Parse;
}
function getClassName(parseClass) {
if (parseClass && parseClass.className) {
return parseClass.className;
}
return parseClass;
}
module.exports = {
rebuildAndStart: rebuildAndStart,
rebuild: rebuild,
getConfig: getConfig,
start: start
}
ParseServer: ParseServer
};

47

package.json
{
"name": "parse-server",
"version": "1.0.16",
"description": "Server boilerplate for supplier specific parsing both scraped and raw",
"version": "2.0.0",
"description": "An express module providing a Parse-compatible API server",
"main": "index.js",
"directories": {
"test": "test"
},
"scripts": {
"test": "make test"
},
"repository": {
"type": "git",
"url": "''"
"url": "https://github.com/ParsePlatform/parse-server"
},
"keywords": [
"docparse"
],
"author": "Noah Isaacson",
"license": "BSD",
"gitHead": "44011080b99310a19c6b40fbf53e9a61411ea0d3",
"dependencies": {
"eyespect": "~0.1.8",
"should": "~1.2.2",
"optimist": "~0.3.5",
"nconf": "~0.6.7",
"winston": "~0.6.2",
"winston-loggly": "~0.6.0",
"cradle": "~0.6.4",
"passport": "~0.1.16",
"required-keys": "~1.0.4",
"api-auth": "~1.0.4",
"api-middleware": "~1.0.6",
"express": "~3.1.0",
"seaport": "~1.4.0"
"bcrypt": "~0.8",
"body-parser": "~1.12.4",
"deepcopy": "^0.5.0",
"express": "~4.2.x",
"hat": "~0.0.3",
"mime": "^1.3.4",
"mongodb": "~2.0.33",
"multer": "~0.1.8",
"parse": "~1.6.12",
"request": "^2.65.0"
},
"devDependencies": {
"mocha": "git://github.com/nisaacson/mocha.git",
"request": "~2.16.2",
"create-test-users": "~1.0.1"
"jasmine": "^2.3.2"
},
"scripts": {
"test": "TESTING=1 jasmine"
}
}

@@ -1,14 +0,84 @@

Parse Server boilerplate for supplier specific parsing modules both raw and scraped
## parse-server
# Usage
See *example/devRebuildAndStart* for a complete example of spinning up a server. Execute this file with the command
A Parse.com API compatible router package for Express
---
#### Basic options:
* databaseURI (required) - The connection string for your database, i.e. `mongodb://user:pass@host.com/dbname`
* appId (required) - The application id to host with this server instance
* masterKey (required) - The master key to use for overriding ACL security
* cloud - The absolute path to your cloud code main.js file
* fileKey - For migrated apps, this is necessary to provide access to files already hosted on Parse.
#### Client key options:
The client keys used with Parse are no longer necessary with parse-server. If you wish to still require them, perhaps to be able to refuse access to older clients, you can set the keys at intialization time. Setting any of these keys will require all requests to provide one of the configured keys.
* clientKey
* javascriptKey
* restAPIKey
* dotNetKey
#### Advanced options:
* filesAdapter - The default behavior (GridStore) can be changed by creating an adapter class (see `FilesAdapter.js`)
* databaseAdapter (unfinished) - The backing store can be changed by creating an adapter class (see `DatabaseAdapter.js`)
---
### Usage
You can create an instance of ParseServer, and mount it on a new or existing Express website:
```
cd <project root>
node example/devRebuildAndStart.js --config test/config.json --role fooRole
var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var app = express();
// Specify the connection string for your mongodb database
// and the location to your Parse cloud code
var api = new ParseServer({
databaseURI: 'mongodb://localhost:27017/dev',
cloud: '/home/myApp/cloud/main.js', // Provide an absolute path
appId: 'myAppId',
masterKey: 'mySecretMasterKey',
fileKey: 'optionalFileKey'
});
// Serve the Parse API on the /parse URL prefix
app.use('/parse', api);
// Hello world
app.get('/', function(req, res) {
res.status(200).send('Express is running here.');
});
var port = process.env.PORT || 1337;
app.listen(port, function() {
console.log('parse-server-example running on port ' + port + '.');
});
```
# Installation
```bash
npm install parse-server
```
### Supported
* CRUD operations
* Schema validation
* Pointers
* Users, including Facebook login and anonymous users
* Files
* Installations
* Sessions
* Geopoints
* Roles
* Class-level Permissions (see below)
Parse server does not include a web-based dashboard, which is where class-level permissions have always been configured. If you migrate an app from Parse, you'll see the format for CLPs in the SCHEMA collection. There is also a `setPermissions` method on the `Schema` class, which you can see used in the unit-tests in `Schema.spec.js`
You can also set up an app on Parse, providing the connection string for your mongo database, and continue to use the dashboard on Parse.com.
### Not supported
* Push - We did not rebuild a new push delivery system for parse-server, but we are open to working on one together with the community.

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc