Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google app engine 如何在Google应用程序引擎(GCP)上部署多端口应用程序_Google App Engine_Google Cloud Platform_Graphql - Fatal编程技术网

Google app engine 如何在Google应用程序引擎(GCP)上部署多端口应用程序

Google app engine 如何在Google应用程序引擎(GCP)上部署多端口应用程序,google-app-engine,google-cloud-platform,graphql,Google App Engine,Google Cloud Platform,Graphql,我尝试在GCP上部署多端口应用程序 谁能告诉我怎么 该应用程序实际上只包括两个应用程序。。。 首先是路由器的支付功能。 其次,它是基于apollo服务器的graphQL 它们在本地工作得很好,我为graphQL调用localhost 4000,为node.js调用5000 const express = require('express'); const cors = require('cors'); const bodyParser = require('body-parser'); cons

我尝试在GCP上部署多端口应用程序 谁能告诉我怎么

该应用程序实际上只包括两个应用程序。。。 首先是路由器的支付功能。 其次,它是基于apollo服务器的graphQL

它们在本地工作得很好,我为graphQL调用localhost 4000,为node.js调用5000

const express = require('express');
const cors = require('cors');
const bodyParser = require('body-parser');
const path = require('path');
const graphqlHTTP = require('express-graphql');
const { buildSchema } = require('graphql');
const { gql } = require('apollo-server-express');
const { ApolloServer} = require('apollo-server-express');
const { GraphQLServer } = require('graphql-yoga');
const { prisma } = require('./generated/prisma-client');


const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY);
const app = express();


app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));

app.use(cors());


//be careful! The token has changed! 
app.post('/payment', (req, res) => {
  const body = {
    source: 'tok_visa',
    amount: req.body.amount,
    currency: 'usd'
  };

  stripe.charges.create(body, (stripeErr, stripeRes) => {
    if (stripeErr) {
        console.log("stripe error");
        console.log(stripeErr);

      res.status(500).send({ error: stripeErr });
    } else {
        console.log(stripeRes);
        res.status(200).send({ success: stripeRes });
    }
  });
});


const typeDefs = gql`
type Collection {
  id: ID!
  title: String! 
  items: [Item!]!
}

type Item {
  id: ID!
  name: String!
  price: Float!
  imageUrl: String!
  collection: Collection
}

type Query {
  collections: [Collection!]!
  collection(id: ID!): Collection
  getCollectionsByTitle(title: String): Collection
}
`;

const resolvers = {
  Query: {
    collections: (root, args, ctx, info) => ctx.prisma.collections({}, info),
    collection: (root, { id }, ctx) => ctx.prisma.collection({ id }),
    getCollectionsByTitle: (root, { title }, ctx) =>
      ctx.prisma.collection({ title })
  },
  Item: {
    collection: ({ id }, args, context) => {
      return context.prisma.item({ id }).collection();
    }
  },
  Collection: {
    items: ({ id }, args, context) => {
      return context.prisma.collection({ id }).items();
    }
  }
};



const server = new GraphQLServer({
  typeDefs,
  resolvers,
  context: {
    prisma
  }
});


server.start(
  {
    port:4000,
    cors: {
      origin: '*'
    }
  },
  () => console.log('GraphQL server is running')
);

// Start the server, refer to google cloud platform documentation
const PORT = process.env.PORT || 5000;
app.listen(PORT, () => {
  console.log(`App listening on port ${PORT}`);
  console.log('Press Ctrl+C to quit.');
});
// [END gae_flex_quickstart]

module.exports = app;