-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
37 lines (31 loc) · 804 Bytes
/
Copy pathserver.js
File metadata and controls
37 lines (31 loc) · 804 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
// noinspection ES6UnusedImports
import {} from "./config/getENV.js";
const port = process.env.PORT || 3001;
import express from "express";
import graphqlServer from "./graphql/index.js";
import jwt from "jsonwebtoken";
export function setup(app) {
graphqlServer.applyMiddleware({
app,
});
return app;
}
if (process.env.FUNCTIONAL_TESTS !== "true") {
const app = setup(express());
// noinspection JSIgnoredPromiseFromCall
app.listen(port, () => {
console.log(`App listening at http://localhost:${port}`);
printHeaders();
});
}
function printHeaders() {
let token = jwt.sign({}, process.env.ACCESS_TOKEN_SECRET, {
expiresIn: "24h",
});
let message = `
{
"authorization": "jwt ${token}"
}
`;
console.log(message);
}