Files
kami-parse-server/src/cli/parse-server.js

76 lines
2.3 KiB
JavaScript
Raw Normal View History

2016-02-24 08:50:04 -05:00
import path from 'path';
import express from 'express';
2016-02-24 14:20:24 -05:00
import { ParseServer } from '../index';
2016-02-24 08:50:04 -05:00
import definitions from './cli-definitions';
import program from './utils/commander';
2016-04-04 20:02:34 -04:00
import { mergeWithOptions } from './utils/commander';
2016-02-19 20:16:14 -05:00
program.loadDefinitions(definitions);
program
.usage('[options] <path/to/configuration.json>');
2016-03-15 20:22:32 -04:00
2016-02-19 20:16:14 -05:00
program.on('--help', function(){
console.log(' Get Started guide:');
console.log('');
console.log(' Please have a look at the get started guide!')
console.log(' https://github.com/ParsePlatform/parse-server/wiki/Parse-Server-Guide');
console.log('');
console.log('');
console.log(' Usage with npm start');
console.log('');
console.log(' $ npm start -- path/to/config.json');
console.log(' $ npm start -- --appId APP_ID --masterKey MASTER_KEY --serverURL serverURL');
console.log(' $ npm start -- --appId APP_ID --masterKey MASTER_KEY --serverURL serverURL');
2016-02-19 20:16:14 -05:00
console.log('');
console.log('');
console.log(' Usage:');
console.log('');
console.log(' $ parse-server path/to/config.json');
console.log(' $ parse-server -- --appId APP_ID --masterKey MASTER_KEY --serverURL serverURL');
console.log(' $ parse-server -- --appId APP_ID --masterKey MASTER_KEY --serverURL serverURL');
2016-02-19 20:16:14 -05:00
console.log('');
});
2016-03-15 20:22:32 -04:00
2016-02-19 20:16:14 -05:00
program.parse(process.argv, process.env);
2016-04-04 20:02:34 -04:00
let options = program.getOptions();
if (!options.serverURL) {
options.serverURL = `http://localhost:${options.port}${options.mountPath}`;
}
2016-02-19 20:16:14 -05:00
if (!options.appId || !options.masterKey || !options.serverURL) {
program.outputHelp();
console.error("");
Advancements with postgres (#2510) * Start DB runner from tests * Connect GridstoreAdapter only when needed * removes unused package * better test errors reporting * Adds support for __op.Delete * Better test error reporting * Makes sure all tests can run without crashing * Use xdescribe to skip test suite * Removes unused dependencies * Let volatiles classes be created with PG on start * Do not fail if class dont exist * adds index.spec.js to the pg suite * Use a new config each test to prevent side effects * Enable EmailVerificationToken specs with pg * Makes sure failure output is not cut * Reduces number of ignored tests in ParseObject.spec * Inspect reconfiguration errors * Mark GlobalConfig is incompatible with PG - Problem is with nested updates (param.prop = value) * PG: Nested JSON queries and updates - Adds support for nested json and . operator queries - Adds debug support for PG adapter - Adds loglevel support in helper * Enable working specs in ParseUser * Sets default logLevel in tests to undefined * Adds File type support, retores purchaseValidation specs * Adds support for updating jsonb objects - Restores PushController tests * Proper implementation of deleteByQuery and ORs - Adds ParseInstallation spec to the test suite * xit only failing tests * Nit on ParseAPI spec * add sorting operator * properly bound order keys * reverts describe_only_db behavior * Enables passing tests * Adds basic support for relations, upsertOneObject aliased to createObject * progress on queries options * Fix ACL update related problems * Creates relation tables on class creation * Adds Relation tests * remove flaky tests * use promises instead of CB * disable flaky test * nits * Fixes on schema spec - Next thing is to implemenet geopoint and files correctly * fix failues * Basic GeoPoint support * Adds support for $nearSphere/$maxDistance geopoint queries * enable passing tests * drop tables afterEach for PG, clean up relation tables too * Better initialization/dropTables
2016-08-15 16:48:39 -04:00
console.error('\u001b[31mERROR: appId and masterKey are required\u001b[0m');
console.error("");
process.exit(1);
}
2016-02-24 08:50:04 -05:00
const app = express();
const api = new ParseServer(options);
2016-02-19 20:16:14 -05:00
app.use(options.mountPath, api);
var server = app.listen(options.port, function() {
2016-03-15 20:22:32 -04:00
2016-02-19 20:16:14 -05:00
for (let key in options) {
2016-02-24 08:50:04 -05:00
let value = options[key];
2016-02-19 20:16:14 -05:00
if (key == "masterKey") {
value = "***REDACTED***";
}
console.log(`${key}: ${value}`);
}
console.log('');
console.log('parse-server running on '+options.serverURL);
2016-02-19 20:16:14 -05:00
});
var handleShutdown = function() {
console.log('Termination signal received. Shutting down.');
server.close(function () {
process.exit(0);
});
};
process.on('SIGTERM', handleShutdown);
process.on('SIGINT', handleShutdown);