-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
47 lines (40 loc) · 1.19 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
import express from 'express';
import mongoose from 'mongoose';
import router from './routes/index.js';
import { swaggerUi, specs } from './docs.js';
const app = express();
app.use(express.json());
app.use('/', router);
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(specs));
app.get('/', async (req, res) => {
res.send(`
<body style="font-family: Arial; text-align: center">
<h1>Docs will be here! v${process.env.npm_package_version}</h1>
<div style="display: flex; justify-content: center;">
<img src="https://raw.githubusercontent.com/DionysusBenstein/Hasbik/master/hasbik.jpg">
</div>
</body>
`);
});
// Routes
/**
* @swagger
* /:
* get:
* description: Use to request all customers
* responses:
* '200':
* description: A successful response
*/
const port = process.env.PORT || 5000;
async function start() {
try {
await mongoose.connect(
`mongodb+srv://benstein:[email protected]/myFirstDatabase?retryWrites=true&w=majority`
);
app.listen(port, () => console.log(`Listening on port ${port}...`));
} catch (e) {
console.log(e);
}
}
start();