-
Notifications
You must be signed in to change notification settings - Fork 0
/
service.js
66 lines (55 loc) · 2.17 KB
/
service.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//Author: Hamit Yıldırım
//Date: 11.04.2021
//Version: 1.0
//Revision: 0
// I have kept the name of this file generic so that it is classified according to the job it will do.
// Our project is generally prepared to meet an api method. The structure was completely prepared by me and has not been used anywhere before.
// MongoDb atlas cloud structure was used in the project. Atlas works for a limited time and with limited IP access. It is designed to run directly when the connection of the application is changed and when it has permissions.
// Jest is used for testing
// It can be used both with NodeIDE and added as a script for debug operations.
// CURL and Postman were also used during the development phase.
// Test catch returns from async operations are intentionally left blank. Because it would be illogical to have a test as well.
// Integration has not been added to test topics, only unit test has been implemented
// Even the object-mapper is for simplicity and pine is likewise helpful when developing
const express = require('express');
require('dotenv').config()
const app = express();
const port = process.env.PORT || 3000;
//const Routers = require('./routes');
app.use(express.json());
const indexRouter = require('./routes/index');
const caseRouter = require('./routes/case.route');
const swaggerJSDoc = require('swagger-jsdoc');
const swaggerUi = require('swagger-ui-express');
const swaggerDefinition = {
openapi: '3.0.0',
info: {
title: 'Case study Api',
version: '1.0.0',
description:
'This is a REST API made with Express for special case',
license: {
name: 'Licensed Under MIT'
},
contact: {
name: 'JSONPlaceholder'
},
},
servers: [
{
url: 'http://localhost:3001',
description: 'Development RestAPI example',
},
],
};
const options = {
swaggerDefinition,
apis: ['./routes/*.js'],
}
const swaggerSpec = swaggerJSDoc(options);
app.use('/', indexRouter);
app.use('/api/case', caseRouter);
app.use("/swagger", swaggerUi.serve, swaggerUi.setup(swaggerSpec));
app.listen(port, () => {
console.log(`Server listening on the port ${port}`);
})