wip: swagger

This commit is contained in:
Davidson Gomes 2023-10-02 09:24:53 -03:00
parent 5c74cbfe19
commit e1ac29683d
8 changed files with 1311 additions and 2 deletions

View File

@ -1,9 +1,14 @@
# 1.5.3 (develop)
### Feature
* Swagger documentation
### Fixed
* Remove rabbitmq queues when delete instances
* Improvement in restart instance to completely redo the connection
* Update node version: v20
# 1.5.2 (2023-09-28 17:56)

View File

@ -1,4 +1,4 @@
FROM node:16.18-alpine
FROM node:20.7.0-alpine
LABEL version="1.5.2" description="Api to control whatsapp features through http requests."
LABEL maintainer="Davidson Gomes" git="https://github.com/DavidsonGomes"

View File

@ -78,7 +78,9 @@
"sharp": "^0.30.7",
"socket.io": "^4.7.1",
"socks-proxy-agent": "^8.0.1",
"uuid": "^9.0.0"
"swagger-ui-express": "^5.0.0",
"uuid": "^9.0.0",
"yamljs": "^0.3.0"
},
"devDependencies": {
"@types/compression": "^1.7.2",

View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

17
src/docs/swagger.conf.ts Normal file
View File

@ -0,0 +1,17 @@
import { Router } from 'express';
import { join } from 'path';
import swaggerUi from 'swagger-ui-express';
import YAML from 'yamljs';
const document = YAML.load(join(process.cwd(), 'src', 'docs', 'swagger.yaml'));
const router = Router();
export const swaggerRouter = router.use('/docs', swaggerUi.serve).get(
'/docs',
swaggerUi.setup(document, {
customCssUrl: '/css/dark-theme-swagger.css',
customSiteTitle: 'Evolution API',
customfavIcon: '/images/logo.svg',
}),
);

1282
src/docs/swagger.yaml Normal file

File diff suppressed because it is too large Load Diff

View File

@ -10,6 +10,7 @@ import { Auth, configService, Cors, HttpServer, Rabbitmq, Webhook } from './conf
import { onUnexpectedError } from './config/error.config';
import { Logger } from './config/logger.config';
import { ROOT_DIR } from './config/path.config';
import { swaggerRouter } from './docs/swagger.conf';
import { initAMQP } from './libs/amqp.server';
import { initIO } from './libs/socket.server';
import { ServerUP } from './utils/server-up';
@ -51,6 +52,7 @@ function bootstrap() {
app.use('/store', express.static(join(ROOT_DIR, 'store')));
app.use('/', router);
app.use(swaggerRouter);
app.use(
(err: Error, req: Request, res: Response, next: NextFunction) => {

View File

@ -40,6 +40,7 @@ router
status: HttpStatus.OK,
message: 'Welcome to the Evolution API, it is working!',
version: packageJson.version,
documentation: `${req.protocol}://${req.get('host')}/docs`,
});
})
.use('/instance', new InstanceRouter(configService, ...guards).router)