-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
28 lines (26 loc) · 863 Bytes
/
server.js
File metadata and controls
28 lines (26 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//Packages
require("dotenv/config");
const mongoose = require("mongoose");
const { graphqlUploadExpress } = require("graphql-upload");
//App & ApolloServer
const app = require("./app");
const apolloServer = require("./apollo");
async function startServer() {
app.use(graphqlUploadExpress())
await apolloServer.start();
apolloServer.applyMiddleware({ app, path: '/ebuy' });
app.use("/", (req, res) => {
res.send("Welcome to ebuy platform")
})
}
//StartServer
startServer();
mongoose.connect(process.env.MONGODB_LOCAL_URL)
.then(() => console.log("MongoDB Connected Successfully!"))
.catch((err) => console.log("MognoDB Connetion Failed!"));
//Server Creations
const port = process.env.PORT || 3001;
app.listen(port, () => {
console.log(`App is running on port ${port}`);
console.log(`GraphQl EndPoint path: /ebuy`);
})