Skip to content

Commit

Permalink
env:BASE_URL
Browse files Browse the repository at this point in the history
  • Loading branch information
jrCleber committed Jun 5, 2024
1 parent bcf70d2 commit 74dc217
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
4 changes: 4 additions & 0 deletions .env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ REDIS_ENABLED=false
REDIS_URI=redis://localhost:6379
REDIS_PREFIX=codechat

# Domínio em que a documetação será exibida
# EX.: v1.dodmain.com
BASE_URL=

# https://min.io/docs/minio/linux/index.html
S3_ENABLED=false
S3_ACCESS_KEY=access_key_id
Expand Down
6 changes: 3 additions & 3 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ info:
can build stronger and more authentic relationships with their customers, generating lasting satisfaction and loyalty.
[![Run in Postman](https://run.pstmn.io/button.svg)](https://www.postman.com/codechat/workspace/codechat-whatsapp-api/api/fbe06c7b-7647-4c71-81ee-841f5b2e90d8?action=share&creator=14064846)
version: 1.3.0
version: 1.3.1
contact:
name: jrCleber
email: [email protected]
Expand Down Expand Up @@ -1265,7 +1265,7 @@ paths:
summary: Delete Message
description: |
This endpoint is used to delete a message for everyone in a chat instance.
It requires the `instanceName` parameter in the path and the `messageId` parameter in the query.
It requires the `instanceName` parameter in the path and the `id` parameter in the query.
parameters:
- name: instanceName
in: path
Expand All @@ -1274,7 +1274,7 @@ paths:
required: true
description: '- required'
example: 'codechat_v1'
- name: messageId
- name: id
in: query
schema:
type: string
Expand Down
13 changes: 12 additions & 1 deletion src/config/scala.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,26 @@ import { Router } from 'express';
import { join } from 'path';
import YAML from 'yamljs';
import { apiReference } from '@scalar/express-api-reference';
import { readFileSync } from 'fs';

const router = Router();

const yamlFile = readFileSync(join(process.cwd(), 'docs', 'swagger.yaml'), {
encoding: 'utf8',
});

const json = YAML.parse(yamlFile);

if (process.env?.BASE_URL) {
json.servers[0].variables.prod_host.default = process.env?.BASE_URL;
}

export const docsRouter = router.use(
'/docs',
apiReference({
spec: {
content() {
return YAML.load(join(process.cwd(), 'docs', 'swagger.yaml'));
return json;
},
},
}),
Expand Down
10 changes: 5 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
* │ See the License for the specific language governing permissions and │
* │ limitations under the License. │
* │ │
* │ @function initWA @param undefined │
* | @function bootstrap @param undefined │
* ├──────────────────────────────────────────────────────────────────────────────┤
* │ @important │
Expand Down Expand Up @@ -57,10 +56,11 @@ export async function bootstrap() {
logger.log('HTTP' + ' - ON: ' + httpServer.PORT);
new Logger(configService, 'Swagger Docs').warn(
`
┌──────────────────────────────┐
│ Swagger Docs │
│ http://localhost:${httpServer.PORT}/docs │
└──────────────────────────────┘`.replace(/^ +/gm, ' '),
..
. Swagger Docs
. http://localhost:${httpServer.PORT}/docs
. https://${process.env?.BASE_URL || 'no-value'}/docs
.. `.replace(/^ +/gm, ' '),
);
});

Expand Down

0 comments on commit 74dc217

Please sign in to comment.