-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
66 lines (52 loc) · 1.55 KB
/
index.js
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// DB stuff
const { ApolloServer } = require("apollo-server");
const dotenv = require("dotenv");
const mongoose = require("mongoose");
const typeDefs = require("./graphql/typeDefs");
const resolvers = require("./graphql/resolvers");
const sendEmail = require("./emails/email");
const checkAuth = require("./util/check-auth");
// DB user athentication
dotenv.config();
const server = new ApolloServer({
typeDefs,
resolvers,
context: ({ req }) => ({ req })
});
mongoose
.connect(process.env.MONGO_DB_URL, {
useNewUrlParser: true,
useUnifiedTopology: true,
})
.then(() => {
console.log("Connected to MongoDB");
return server.listen({ port: process.env.PORT || 5000 });
})
.then((res) => {
console.log(`Server running at ${res.url}`);
});
//for pdf stuff
// const express = require('express') ;
// const bodyParser = require('body-parser');
// const pdf = require('html-pdf');
// const cors = require('cors');
// const pdfTemplate = require('./documents');
// const app = express();
// const port = 5001;
// app.use(cors());
// app.use(bodyParser.urlencoded({extended:true}));
// app.use(bodyParser.json());
// app.post('/create-pdf', (req,res) => {
// pdf.create(pdfTemplate(req.body), {}).toFile('result.pdf', (err) => {
// if(err) {
// res.send(Promise.reject());
// }
// res.send( Promise.resolve());
// })
// })
// app.get('/fetch-pdf', (req,res) => {
// sendEmail();
// res.sendFile(`${__dirname}/result.pdf`)
// })
// app.listen(port, () => console.log(`express app listening on port ${port}`));
//sendEmail();