forked from graphql-hive/graphql-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
37 lines (32 loc) · 983 Bytes
/
index.ts
File metadata and controls
37 lines (32 loc) · 983 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
29
30
31
32
33
34
35
36
37
declare global {
namespace GraphQLModules {
interface GlobalContext {
request: any;
}
}
}
import 'reflect-metadata';
import { createApplication } from 'graphql-modules';
import http from 'http';
import { createHandler } from 'graphql-http/lib/use/http';
import { UserModule } from './app/user/user.module';
import { AuthModule } from './app/auth/auth.module';
import { SocialNetworkModule } from './app/social-network/social-network.module';
const app = createApplication({
modules: [UserModule, AuthModule, SocialNetworkModule],
});
// Create the GraphQL over HTTP Node request handler
const handler = createHandler({
schema: app.schema,
execute: app.createExecution(),
});
// Create a HTTP server using the listener on `/graphql`
const server = http.createServer((req, res) => {
if (req.url?.startsWith('/graphql')) {
handler(req, res);
} else {
res.writeHead(404).end();
}
});
server.listen(4000);
console.log('Listening to port 4000');