MCPcopy
hub / github.com/parse-community/parse-server / startApp

Method startApp

src/ParseServer.ts:419–497  ·  view source on GitHub ↗

* starts the parse server's express app * @param {ParseServerOptions} options to use to start the server * @returns {ParseServer} the parse server instance

(options: ParseServerOptions)

Source from the content-addressed store, hash-verified

417 */
418
419 async startApp(options: ParseServerOptions) {
420 try {
421 await this.start();
422 } catch (e) {
423 // eslint-disable-next-line no-console
424 console.error('Error on ParseServer.startApp: ', e);
425 throw e;
426 }
427 const app = express();
428 if (options.middleware) {
429 let middleware;
430 if (typeof options.middleware == 'string') {
431 middleware = require(path.resolve(process.cwd(), options.middleware));
432 } else {
433 middleware = options.middleware; // use as-is let express fail
434 }
435 app.use(middleware);
436 }
437 app.use(options.mountPath, this.app);
438
439 if (options.mountGraphQL === true || options.mountPlayground === true) {
440 let graphQLCustomTypeDefs = undefined;
441 if (typeof options.graphQLSchema === 'string') {
442 graphQLCustomTypeDefs = parse(fs.readFileSync(options.graphQLSchema, 'utf8'));
443 } else if (
444 typeof options.graphQLSchema === 'object' ||
445 typeof options.graphQLSchema === 'function'
446 ) {
447 graphQLCustomTypeDefs = options.graphQLSchema;
448 }
449
450 const parseGraphQLServer = new ParseGraphQLServer(this, {
451 graphQLPath: options.graphQLPath,
452 playgroundPath: options.playgroundPath,
453 graphQLCustomTypeDefs,
454 });
455
456 if (options.mountGraphQL) {
457 parseGraphQLServer.applyGraphQL(app);
458 }
459
460 if (options.mountPlayground) {
461 parseGraphQLServer.applyPlayground(app);
462 logging.getLogger().warn(
463 'GraphQL Playground is deprecated and will be removed in a future version. It exposes the master key in the browser. Use Parse Dashboard as GraphQL IDE or configure a third-party GraphQL client with custom request headers.'
464 );
465 }
466 }
467 const server = await new Promise(resolve => {
468 app.listen(options.port, options.host, function () {
469 resolve(this);
470 });
471 });
472 this.server = server;
473 connections.track(server);
474
475 if (options.startLiveQueryServer || options.liveQueryServerOptions) {
476 this.liveQueryServer = await ParseServer.createLiveQueryServer(

Callers 6

serverFunction · 0.80
parse-server.jsFile · 0.80
reconfigureServerFunction · 0.80
FailingServer.jsFile · 0.80

Calls 10

startMethod · 0.95
applyGraphQLMethod · 0.95
applyPlaygroundMethod · 0.95
configureListenersFunction · 0.85
errorMethod · 0.80
warnMethod · 0.80
trackMethod · 0.80
createLiveQueryServerMethod · 0.80
verifyServerUrlMethod · 0.80
resolveFunction · 0.50

Tested by

no test coverage detected