Passed
Push — main ( 90c63f...671b07 )
by Julia
02:03
created

server/app.js   A

Complexity

Total Complexity 1
Complexity/F 1

Size

Lines of Code 51
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 18
mnd 0
bc 0
fnc 1
dl 0
loc 51
rs 10
bpm 0
cpm 1
noi 1
c 0
b 0
f 0
1
import dotenv from "dotenv";
2
import express from "express";
3
import cors from "cors";
4
import morgan from "morgan";
5
6
7
8
9
dotenv.config();
10
// dotenv.config({ path: '.env' });
11
12
import apiRouter from "./routes/v1/index.js";
13
import errorHandler from "./src/middleware/error-handler.js";
14
// import apiKeyHandler from "./src/middleware/apiKey-handler.js";
15
16
const app = express();
17
const port = 1337;
18
19
app.use(morgan("dev"));
20
21
app.use(cors());
22
app.use(express.json());
23
24
app.use(express.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded
25
26
// TODO: Här kan vi lägga in en middleware för att kolla API-nyckel?
27
// app.use(apiKeyHandler);
28
29
app.use("/v1", apiRouter);
30
31
app.use(errorHandler);
32
33
// just for testing via browser
34
// import userModel from "./src/models/user.js";
35
36
37
38
// /**
39
//  * Just to check that database connection
40
//  * is working.. will remove later
41
//  */
42
// app.get("/", async (req, res) => {
43
//     const result = await userModel.allPag(10, 3);
44
//     res.json(result);
45
// });
46
47
app.listen(port, () => {
48
    console.log(`Server running on port ${port}`);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
49
});
50
51
export default app;
52