-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
48 lines (35 loc) · 1.4 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
//~ ---------- VARIABLES D'ENVIRONNEMENT
import 'dotenv/config';
// ----------- COMMONJS
// const { createServer } = require("http");
// const { ApolloServer } = require("apollo-server-express");
// const debug = require('debug')('app:server');
// const { app,apolloConfig } = require("./app");
// import { errorHandling } from './app/services/errorLoggerHandling.js';
// errorHandling.manage({message: "myError"},{url: '/test/api'})
//~ ---------- IMPORTATION APPOLOSERVER (GraphQL)
import { ApolloServer } from 'apollo-server-express';
//~ ---------- EXPRESS
import express from 'express';
const app = express();
//~ ---------- LOGGER
import debug from 'debug';
const logger = debug('EntryPoint');
logger('-------------------- Lancement du server -------------------- ')
//~ ----------
//~ ---------- IMPORTATION SCHEMA AND RESOLVERS WITH CONFIG
import { apolloConfig } from './app/index.js';
const server = new ApolloServer(apolloConfig);
//~ ---------- PORT
const PORT = process.env.PORT ?? 3000;
//~ ---------- START APOLLO SERVER
async function startServer() {
//Start instance Apollo Server
await server.start();
// Link Express with Apollo server
server.applyMiddleware({app});
await app.listen(PORT);
logger(`🚀 Server launched on http://localhost:${PORT}`);
logger('------------------------------------------------------------- ')
};
startServer();