-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.ts
48 lines (36 loc) · 1.18 KB
/
app.ts
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
// const express = require("express");
const cors = require("cors");
const dotenv = require("dotenv");
const {graphqlHTTP} = require("express-graphql");
import express, { Request, Response } from "express";
import connectDb from "./db/db";
// const Projectroutes = require('./routes/project.route');
// const Contactroutes = require('./routes/contact.route');
// const Authroutes = require('./routes/auth.route');
const schema = require("./schema/schema");
dotenv.config({path:"./config/config.env"})
connectDb()
const app = express();
//middlewares
app.use(cors());
app.use(express.json())
//routes
app.use('/graphql',graphqlHTTP({
schema,
graphiql:process.env.NODE_ENV !== "production",
// cors:{
// origin:"https://debayan031.netlify.app/",
// credentials:true
// }
}))
// app.use('/api/projects',Projectroutes)
// app.use('/api/contact',Contactroutes)
// app.use('/api/auth',Authroutes)
app.get('/',(req : Request,res : Response)=>{
res.status(200).json("server is up and running")
})
// const PORT = process.env.PORT || 8967;
// app.listen(PORT, () => {
// console.log(`server started at: http://localhost:${PORT}`);
// })
// module.exports = app;