express

graphqlHTTP is not a function

荒凉一梦 提交于 2020-07-16 02:22:28
问题 Here is my simple graphql experess app const express = require('express'); const graphqlHTTP = require('express-graphql'); const app = express(); app.use( '/graphql', graphqlHTTP({ graphiql: true, }) ); app.listen(4000, () => { console.log("listening for request!"); }); I'm getting the following errors when I run it: graphqlHTTP({ ^ TypeError: graphqlHTTP is not a function at Object.<anonymous> (D:\PersonalProjects\GraphQL\server\app.js:7:5) at Module._compile (internal/modules/cjs/loader.js

Deploying node app to heroku with client and server in two separate folders

可紊 提交于 2020-07-15 06:12:41
问题 I've done a bunch of research and I can't quite seem to wrap my head around this. I've built an app. The client was built with Vue-cli and runs on port 8080 from a client folder, and the server from a separate server folder on port 8081 . In essence, I have this: client - package.json - node_modules - src - build - index.html server - package.json - node_modules - app.js - auth.js I'm unsure of how to resolve the folder structure so that I can deploy this to Heroku. According to a bunch of

Deploying node app to heroku with client and server in two separate folders

会有一股神秘感。 提交于 2020-07-15 06:12:34
问题 I've done a bunch of research and I can't quite seem to wrap my head around this. I've built an app. The client was built with Vue-cli and runs on port 8080 from a client folder, and the server from a separate server folder on port 8081 . In essence, I have this: client - package.json - node_modules - src - build - index.html server - package.json - node_modules - app.js - auth.js I'm unsure of how to resolve the folder structure so that I can deploy this to Heroku. According to a bunch of

Deploying node app to heroku with client and server in two separate folders

拜拜、爱过 提交于 2020-07-15 06:10:43
问题 I've done a bunch of research and I can't quite seem to wrap my head around this. I've built an app. The client was built with Vue-cli and runs on port 8080 from a client folder, and the server from a separate server folder on port 8081 . In essence, I have this: client - package.json - node_modules - src - build - index.html server - package.json - node_modules - app.js - auth.js I'm unsure of how to resolve the folder structure so that I can deploy this to Heroku. According to a bunch of

Deploying node app to heroku with client and server in two separate folders

▼魔方 西西 提交于 2020-07-15 06:10:16
问题 I've done a bunch of research and I can't quite seem to wrap my head around this. I've built an app. The client was built with Vue-cli and runs on port 8080 from a client folder, and the server from a separate server folder on port 8081 . In essence, I have this: client - package.json - node_modules - src - build - index.html server - package.json - node_modules - app.js - auth.js I'm unsure of how to resolve the folder structure so that I can deploy this to Heroku. According to a bunch of

Deploying node app to heroku with client and server in two separate folders

非 Y 不嫁゛ 提交于 2020-07-15 06:09:02
问题 I've done a bunch of research and I can't quite seem to wrap my head around this. I've built an app. The client was built with Vue-cli and runs on port 8080 from a client folder, and the server from a separate server folder on port 8081 . In essence, I have this: client - package.json - node_modules - src - build - index.html server - package.json - node_modules - app.js - auth.js I'm unsure of how to resolve the folder structure so that I can deploy this to Heroku. According to a bunch of

Graphql create relations between two queries.Error cannot access before initialization

孤者浪人 提交于 2020-07-10 10:37:33
问题 I have this code: const ProductType = new GraphQLObjectType({ name: 'Product', fields: { id: { type: GraphQLID }, name: { type: GraphQLString }, category: { type: CategoryType, resolve: async (parent) => { return await Category.findOne({_id: parent.category}); } } } }); const CategoryType = new GraphQLObjectType({ name: 'Category', fields: { id: { type: GraphQLID }, name: { type: GraphQLString }, products: { type: ProductType, resolve: async (parent, args) => { return await Product.find(

How to stub express middleware using sinon in typescript?

强颜欢笑 提交于 2020-07-10 10:27:35
问题 I'm trying to write an integration test for my express router using typescript, mocha, sinon and chai-http. This router uses a custom middleware that I wrote which checks for JWT in the header. Ideally, I want to stub my authMiddleware so that I can control its behaviour without actually providing valid/invalid JWT for every test case. When I try to stub authMiddleware in my tests, I realised that express app uses the actual implementation of authMiddleware rather than mocked one. I've tried

Expose HTTP GET API in GraphQL Apollo Server v2.0

我们两清 提交于 2020-07-10 10:26:43
问题 I am using Apollo Server v2.0 (without middleware) as part of my project and I would like to add support for a HTTP GET endpoint to for file downloads. Is there a way to expose an API endpoint without using apollo-server-express? Thank you 回答1: No. While apollo-server currently uses express under the hood, the Express instance is not exposed as a property on the ApolloServer instance. In order to expose any additional endpoints, you'd need to migrate to apollo-server-express or any of the

req.session returns wrong value

删除回忆录丶 提交于 2020-07-10 10:24:25
问题 app.js const mongoose = require('mongoose'); const session = require('express-session'); const MongoDBStore = require('connect-mongodb-session')(session); const MONGODB_URI = 'mongodb+srv://@cluster0-szxlh.mongodb.net/shop'; const store = new MongoDBStore({ uri: MONGODB_URI, collection: 'sessions' }); app.use( session({ secret: 'my secret', resave: false, saveUninitialized: false, store: store }) ); app.use((req, res, next) => { console.log("in app"); res.locals.isAuthenticated = req.session