mirror of
https://github.com/dadosfera/maestro.git
synced 2026-09-01 04:08:16 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bb72cfce45 | ||
|
|
03d17758ae | ||
|
|
b7e76a6d3f | ||
|
|
7781298e6e | ||
|
|
2c00d3249a | ||
|
|
cd7c7d538f | ||
|
|
e496d42776 | ||
|
|
a07247d538 | ||
|
|
153ba1a98b | ||
|
|
46519323f8 | ||
|
|
a51d52d68e | ||
|
|
555ff2eda9 | ||
|
|
5d1a54a720 | ||
|
|
8399a0e4c1 | ||
|
|
cf54cb0bc2 | ||
|
|
4eba099390 | ||
|
|
08fa269ce0 | ||
|
|
e52af6844b | ||
|
|
2344e4dba3 | ||
|
|
d686753f25 | ||
|
|
c1498f8f1b | ||
|
|
0b3cb581c4 | ||
|
|
97a6e05812 | ||
|
|
356d438404 | ||
|
|
cf870cff14 | ||
|
|
26c6a289eb | ||
|
|
8d27e42fcd | ||
|
|
c44e557b11 | ||
|
|
25d06ab4c5 | ||
|
|
31bb795d23 | ||
|
|
a2e25eb737 | ||
|
|
6be53bebaf | ||
|
|
741f009723 | ||
|
|
45477b5750 | ||
|
|
36de53dfd3 | ||
|
|
cd8fe2fbf6 | ||
|
|
c4a2bee69c | ||
|
|
e48d11153d | ||
|
|
c7e4de7d65 | ||
|
|
b2e7870cc5 | ||
|
|
1e239026a3 | ||
|
|
bc108d43e3 | ||
|
|
1c5b929c1b | ||
|
|
3e21c308f6 | ||
|
|
f4a5f91cbb | ||
|
|
c8aeb7f3db | ||
|
|
b9453b11cf | ||
|
|
a69752332e | ||
|
|
09c7cc79ee | ||
|
|
65f6f03e55 | ||
|
|
a54300f600 | ||
|
|
5ef85f79d3 | ||
|
|
a8a429977f | ||
|
|
692a9de0af | ||
|
|
7dc669ca44 | ||
|
|
e897da1ef0 | ||
|
|
b366e786ba | ||
|
|
24d56c7a58 | ||
|
|
d7f205901b | ||
|
|
7212c5249c |
@@ -2,117 +2,109 @@ name: Deploy
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- alpha
|
||||
- beta
|
||||
- main
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
environment:
|
||||
description: 'Deployment environment'
|
||||
required: true
|
||||
type: choice
|
||||
options:
|
||||
- dev
|
||||
- stg
|
||||
- prd
|
||||
|
||||
jobs:
|
||||
extract_environment:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
environment: ${{ steps.extract_environment.outputs.environment }}
|
||||
env:
|
||||
EVENT: ${{ github.event_name }}
|
||||
DEPLOY_ENV: ${{ github.event.inputs.environment }}
|
||||
steps:
|
||||
- name: Extract Environment
|
||||
run: |
|
||||
if [ ${GITHUB_REF} == "refs/heads/main" ]; then
|
||||
if [ ${EVENT} == "workflow_dispatch" ]; then
|
||||
echo "##[set-output name=environment;]$(echo ${DEPLOY_ENV})"
|
||||
elif [ ${GITHUB_REF} == "refs/heads/main" ]; then
|
||||
echo "##[set-output name=environment;]$(echo "prd")"
|
||||
elif [ ${GITHUB_REF} == "refs/heads/alpha" ]; then
|
||||
echo "##[set-output name=environment;]$(echo "dev")"
|
||||
elif [ ${GITHUB_REF} == "refs/heads/beta" ]; then
|
||||
echo "##[set-output name=environment;]$(echo "stg")"
|
||||
fi
|
||||
id: extract_environment
|
||||
|
||||
semantic_release:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
#new_release_published: ${{ steps.semantic.outputs.last_release_version != steps.semantic.outputs.new_release_version }}
|
||||
new_release_published: ${{ steps.semantic.outputs.new_release_published }}
|
||||
new_release_version: ${{ steps.semantic.outputs.new_release_version }}
|
||||
#new_release_version: ${{ steps.semantic.outputs.new_release_version }}
|
||||
new_release_version: ${{ (steps.semantic.outputs.new_release_published == 'true' && steps.semantic.outputs.new_release_version) || (github.event_name == 'workflow_dispatch' && '0.0.0') }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Semantic Release
|
||||
- if: github.event_name != 'workflow_dispatch'
|
||||
name: Semantic Release
|
||||
uses: cycjimmy/semantic-release-action@v2
|
||||
id: semantic
|
||||
with:
|
||||
semantic_version: 16
|
||||
extra_plugins: |
|
||||
@saithodev/semantic-release-backmerge
|
||||
conventional-changelog-eslint
|
||||
branches: |
|
||||
[
|
||||
'main',
|
||||
{
|
||||
name: 'alpha',
|
||||
prerelease: true
|
||||
},
|
||||
{
|
||||
name: 'beta',
|
||||
prerelease: true
|
||||
}
|
||||
'main'
|
||||
]
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
deploy:
|
||||
if: ${{ github.event_name == 'workflow_dispatch' || needs.semantic_release.outputs.new_release_published == 'true' }}
|
||||
needs: [extract_environment, semantic_release]
|
||||
runs-on: [self-hosted, "${{ needs.extract_environment.outputs.environment }}"]
|
||||
runs-on:
|
||||
[self-hosted, '${{ needs.extract_environment.outputs.environment }}']
|
||||
|
||||
steps:
|
||||
- name: Printing stats
|
||||
env:
|
||||
EVENT: ${{ github.event_name }}
|
||||
IMAGE_TAG: ${{ needs.semantic_release.outputs.new_release_version }}
|
||||
ENV: ${{ needs.extract_environment.outputs.environment }}
|
||||
run: echo ${GITHUB_REF#refs/heads/}
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Update Pip
|
||||
if: needs.semantic_release.outputs.new_release_published == 'true'
|
||||
run: |
|
||||
python3 -m pip install --upgrade pip
|
||||
|
||||
- name: Install Docker Compose
|
||||
if: needs.semantic_release.outputs.new_release_published == 'true'
|
||||
run: |
|
||||
python3 -m pip install docker-compose --upgrade
|
||||
|
||||
- name: Install AWS CLI
|
||||
if: needs.semantic_release.outputs.new_release_published == 'true'
|
||||
run: |
|
||||
python3 -m pip install awscli --upgrade
|
||||
|
||||
- name: Install AWS Elastic Beanstalk CLI
|
||||
if: needs.semantic_release.outputs.new_release_published == 'true'
|
||||
run: |
|
||||
python3 -m pip install awsebcli --upgrade
|
||||
|
||||
- name: Configure AWS Region
|
||||
if: needs.semantic_release.outputs.new_release_published == 'true'
|
||||
uses: aws-actions/configure-aws-credentials@v1
|
||||
id: aws
|
||||
with:
|
||||
aws-region: us-east-1
|
||||
|
||||
- name: Extract Environment
|
||||
if: needs.semantic_release.outputs.new_release_published == 'true'
|
||||
shell: bash
|
||||
run: |
|
||||
if [ ${GITHUB_REF} == "refs/heads/main" ]; then
|
||||
echo "##[set-output name=result;]$(echo "prd")"
|
||||
elif [ ${GITHUB_REF} == "refs/heads/alpha" ]; then
|
||||
echo "##[set-output name=result;]$(echo "dev")"
|
||||
elif [ ${GITHUB_REF} == "refs/heads/beta" ]; then
|
||||
echo "##[set-output name=result;]$(echo "stg")"
|
||||
fi
|
||||
id: extract_environment
|
||||
|
||||
- name: Login to AWS ECR
|
||||
if: needs.semantic_release.outputs.new_release_published == 'true'
|
||||
id: login_ecr
|
||||
uses: aws-actions/amazon-ecr-login@v1
|
||||
|
||||
- name: Build, Tag, and Push Image to AWS ECR
|
||||
if: needs.semantic_release.outputs.new_release_published == 'true'
|
||||
env:
|
||||
ENV: ${{ steps.extract_environment.outputs.result }}
|
||||
ENV: ${{ needs.extract_environment.outputs.environment }}
|
||||
IMAGE_TAG: ${{ needs.semantic_release.outputs.new_release_version }}
|
||||
ACCOUNT_ID: ${{ steps.aws.outputs.aws-account-id }}
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
@@ -121,9 +113,8 @@ jobs:
|
||||
docker-compose -f build.docker-compose.yml push
|
||||
|
||||
- name: Create ZIP file to Deploy AWS Beanstalk
|
||||
if: needs.semantic_release.outputs.new_release_published == 'true'
|
||||
env:
|
||||
ENV: ${{ steps.extract_environment.outputs.result }}
|
||||
ENV: ${{ needs.extract_environment.outputs.environment }}
|
||||
IMAGE_TAG: ${{ needs.semantic_release.outputs.new_release_version }}
|
||||
ACCOUNT_ID: ${{ steps.aws.outputs.aws-account-id }}
|
||||
run: |
|
||||
@@ -133,11 +124,10 @@ jobs:
|
||||
zip deploy.zip docker-compose.yml -r .ebextensions
|
||||
|
||||
- name: Deploy AWS Beanstalk
|
||||
if: needs.semantic_release.outputs.new_release_published == 'true'
|
||||
env:
|
||||
ENV: ${{ steps.extract_environment.outputs.result }}
|
||||
ENV: ${{ needs.extract_environment.outputs.environment }}
|
||||
AWS_REGION: us-east-1
|
||||
APP_NAME: maestro
|
||||
APP_NAME: ${{ github.event.repository.name }}
|
||||
run: |
|
||||
eb use $APP_NAME-$ENV
|
||||
echo -e "deploy:\n artifact: deploy.zip" >> .elasticbeanstalk/config.yml
|
||||
+1
-1
@@ -29,7 +29,7 @@ lerna-debug.log*
|
||||
|
||||
# IDE - VSCode
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
#!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
|
||||
@@ -26,18 +26,6 @@
|
||||
"preset": "eslint"
|
||||
}
|
||||
],
|
||||
[
|
||||
"@saithodev/semantic-release-backmerge",
|
||||
{
|
||||
"branches": [
|
||||
{ "from": "main", "to": "alpha" },
|
||||
{ "from": "main", "to": "beta" }
|
||||
],
|
||||
"backmergeStrategy": "merge",
|
||||
"clearWorkspace": true,
|
||||
"restoreWorkspace": true
|
||||
}
|
||||
],
|
||||
"@semantic-release/npm",
|
||||
"@semantic-release/github"
|
||||
]
|
||||
|
||||
@@ -1,4 +1,50 @@
|
||||
# Maestro
|
||||
<p align="center">
|
||||
<image src="./assets/maestro.svg" style="width:10rem">
|
||||
<h1 align="center">Maestro</h1>
|
||||
</p>
|
||||
<h1 align="center">Maestro</h1>
|
||||
</p>
|
||||
This is the Dadosfera´s gateway repository, it´s responsable for the communication between frontend application and Dadosfera´s mirosservices.
|
||||
|
||||
## 💻 Requirements
|
||||
|
||||
Before you start, make sure you have done the following steps:
|
||||
|
||||
* Installed Nodejs version 16.14.2
|
||||
* Installed latest NPM version
|
||||
|
||||
|
||||
|
||||
## 🚀 Installing Maestro
|
||||
|
||||
First of all clone the repository:
|
||||
* SSH:
|
||||
```
|
||||
git clone git@github.com:dadosfera/maestro.git
|
||||
```
|
||||
* HTTPS:
|
||||
```
|
||||
git clone git@github.com:dadosfera/maestro.git
|
||||
```
|
||||
|
||||
## Enviroment variables
|
||||
|
||||
Here is a list of enviroment variables needed in order to run the application correctly.
|
||||
|
||||
```
|
||||
ENV=
|
||||
DUC_URL=
|
||||
INFACTORY_URL=
|
||||
TRFACTORY_URL=
|
||||
OTFACTORY_URL=
|
||||
PIFACTORY_URL=
|
||||
JWT_PRIVATE_KEY=
|
||||
AWS_IDENTITY_POOL_ID=
|
||||
```
|
||||
|
||||
## Running Maestro
|
||||
|
||||
In order to run Maestro just run the following command:
|
||||
```
|
||||
npm run start:dev
|
||||
```
|
||||
If everything is fine the Maestro will start and be ready to receive HTTP requests
|
||||
Generated
+146
-28
@@ -17,8 +17,9 @@
|
||||
"@nestjs/mapped-types": "*",
|
||||
"@nestjs/microservices": "^8.4.3",
|
||||
"@nestjs/platform-express": "^8.4.3",
|
||||
"@nestjs/schedule": "^1.1.0",
|
||||
"@nestjs/swagger": "^5.2.1",
|
||||
"@victorradael/protospack": "^1.6.5",
|
||||
"@victorradael/protospack": "2.4.1-1",
|
||||
"axios": "^0.25.0",
|
||||
"dotenv": "^14.2.0",
|
||||
"helmet": "^5.0.2",
|
||||
@@ -45,6 +46,7 @@
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"eslint-plugin-prettier": "^4.0.0",
|
||||
"jest": "^27.5.1",
|
||||
"nock": "^13.2.4",
|
||||
"prettier": "^2.6.1",
|
||||
"source-map-support": "^0.5.20",
|
||||
"supertest": "^6.1.3",
|
||||
@@ -1580,6 +1582,20 @@
|
||||
"@nestjs/core": "^8.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@nestjs/schedule": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/schedule/-/schedule-1.1.0.tgz",
|
||||
"integrity": "sha512-0QpbwClUildXqlyoaygG+aIQZNNMv31XDyQxX+Ob1zw/3I8+AVrDlBwZHQ+tlhIcJFR8aG+VTH8xwIjXwtS1UA==",
|
||||
"dependencies": {
|
||||
"cron": "1.8.2",
|
||||
"uuid": "8.3.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@nestjs/common": "^6.10.11 || ^7.0.0 || ^8.0.0",
|
||||
"@nestjs/core": "^7.0.0 || ^8.0.0",
|
||||
"reflect-metadata": "^0.1.12"
|
||||
}
|
||||
},
|
||||
"node_modules/@nestjs/schematics": {
|
||||
"version": "8.0.8",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/schematics/-/schematics-8.0.8.tgz",
|
||||
@@ -2344,9 +2360,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@victorradael/protospack": {
|
||||
"version": "1.6.5",
|
||||
"resolved": "https://registry.npmjs.org/@victorradael/protospack/-/protospack-1.6.5.tgz",
|
||||
"integrity": "sha512-WuRHsvjyprZTrA+L/LmuR0x4d/GLxO/rprQAMqQ5PzZmMViMQSrN6IGX6umJKHImLhVeRkNEGsysjAxHc4V12Q==",
|
||||
"version": "2.4.1-1",
|
||||
"resolved": "https://registry.npmjs.org/@victorradael/protospack/-/protospack-2.4.1-1.tgz",
|
||||
"integrity": "sha512-QpdnjOiSil1sPvOVuSC1mu5Z76ZDF1+QbDDe/RI3WVWo39dxARBxOxp7/biRY6KLxTPvSUOQbrBAg7Bfx0ul+A==",
|
||||
"dependencies": {
|
||||
"rxjs": "^7.5.5"
|
||||
}
|
||||
@@ -3517,6 +3533,14 @@
|
||||
"integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/cron": {
|
||||
"version": "1.8.2",
|
||||
"resolved": "https://registry.npmjs.org/cron/-/cron-1.8.2.tgz",
|
||||
"integrity": "sha512-Gk2c4y6xKEO8FSAUTklqtfSr7oTq0CiPQeLBG5Fl0qoXpZyMcj1SG59YL+hqq04bu6/IuEA7lMkYDAplQNKkyg==",
|
||||
"dependencies": {
|
||||
"moment-timezone": "^0.5.x"
|
||||
}
|
||||
},
|
||||
"node_modules/cross-spawn": {
|
||||
"version": "7.0.3",
|
||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
||||
@@ -4715,20 +4739,6 @@
|
||||
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
|
||||
},
|
||||
"node_modules/fsevents": {
|
||||
"version": "2.3.2",
|
||||
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
|
||||
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/function-bind": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
|
||||
@@ -6364,6 +6374,12 @@
|
||||
"integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/json-stringify-safe": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz",
|
||||
"integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/json5": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.0.tgz",
|
||||
@@ -6570,6 +6586,12 @@
|
||||
"resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz",
|
||||
"integrity": "sha1-DdOXEhPHxW34gJd9UEyI+0cal6w="
|
||||
},
|
||||
"node_modules/lodash.set": {
|
||||
"version": "4.3.2",
|
||||
"resolved": "https://registry.npmjs.org/lodash.set/-/lodash.set-4.3.2.tgz",
|
||||
"integrity": "sha1-2HV7HagH3eJIFrDWqEvqGnYjCyM=",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/log-symbols": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz",
|
||||
@@ -6816,6 +6838,25 @@
|
||||
"mkdirp": "bin/cmd.js"
|
||||
}
|
||||
},
|
||||
"node_modules/moment": {
|
||||
"version": "2.29.3",
|
||||
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.3.tgz",
|
||||
"integrity": "sha512-c6YRvhEo//6T2Jz/vVtYzqBzwvPT95JBQ+smCytzf7c50oMZRsR/a4w88aD34I+/QVSfnoAnSBFPJHItlOMJVw==",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/moment-timezone": {
|
||||
"version": "0.5.34",
|
||||
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.34.tgz",
|
||||
"integrity": "sha512-3zAEHh2hKUs3EXLESx/wsgw6IQdusOT8Bxm3D9UrHPQR7zlMmzwybC8zHEM1tQ4LJwP7fcxrWr8tuBg05fFCbg==",
|
||||
"dependencies": {
|
||||
"moment": ">= 2.9.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/ms": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||
@@ -6865,6 +6906,21 @@
|
||||
"integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/nock": {
|
||||
"version": "13.2.4",
|
||||
"resolved": "https://registry.npmjs.org/nock/-/nock-13.2.4.tgz",
|
||||
"integrity": "sha512-8GPznwxcPNCH/h8B+XZcKjYPXnUV5clOKCjAqyjsiqA++MpNx9E9+t8YPp0MbThO+KauRo7aZJ1WuIZmOrT2Ug==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"debug": "^4.1.0",
|
||||
"json-stringify-safe": "^5.0.1",
|
||||
"lodash.set": "^4.3.2",
|
||||
"propagate": "^2.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 10.13"
|
||||
}
|
||||
},
|
||||
"node_modules/node-emoji": {
|
||||
"version": "1.11.0",
|
||||
"resolved": "https://registry.npmjs.org/node-emoji/-/node-emoji-1.11.0.tgz",
|
||||
@@ -7351,6 +7407,15 @@
|
||||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/propagate": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/propagate/-/propagate-2.0.1.tgz",
|
||||
"integrity": "sha512-vGrhOavPSTz4QVNuBNdcNXePNdNMaO1xj9yBeH1ScQPjk/rhg9sSlCXPhMkFuaNNW/syTvYqsnbIJxMBfRbbag==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/protobufjs": {
|
||||
"version": "6.11.2",
|
||||
"resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.11.2.tgz",
|
||||
@@ -10307,6 +10372,15 @@
|
||||
"tslib": "2.3.1"
|
||||
}
|
||||
},
|
||||
"@nestjs/schedule": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/schedule/-/schedule-1.1.0.tgz",
|
||||
"integrity": "sha512-0QpbwClUildXqlyoaygG+aIQZNNMv31XDyQxX+Ob1zw/3I8+AVrDlBwZHQ+tlhIcJFR8aG+VTH8xwIjXwtS1UA==",
|
||||
"requires": {
|
||||
"cron": "1.8.2",
|
||||
"uuid": "8.3.2"
|
||||
}
|
||||
},
|
||||
"@nestjs/schematics": {
|
||||
"version": "8.0.8",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/schematics/-/schematics-8.0.8.tgz",
|
||||
@@ -10904,9 +10978,9 @@
|
||||
}
|
||||
},
|
||||
"@victorradael/protospack": {
|
||||
"version": "1.6.5",
|
||||
"resolved": "https://registry.npmjs.org/@victorradael/protospack/-/protospack-1.6.5.tgz",
|
||||
"integrity": "sha512-WuRHsvjyprZTrA+L/LmuR0x4d/GLxO/rprQAMqQ5PzZmMViMQSrN6IGX6umJKHImLhVeRkNEGsysjAxHc4V12Q==",
|
||||
"version": "2.4.1-1",
|
||||
"resolved": "https://registry.npmjs.org/@victorradael/protospack/-/protospack-2.4.1-1.tgz",
|
||||
"integrity": "sha512-QpdnjOiSil1sPvOVuSC1mu5Z76ZDF1+QbDDe/RI3WVWo39dxARBxOxp7/biRY6KLxTPvSUOQbrBAg7Bfx0ul+A==",
|
||||
"requires": {
|
||||
"rxjs": "^7.5.5"
|
||||
}
|
||||
@@ -11845,6 +11919,14 @@
|
||||
"integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==",
|
||||
"dev": true
|
||||
},
|
||||
"cron": {
|
||||
"version": "1.8.2",
|
||||
"resolved": "https://registry.npmjs.org/cron/-/cron-1.8.2.tgz",
|
||||
"integrity": "sha512-Gk2c4y6xKEO8FSAUTklqtfSr7oTq0CiPQeLBG5Fl0qoXpZyMcj1SG59YL+hqq04bu6/IuEA7lMkYDAplQNKkyg==",
|
||||
"requires": {
|
||||
"moment-timezone": "^0.5.x"
|
||||
}
|
||||
},
|
||||
"cross-spawn": {
|
||||
"version": "7.0.3",
|
||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
||||
@@ -12769,13 +12851,6 @@
|
||||
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
|
||||
},
|
||||
"fsevents": {
|
||||
"version": "2.3.2",
|
||||
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
|
||||
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"function-bind": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
|
||||
@@ -14013,6 +14088,12 @@
|
||||
"integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=",
|
||||
"dev": true
|
||||
},
|
||||
"json-stringify-safe": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz",
|
||||
"integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=",
|
||||
"dev": true
|
||||
},
|
||||
"json5": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.0.tgz",
|
||||
@@ -14191,6 +14272,12 @@
|
||||
"resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz",
|
||||
"integrity": "sha1-DdOXEhPHxW34gJd9UEyI+0cal6w="
|
||||
},
|
||||
"lodash.set": {
|
||||
"version": "4.3.2",
|
||||
"resolved": "https://registry.npmjs.org/lodash.set/-/lodash.set-4.3.2.tgz",
|
||||
"integrity": "sha1-2HV7HagH3eJIFrDWqEvqGnYjCyM=",
|
||||
"dev": true
|
||||
},
|
||||
"log-symbols": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz",
|
||||
@@ -14375,6 +14462,19 @@
|
||||
"minimist": "^1.2.5"
|
||||
}
|
||||
},
|
||||
"moment": {
|
||||
"version": "2.29.3",
|
||||
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.3.tgz",
|
||||
"integrity": "sha512-c6YRvhEo//6T2Jz/vVtYzqBzwvPT95JBQ+smCytzf7c50oMZRsR/a4w88aD34I+/QVSfnoAnSBFPJHItlOMJVw=="
|
||||
},
|
||||
"moment-timezone": {
|
||||
"version": "0.5.34",
|
||||
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.34.tgz",
|
||||
"integrity": "sha512-3zAEHh2hKUs3EXLESx/wsgw6IQdusOT8Bxm3D9UrHPQR7zlMmzwybC8zHEM1tQ4LJwP7fcxrWr8tuBg05fFCbg==",
|
||||
"requires": {
|
||||
"moment": ">= 2.9.0"
|
||||
}
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||
@@ -14418,6 +14518,18 @@
|
||||
"integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==",
|
||||
"dev": true
|
||||
},
|
||||
"nock": {
|
||||
"version": "13.2.4",
|
||||
"resolved": "https://registry.npmjs.org/nock/-/nock-13.2.4.tgz",
|
||||
"integrity": "sha512-8GPznwxcPNCH/h8B+XZcKjYPXnUV5clOKCjAqyjsiqA++MpNx9E9+t8YPp0MbThO+KauRo7aZJ1WuIZmOrT2Ug==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"debug": "^4.1.0",
|
||||
"json-stringify-safe": "^5.0.1",
|
||||
"lodash.set": "^4.3.2",
|
||||
"propagate": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"node-emoji": {
|
||||
"version": "1.11.0",
|
||||
"resolved": "https://registry.npmjs.org/node-emoji/-/node-emoji-1.11.0.tgz",
|
||||
@@ -14773,6 +14885,12 @@
|
||||
"sisteransi": "^1.0.5"
|
||||
}
|
||||
},
|
||||
"propagate": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/propagate/-/propagate-2.0.1.tgz",
|
||||
"integrity": "sha512-vGrhOavPSTz4QVNuBNdcNXePNdNMaO1xj9yBeH1ScQPjk/rhg9sSlCXPhMkFuaNNW/syTvYqsnbIJxMBfRbbag==",
|
||||
"dev": true
|
||||
},
|
||||
"protobufjs": {
|
||||
"version": "6.11.2",
|
||||
"resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.11.2.tgz",
|
||||
|
||||
+6
-1
@@ -29,8 +29,9 @@
|
||||
"@nestjs/mapped-types": "*",
|
||||
"@nestjs/microservices": "^8.4.3",
|
||||
"@nestjs/platform-express": "^8.4.3",
|
||||
"@nestjs/schedule": "^1.1.0",
|
||||
"@nestjs/swagger": "^5.2.1",
|
||||
"@victorradael/protospack": "^1.6.5",
|
||||
"@victorradael/protospack": "2.4.1",
|
||||
"axios": "^0.25.0",
|
||||
"dotenv": "^14.2.0",
|
||||
"helmet": "^5.0.2",
|
||||
@@ -41,6 +42,9 @@
|
||||
"rxjs": "^7.5.5",
|
||||
"swagger-ui-express": "^4.3.0"
|
||||
},
|
||||
"overrides":{
|
||||
"busboy@<1.6.0":"1.6.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/cli": "^8.2.4",
|
||||
"@nestjs/schematics": "^8.0.8",
|
||||
@@ -57,6 +61,7 @@
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"eslint-plugin-prettier": "^4.0.0",
|
||||
"jest": "^27.5.1",
|
||||
"nock": "^13.2.4",
|
||||
"prettier": "^2.6.1",
|
||||
"source-map-support": "^0.5.20",
|
||||
"supertest": "^6.1.3",
|
||||
|
||||
@@ -10,7 +10,9 @@ export class AuthClient {
|
||||
options: {
|
||||
url: process.env.DUC_URL,
|
||||
package: DucPackages,
|
||||
credentials: credentials.createSsl(),
|
||||
credentials: process.env.LOCAL_ENV
|
||||
? undefined
|
||||
: credentials.createSsl(),
|
||||
protoPath: DucProtoFilePath,
|
||||
loader: {
|
||||
enums: String,
|
||||
|
||||
@@ -2,12 +2,18 @@ import { OnModuleInit, Inject } from '@nestjs/common';
|
||||
import { ClientGrpc } from '@nestjs/microservices';
|
||||
|
||||
import {
|
||||
AuthServiceInterface,
|
||||
DucServicesNames,
|
||||
AuthServiceInterface,
|
||||
AuthSignInRequest,
|
||||
AuthRefreshAccessTokenRequest,
|
||||
AuthConfirmationRequest,
|
||||
AuthResendConfirmationCodeRequest,
|
||||
AuthEnableTotpMfaRequest,
|
||||
AuthDisableTotpMfaRequest,
|
||||
AuthDismissTotpMfaRequest,
|
||||
AuthVerifyTotpMfaRequest,
|
||||
} from '@victorradael/protospack';
|
||||
|
||||
import { ILogin } from './interfaces';
|
||||
|
||||
export class AuthClientService implements OnModuleInit {
|
||||
private authService: AuthServiceInterface;
|
||||
constructor(
|
||||
@@ -20,11 +26,99 @@ export class AuthClientService implements OnModuleInit {
|
||||
);
|
||||
}
|
||||
|
||||
async signIn({ username, password, totp }: ILogin): Promise<any> {
|
||||
async signIn({ username, password, totp }: AuthSignInRequest): Promise<any> {
|
||||
console.log('AuthClientService', 'SignIn');
|
||||
|
||||
const tokens = await new Promise((resolve, reject) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.authService.signIn({ username, password, totp }).subscribe({
|
||||
next: resolve,
|
||||
//error: (err) => reject(err.details),
|
||||
error: (err) => {
|
||||
console.log(err);
|
||||
reject(err.details);
|
||||
},
|
||||
complete() {
|
||||
console.log('done');
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async enableTotpMFA({
|
||||
accessToken,
|
||||
password,
|
||||
}: AuthEnableTotpMfaRequest): Promise<any> {
|
||||
console.log('AuthClientService', 'enableTotpMFA');
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.authService.enableTotpMfa({ accessToken, password }).subscribe({
|
||||
next: resolve,
|
||||
error: (err) => reject(err.details),
|
||||
complete() {
|
||||
console.log('done');
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async disableTotpMFA({
|
||||
accessToken,
|
||||
password,
|
||||
}: AuthDisableTotpMfaRequest): Promise<any> {
|
||||
console.log('AuthClientService', 'disableTotpMFA');
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.authService.disableTotpMfa({ accessToken, password }).subscribe({
|
||||
next: resolve,
|
||||
error: (err) => reject(err.details),
|
||||
complete() {
|
||||
console.log('done');
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async dismissTotpMFA({
|
||||
accessToken,
|
||||
}: AuthDismissTotpMfaRequest): Promise<any> {
|
||||
console.log('AuthClientService', 'dismissTotpMFA');
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.authService.dismissTotpMfa({ accessToken }).subscribe({
|
||||
next: resolve,
|
||||
error: (err) => reject(err.details),
|
||||
complete() {
|
||||
console.log('done');
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async verifyTotp({
|
||||
accessToken,
|
||||
totp,
|
||||
}: AuthVerifyTotpMfaRequest): Promise<any> {
|
||||
console.log('AuthClientService', 'disableTotpMFA');
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.authService.verifyTotp({ accessToken, totp }).subscribe({
|
||||
next: resolve,
|
||||
error: (err) => reject(err.details),
|
||||
complete() {
|
||||
console.log('done');
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async confirmRegister({
|
||||
username,
|
||||
code,
|
||||
}: AuthConfirmationRequest): Promise<any> {
|
||||
console.log('AuthClientService', 'confirmRegister');
|
||||
|
||||
const tokens = await new Promise((resolve, reject) => {
|
||||
this.authService.confirmRegister({ username, code }).subscribe({
|
||||
next(x) {
|
||||
resolve(x);
|
||||
},
|
||||
@@ -43,4 +137,48 @@ export class AuthClientService implements OnModuleInit {
|
||||
});
|
||||
return tokens;
|
||||
}
|
||||
|
||||
async resendeConfirmationCode({
|
||||
username,
|
||||
}: AuthResendConfirmationCodeRequest): Promise<any> {
|
||||
console.log('AuthClientService', 'resendConfirmationCode');
|
||||
|
||||
const authResendConfirmationCodeRequestReturn = await new Promise(
|
||||
(resolve, reject) => {
|
||||
this.authService.resendConfirmationCode({ username }).subscribe({
|
||||
next(x) {
|
||||
resolve(x);
|
||||
},
|
||||
error(err) {
|
||||
console.log('Observable Error');
|
||||
reject(err);
|
||||
},
|
||||
complete() {
|
||||
console.log('done');
|
||||
},
|
||||
});
|
||||
},
|
||||
)
|
||||
.then((res) => res)
|
||||
.catch((err) => {
|
||||
throw new Error(err);
|
||||
});
|
||||
return authResendConfirmationCodeRequestReturn;
|
||||
}
|
||||
|
||||
async refreshAccessToken({
|
||||
refreshToken,
|
||||
}: AuthRefreshAccessTokenRequest): Promise<any> {
|
||||
console.log('AuthClientService', 'RefreshAccessToken');
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.authService.refreshAccessToken({ refreshToken }).subscribe({
|
||||
next: resolve,
|
||||
error: (err) => reject(err.details),
|
||||
complete() {
|
||||
console.log('done');
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
-5
@@ -1,5 +0,0 @@
|
||||
export interface ILogin {
|
||||
username: string;
|
||||
password: string;
|
||||
totp: string;
|
||||
}
|
||||
@@ -10,7 +10,9 @@ export class InputsClientConfiguration {
|
||||
options: {
|
||||
url: process.env.INFACTORY_URL,
|
||||
package: InputPackages,
|
||||
credentials: credentials.createSsl(),
|
||||
credentials: process.env.LOCAL_ENV
|
||||
? undefined
|
||||
: credentials.createSsl(),
|
||||
protoPath: InputProtoFilePath,
|
||||
loader: {
|
||||
enums: String,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { OnModuleInit, Inject } from '@nestjs/common';
|
||||
import { ClientGrpc } from '@nestjs/microservices';
|
||||
import {
|
||||
InputCreateResponse,
|
||||
InputCreateS3Request,
|
||||
InputNewCreateRequest,
|
||||
InputService,
|
||||
TestConnectionGetColumnsRequest,
|
||||
@@ -41,6 +43,29 @@ export class InputsClientService implements OnModuleInit {
|
||||
console.log('done');
|
||||
},
|
||||
});
|
||||
}).catch((err) => {
|
||||
throw new Error(err);
|
||||
});
|
||||
|
||||
return createInputResponse;
|
||||
}
|
||||
|
||||
async createS3Inputs(createInputDto: InputCreateS3Request) {
|
||||
console.log('InputClientService', 'Create');
|
||||
|
||||
const createInputResponse = await new Promise((resolve, reject) => {
|
||||
this.inputService.CreateS3(objectSnakeToCamel(createInputDto)).subscribe({
|
||||
next(x) {
|
||||
resolve(objectCamelToSnake(x));
|
||||
},
|
||||
error(err) {
|
||||
console.log('Observable Error');
|
||||
reject(err);
|
||||
},
|
||||
complete() {
|
||||
console.log('done');
|
||||
},
|
||||
});
|
||||
})
|
||||
.then((res) => res)
|
||||
.catch((err) => {
|
||||
|
||||
@@ -9,7 +9,9 @@ export class OutputsClientConfiguration {
|
||||
options: {
|
||||
url: process.env.OTFACTORY_URL,
|
||||
package: OutputPackages,
|
||||
credentials: credentials.createSsl(),
|
||||
credentials: process.env.LOCAL_ENV
|
||||
? undefined
|
||||
: credentials.createSsl(),
|
||||
protoPath: OutputProtoFilePath,
|
||||
loader: {
|
||||
enums: String,
|
||||
|
||||
@@ -12,7 +12,9 @@ export class PipelinesClientConfiguration {
|
||||
options: {
|
||||
url: process.env.PIFACTORY_URL,
|
||||
package: PipelinePackages,
|
||||
credentials: credentials.createSsl(),
|
||||
credentials: process.env.LOCAL_ENV
|
||||
? undefined
|
||||
: credentials.createSsl(),
|
||||
protoPath: PipelineProtoFilePath,
|
||||
loader: {
|
||||
enums: String,
|
||||
|
||||
@@ -61,7 +61,7 @@ export class PipelinesClientService implements OnModuleInit {
|
||||
const findAllPipelineResponse = await new Promise((resolve, reject) => {
|
||||
this.pipelineService.FindAll(objectSnakeToCamel(data)).subscribe({
|
||||
next(x) {
|
||||
resolve(x);
|
||||
resolve(x.pipelines);
|
||||
},
|
||||
error(err) {
|
||||
console.log('Observable Error');
|
||||
|
||||
@@ -10,7 +10,7 @@ export class TransformationsClientConfiguration {
|
||||
return {
|
||||
transport: Transport.GRPC,
|
||||
options: {
|
||||
url: process.env.TRFACTORY_URL,
|
||||
url: process.env.INFACTORY_URL,
|
||||
package: TransformationPackages,
|
||||
credentials: credentials.createSsl(),
|
||||
protoPath: TransformationProtoFilePath,
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
} from '@nestjs/common';
|
||||
import jwkToPem from 'jwk-to-pem';
|
||||
import { decode, verify } from 'jsonwebtoken';
|
||||
import { HttpExceptionFilter } from 'src/error/http-exception.filter';
|
||||
import { HttpExceptionFilter } from '../error/http-exception.filter';
|
||||
|
||||
@UseFilters(new HttpExceptionFilter())
|
||||
export class LoggerMiddleware implements NestMiddleware {
|
||||
@@ -17,9 +17,11 @@ export class LoggerMiddleware implements NestMiddleware {
|
||||
const idToken = request.get('Dadosfera-User');
|
||||
const accessToken = request.get('Authorization');
|
||||
const privateKey = process.env.JWT_PRIVATE_KEY;
|
||||
|
||||
let requiredRoute = '';
|
||||
const requiredMethod = request.method.trim();
|
||||
const requiredRoute = request.route.path.split('/')[1].trim();
|
||||
if (request.route.path.split('/').length >= 2) {
|
||||
requiredRoute = request.route.path.split('/')[1].trim();
|
||||
}
|
||||
|
||||
verify(idToken, privateKey, (err) => {
|
||||
if (err) {
|
||||
@@ -29,6 +31,7 @@ export class LoggerMiddleware implements NestMiddleware {
|
||||
const jwtDecoded: any = decode(idToken);
|
||||
|
||||
const permissions = jwtDecoded.user.permissions;
|
||||
|
||||
const clienId = jwtDecoded.user.customerId;
|
||||
const customer = jwtDecoded.user.customer;
|
||||
const userId = jwtDecoded.user.id;
|
||||
@@ -36,16 +39,20 @@ export class LoggerMiddleware implements NestMiddleware {
|
||||
await verifyToken(accessToken);
|
||||
|
||||
let havePermission = false;
|
||||
permissions.forEach((permission) => {
|
||||
const permission = permissions.find((permission) => {
|
||||
permission = permission.split('/');
|
||||
const method = permission[0].trim();
|
||||
const route = permission[1].trim();
|
||||
|
||||
if (method === requiredMethod && route === requiredRoute) {
|
||||
havePermission = true;
|
||||
return permission;
|
||||
}
|
||||
});
|
||||
|
||||
if (permission) {
|
||||
havePermission = true;
|
||||
}
|
||||
|
||||
if (havePermission) {
|
||||
request.body.info = {
|
||||
customer_id: clienId,
|
||||
|
||||
@@ -1,28 +1,148 @@
|
||||
import { Body, Controller, Post, UnauthorizedException } from '@nestjs/common';
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Headers,
|
||||
Post,
|
||||
HttpCode,
|
||||
HttpStatus,
|
||||
UnauthorizedException,
|
||||
} from '@nestjs/common';
|
||||
import {
|
||||
AuthSignInRequest,
|
||||
AuthRefreshAccessTokenRequest,
|
||||
AuthEnableTotpMfaRequest,
|
||||
AuthDisableTotpMfaRequest,
|
||||
AuthVerifyTotpMfaRequest,
|
||||
} from '@victorradael/protospack';
|
||||
|
||||
import { AuthClientService } from 'src/clients/auth/client.service';
|
||||
|
||||
interface ISignIn {
|
||||
username: string;
|
||||
password: string;
|
||||
totp: string;
|
||||
}
|
||||
import ErrorBuilder from '../../utils/ErrorBuilder';
|
||||
|
||||
@Controller('auth')
|
||||
export class AuthController {
|
||||
constructor(private authClient: AuthClientService) {}
|
||||
|
||||
// DEPRECADO!
|
||||
@Post()
|
||||
async signIn(@Body() { username, password, totp }: ISignIn) {
|
||||
@HttpCode(HttpStatus.OK)
|
||||
async signIn_old(@Body() body: AuthSignInRequest) {
|
||||
console.log(`/auth`, 'SignIn_old');
|
||||
|
||||
return this.signIn(body);
|
||||
}
|
||||
|
||||
@Post('login')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
async signIn_login(@Body() body: AuthSignInRequest) {
|
||||
console.log(`/auth`, 'SignIn_login');
|
||||
|
||||
return this.signIn(body);
|
||||
}
|
||||
|
||||
@Post('sign-in')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
async signIn(@Body() { username, password, totp }: AuthSignInRequest) {
|
||||
console.log(`/auth`, 'SignIn');
|
||||
|
||||
const tokens = await this.authClient
|
||||
.signIn({ username, password, totp })
|
||||
.then((result) => result)
|
||||
.catch((err) => {
|
||||
throw new UnauthorizedException(err.message);
|
||||
throw ErrorBuilder(err);
|
||||
});
|
||||
|
||||
return tokens;
|
||||
}
|
||||
|
||||
@Post('refresh-access-token')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
async refreshAccessToken(
|
||||
@Body() { refreshToken }: AuthRefreshAccessTokenRequest,
|
||||
) {
|
||||
console.log(`/auth`, 'RefreshAccessToken');
|
||||
|
||||
const accessToken = await this.authClient
|
||||
.refreshAccessToken({ refreshToken })
|
||||
.catch((err) => {
|
||||
throw ErrorBuilder(err);
|
||||
});
|
||||
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
@Post('enable-totp')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
async enableTotpMFA(
|
||||
@Body() body: AuthEnableTotpMfaRequest,
|
||||
@Headers() headers,
|
||||
) {
|
||||
console.log(`/auth`, 'enable-totp');
|
||||
|
||||
const { password } = body;
|
||||
const { authorization: accessToken } = headers;
|
||||
|
||||
const response = await this.authClient
|
||||
.enableTotpMFA({ accessToken, password })
|
||||
.catch((err) => {
|
||||
throw ErrorBuilder(err);
|
||||
});
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@Post('disable-totp')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
async disableTotpMFA(
|
||||
@Body() body: AuthDisableTotpMfaRequest,
|
||||
@Headers() headers,
|
||||
) {
|
||||
console.log(`/auth`, 'disable-totp');
|
||||
|
||||
const { password } = body;
|
||||
const { authorization: accessToken } = headers;
|
||||
|
||||
const response = await this.authClient
|
||||
.disableTotpMFA({ accessToken, password })
|
||||
.catch((err) => {
|
||||
throw ErrorBuilder(err);
|
||||
});
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@Post('dismiss-totp')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
async dismissTotpMFA(@Headers() headers) {
|
||||
console.log(`/auth`, 'disable-totp');
|
||||
|
||||
const { authorization: accessToken } = headers;
|
||||
|
||||
const response = await this.authClient
|
||||
.dismissTotpMFA({ accessToken })
|
||||
.catch((err) => {
|
||||
throw ErrorBuilder(err);
|
||||
});
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@Post('verify-totp')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
async verifyTotp(
|
||||
@Body() body: AuthVerifyTotpMfaRequest,
|
||||
@Headers() headers,
|
||||
): Promise<any> {
|
||||
console.log(`/auth`, 'enable-totp');
|
||||
|
||||
const { totp } = body;
|
||||
const { authorization: accessToken } = headers;
|
||||
|
||||
const response = await this.authClient
|
||||
.verifyTotp({ accessToken, totp })
|
||||
.catch((err) => {
|
||||
throw ErrorBuilder(err);
|
||||
});
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,152 @@
|
||||
import nock from 'nock';
|
||||
import { LoggerMiddleware } from '../../middlewares/authentication';
|
||||
import { NextFunction, Request, Response } from 'express';
|
||||
import { ConsoleLogger, UnauthorizedException } from '@nestjs/common';
|
||||
|
||||
describe('PipelinesGrpcServerService', () => {
|
||||
// let mockRequest: Partial<Request>;
|
||||
// let mockResponse: Partial<Response>;
|
||||
// const nextFunction: NextFunction = jest.fn();
|
||||
|
||||
// beforeEach(() => {
|
||||
// mockRequest = {
|
||||
// headers: {},
|
||||
// body: {
|
||||
// info: {},
|
||||
// },
|
||||
// };
|
||||
// mockResponse = {
|
||||
// json: jest.fn(),
|
||||
// };
|
||||
// });
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(2 + 2).toBe(4);
|
||||
});
|
||||
|
||||
// it('Should be able to pass auth', async () => {
|
||||
// const awsRegion = process.env.AWS_REGION;
|
||||
// const awsPoolId = process.env.AWS_IDENTITY_POOL_ID;
|
||||
// const cognitoRes = {
|
||||
// keys: [
|
||||
// {
|
||||
// alg: 'RS256',
|
||||
// e: 'AQAB',
|
||||
// kid: 'z3VA3+i9JZY3JFDJTNWOap8RY+B7C6mFedaqCuvLvqA=',
|
||||
// kty: 'RSA',
|
||||
// n: 'vIGCQDkPA_eQUoaGDUsCyK_Whr76mNW0kZ1uac6ZnyY6hsjUIjvwehqv-ux3cQo4rQZQVFcoh8n9cK5jguz4GVdD972vIxoEdyv32nBFVr5e1PBunKJ2Y32GTR_Hl0XiE0hRe1v6cWuTqiC4qm1NY7tXYL3mI9L6s9ztNbhmG_V44y26PdhL4vRVrJaHOAmCs-77U-QYAC7Llkpmjh-8tG1zt9_FJ237cpBUVOuhD-7Nm32_eB9wddBGfBw0F10ko_KJoU-7683_Kv8k9coJzFUSONId-bfnLOzs8j1L6ZAHipXCR7rpmuRYzXztjp4Wmm2zPUToWLdMEy0Hq1OWmw',
|
||||
// use: 'sig',
|
||||
// },
|
||||
// {
|
||||
// alg: 'RS256',
|
||||
// e: 'AQAB',
|
||||
// kid: 'u+1W9pi+clp8LaPhZVrv4dXMqRkTRD02YWhbm0NvsUw=',
|
||||
// kty: 'RSA',
|
||||
// n: 'noGq1cRMAKJPWahqfC_zWasYovSUycaS1basMfEoh3ePLc9zRgmyfiVKYzLRosHMe1uk0Y5ekCBKnWA8Yl7I84Yt7IIIaE44oJjSEGBKT3m8i8YaXzawaNs63KPkRh8553o3KzL75bQWcI_ABKqkf-uAKSCl_XotBGkzLUl4hIOYtAtRGEfKaNMPqyTCT5Zn71pMd0isppaUiTW2T5QLsZV1IBp46aSrl_D5Q_FTsJT7feobQVoHp2zfIorCpkfTXBTBMQTEBFSDyPbc6cULl48VKxp0B0GEwR_kYCEHEVzf41LQcUWZUE0OdBychijkSc9MZJnBWUYQZyedJILWnQ',
|
||||
// use: 'sig',
|
||||
// },
|
||||
// ],
|
||||
// };
|
||||
|
||||
// nock(
|
||||
// `https://cognito-idp.${awsRegion}.amazonaws.com/${awsPoolId}/.well-known/jwks.json`,
|
||||
// )
|
||||
// .persist()
|
||||
// .get('')
|
||||
// .reply(200, cognitoRes);
|
||||
|
||||
// mockRequest.headers['Dadosfera-User'] =
|
||||
// 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImlkIjoiZTljYjI1ZGEtMTQyOC00NDJjLTg5NjItYTdkNmQxNjhkODUyIiwibmFtZSI6InJvZHJpZ28uemFtYm9uaSIsInVzZXJuYW1lIjoicm9kcmlnby56YW1ib25pQGRhZG9zZmVyYS5haSIsInJ1bGVJZCI6IjIxNzdmZjg4LThmY2ItNDRlNS1hYzYxLWNjYmU2Y2M3MGU4ZCIsImN1c3RvbWVySWQiOiIxMTI5ODBhMy0wYTEyLTQxYzktYmZmZC03OTFjZjdjYTg3YTIiLCJtZmFTdGF0dXMiOiJwZW5kaW5nIiwiY3JlYXRlZEF0IjoiMjAyMi0wNS0xM1QxNTowOTowOS4xMzhaIiwidXBkYXRlZEF0IjoiMjAyMi0wNS0xM1QxNTowOTowOS4xMzhaIiwicGVybWlzc2lvbnMiOlsiUE9TVCAvcGlwZWxpbmVzIiwiR0VUIC9waXBlbGluZXMiLCJQVVQgL3BpcGVsaW5lcyIsIkRFTEVURSAvcGlwZWxpbmVzIiwiUE9TVCAvaW5wdXRzIiwiR0VUIC9pbnB1dHMiLCJQVVQgL2lucHV0cyIsIkRFTEVURSAvaW5wdXRzIiwiUE9TVCAvb3V0cHV0cyIsIkdFVCAvb3V0cHV0cyIsIlBVVCAvb3V0cHV0cyIsIkRFTEVURSAvb3V0cHV0cyIsIlBPU1QgL3RyYW5zZm9ybWF0aW9ucyIsIkdFVCAvdHJhbnNmb3JtYXRpb25zIiwiUFVUIC90cmFuc2Zvcm1hdGlvbnMiLCJERUxFVEUgL3RyYW5zZm9ybWF0aW9ucyIsIlBPU1QgL2NhdGFsb2ciLCJHRVQgL2NhdGFsb2ciLCJQVVQgL2NhdGFsb2ciLCJERUxFVEUgL2NhdGFsb2ciLCJQT1NUIC9hdXRoIiwiR0VUIC9tZXRhYmFzZSIsIkdFVCAvc25vd2ZsYWtlIl0sImN1c3RvbWVyIjoiZGFkb3NmZXJhIn0sImlhdCI6MTY1MzY1NjE2NywiZXhwIjoxNjUzNzQyNTY3fQ.eeNEEUk_95KOxM-objS7gXz-SCVkNFYpEP688MfLkdI';
|
||||
// mockRequest.headers['Authorization'] =
|
||||
// 'eyJraWQiOiJ1KzFXOXBpK2NscDhMYVBoWlZydjRkWE1xUmtUUkQwMllXaGJtME52c1V3PSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiIxYjkyZmFkMC1iNWVlLTQwMzAtOGRmYy1hZWM0MGQzYzdkYmUiLCJpc3MiOiJodHRwczpcL1wvY29nbml0by1pZHAudXMtZWFzdC0xLmFtYXpvbmF3cy5jb21cL3VzLWVhc3QtMV9OVXY3WTJTeGoiLCJjbGllbnRfaWQiOiI0N3RrY3Jxc2NuajY3bWhnYmg3dXQ1YnJzNCIsIm9yaWdpbl9qdGkiOiJhZWJjNjA5NC1hYTJmLTRiZmUtOWExZi01ZWVhYTVmYzAwNDAiLCJldmVudF9pZCI6IjBhY2NjMzJiLTllNzktNGY2NS1iMDFiLWZhZGJlYzFhZWFiNiIsInRva2VuX3VzZSI6ImFjY2VzcyIsInNjb3BlIjoiYXdzLmNvZ25pdG8uc2lnbmluLnVzZXIuYWRtaW4iLCJhdXRoX3RpbWUiOjE2NTM2NTYxNjcsImV4cCI6MTY1MzY1Nzk2NywiaWF0IjoxNjUzNjU2MTY3LCJqdGkiOiIyYTgzNDhmOC0xNDhlLTQ3NjctODcxYi00M2UyOGRjNjc2NTkiLCJ1c2VybmFtZSI6InJvZHJpZ28uemFtYm9uaUBkYWRvc2ZlcmEuYWkifQ.UgIgeGEH2olNgqPly8cymNgWIZJz5n9N4yeKgTusfGsu5h-TWP_jVhPoCvFoixO2XKzFjSCvKwlKQYZyB74jLQLs-j5C5KGBdOea1HX7pUnEfEVtBINd1kcHib5YpGYq3MHG1uVx8vNJS3XviwgYg4rgNWA4du-QbhMicdRyHolYM-dWxuxtkwTRWMe1Vw6KlTctFsvUWx1GMgjp37tsLONcp3B8OsYXfiR764K_pBNs5gMhJ39gJ7NHHLWkJrtrUTpIoHWaZS_HEgvVyQiJENQvK_bPDMPm_lyF1dW-JBgot4TpAxMmvV1XGabkzycIcAOwUaPsKBlMphgunz1Ffw';
|
||||
// mockRequest.method = 'GET';
|
||||
// mockRequest.route = {
|
||||
// path: '/inputs/',
|
||||
// stack: [
|
||||
// {
|
||||
// method: 'get',
|
||||
// },
|
||||
// ],
|
||||
// methods: {
|
||||
// get: true,
|
||||
// },
|
||||
// };
|
||||
// const authMiddleware = new LoggerMiddleware();
|
||||
|
||||
// await authMiddleware.useTest(
|
||||
// mockRequest as Request,
|
||||
// mockResponse as Response,
|
||||
// nextFunction,
|
||||
// );
|
||||
// expect(nextFunction).toHaveBeenCalled();
|
||||
// });
|
||||
|
||||
// it('Should not be able to pass auth', async () => {
|
||||
// const awsRegion = process.env.AWS_REGION;
|
||||
// const awsPoolId = process.env.AWS_IDENTITY_POOL_ID;
|
||||
// const cognitoRes = {
|
||||
// keys: [
|
||||
// {
|
||||
// alg: 'RS256',
|
||||
// e: 'AQAB',
|
||||
// kid: 'z3VA3+i9JZY3JFDJTNWOap8RY+B7C6mFedaqCuvLvqA=',
|
||||
// kty: 'RSA',
|
||||
// n: 'vIGCQDkPA_eQUoaGDUsCyK_Whr76mNW0kZ1uac6ZnyY6hsjUIjvwehqv-ux3cQo4rQZQVFcoh8n9cK5jguz4GVdD972vIxoEdyv32nBFVr5e1PBunKJ2Y32GTR_Hl0XiE0hRe1v6cWuTqiC4qm1NY7tXYL3mI9L6s9ztNbhmG_V44y26PdhL4vRVrJaHOAmCs-77U-QYAC7Llkpmjh-8tG1zt9_FJ237cpBUVOuhD-7Nm32_eB9wddBGfBw0F10ko_KJoU-7683_Kv8k9coJzFUSONId-bfnLOzs8j1L6ZAHipXCR7rpmuRYzXztjp4Wmm2zPUToWLdMEy0Hq1OWmw',
|
||||
// use: 'sig',
|
||||
// },
|
||||
// {
|
||||
// alg: 'RS256',
|
||||
// e: 'AQAB',
|
||||
// kid: 'u+1W9pi+clp8LaPhZVrv4dXMqRkTRD02YWhbm0NvsUw=',
|
||||
// kty: 'RSA',
|
||||
// n: 'noGq1cRMAKJPWahqfC_zWasYovSUycaS1basMfEoh3ePLc9zRgmyfiVKYzLRosHMe1uk0Y5ekCBKnWA8Yl7I84Yt7IIIaE44oJjSEGBKT3m8i8YaXzawaNs63KPkRh8553o3KzL75bQWcI_ABKqkf-uAKSCl_XotBGkzLUl4hIOYtAtRGEfKaNMPqyTCT5Zn71pMd0isppaUiTW2T5QLsZV1IBp46aSrl_D5Q_FTsJT7feobQVoHp2zfIorCpkfTXBTBMQTEBFSDyPbc6cULl48VKxp0B0GEwR_kYCEHEVzf41LQcUWZUE0OdBychijkSc9MZJnBWUYQZyedJILWnQ',
|
||||
// use: 'sig',
|
||||
// },
|
||||
// ],
|
||||
// };
|
||||
|
||||
// nock(
|
||||
// `https://cognito-idp.${awsRegion}.amazonaws.com/${awsPoolId}/.well-known/jwks.json`,
|
||||
// )
|
||||
// .persist()
|
||||
// .get('')
|
||||
// .reply(200, cognitoRes);
|
||||
|
||||
// mockRequest.headers['Dadosfera-User'] =
|
||||
// 'asdeyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImlkIjoiZTljYjI1ZGEtMTQyOC00NDJjLTg5NjItYTdkNmQxNjhkODUyIiwibmFtZSI6InJvZHJpZ28uemFtYm9uaSIsInVzZXJuYW1lIjoicm9kcmlnby56YW1ib25pQGRhZG9zZmVyYS5haSIsInJ1bGVJZCI6IjIxNzdmZjg4LThmY2ItNDRlNS1hYzYxLWNjYmU2Y2M3MGU4ZCIsImN1c3RvbWVySWQiOiIxMTI5ODBhMy0wYTEyLTQxYzktYmZmZC03OTFjZjdjYTg3YTIiLCJtZmFTdGF0dXMiOiJwZW5kaW5nIiwiY3JlYXRlZEF0IjoiMjAyMi0wNS0xM1QxNTowOTowOS4xMzhaIiwidXBkYXRlZEF0IjoiMjAyMi0wNS0xM1QxNTowOTowOS4xMzhaIiwicGVybWlzc2lvbnMiOlsiUE9TVCAvcGlwZWxpbmVzIiwiR0VUIC9waXBlbGluZXMiLCJQVVQgL3BpcGVsaW5lcyIsIkRFTEVURSAvcGlwZWxpbmVzIiwiUE9TVCAvaW5wdXRzIiwiR0VUIC9pbnB1dHMiLCJQVVQgL2lucHV0cyIsIkRFTEVURSAvaW5wdXRzIiwiUE9TVCAvb3V0cHV0cyIsIkdFVCAvb3V0cHV0cyIsIlBVVCAvb3V0cHV0cyIsIkRFTEVURSAvb3V0cHV0cyIsIlBPU1QgL3RyYW5zZm9ybWF0aW9ucyIsIkdFVCAvdHJhbnNmb3JtYXRpb25zIiwiUFVUIC90cmFuc2Zvcm1hdGlvbnMiLCJERUxFVEUgL3RyYW5zZm9ybWF0aW9ucyIsIlBPU1QgL2NhdGFsb2ciLCJHRVQgL2NhdGFsb2ciLCJQVVQgL2NhdGFsb2ciLCJERUxFVEUgL2NhdGFsb2ciLCJQT1NUIC9hdXRoIiwiR0VUIC9tZXRhYmFzZSIsIkdFVCAvc25vd2ZsYWtlIl0sImN1c3RvbWVyIjoiZGFkb3NmZXJhIn0sImlhdCI6MTY1MzY1NjE2NywiZXhwIjoxNjUzNzQyNTY3fQ.eeNEEUk_95KOxM-objS7gXz-SCVkNFYpEP688MfLkdI';
|
||||
// mockRequest.headers['Authorization'] =
|
||||
// 'asdeyJraWQiOiJ1KzFXOXBpK2NscDhMYVBoWlZydjRkWE1xUmtUUkQwMllXaGJtME52c1V3PSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiIxYjkyZmFkMC1iNWVlLTQwMzAtOGRmYy1hZWM0MGQzYzdkYmUiLCJpc3MiOiJodHRwczpcL1wvY29nbml0by1pZHAudXMtZWFzdC0xLmFtYXpvbmF3cy5jb21cL3VzLWVhc3QtMV9OVXY3WTJTeGoiLCJjbGllbnRfaWQiOiI0N3RrY3Jxc2NuajY3bWhnYmg3dXQ1YnJzNCIsIm9yaWdpbl9qdGkiOiJhZWJjNjA5NC1hYTJmLTRiZmUtOWExZi01ZWVhYTVmYzAwNDAiLCJldmVudF9pZCI6IjBhY2NjMzJiLTllNzktNGY2NS1iMDFiLWZhZGJlYzFhZWFiNiIsInRva2VuX3VzZSI6ImFjY2VzcyIsInNjb3BlIjoiYXdzLmNvZ25pdG8uc2lnbmluLnVzZXIuYWRtaW4iLCJhdXRoX3RpbWUiOjE2NTM2NTYxNjcsImV4cCI6MTY1MzY1Nzk2NywiaWF0IjoxNjUzNjU2MTY3LCJqdGkiOiIyYTgzNDhmOC0xNDhlLTQ3NjctODcxYi00M2UyOGRjNjc2NTkiLCJ1c2VybmFtZSI6InJvZHJpZ28uemFtYm9uaUBkYWRvc2ZlcmEuYWkifQ.UgIgeGEH2olNgqPly8cymNgWIZJz5n9N4yeKgTusfGsu5h-TWP_jVhPoCvFoixO2XKzFjSCvKwlKQYZyB74jLQLs-j5C5KGBdOea1HX7pUnEfEVtBINd1kcHib5YpGYq3MHG1uVx8vNJS3XviwgYg4rgNWA4du-QbhMicdRyHolYM-dWxuxtkwTRWMe1Vw6KlTctFsvUWx1GMgjp37tsLONcp3B8OsYXfiR764K_pBNs5gMhJ39gJ7NHHLWkJrtrUTpIoHWaZS_HEgvVyQiJENQvK_bPDMPm_lyF1dW-JBgot4TpAxMmvV1XGabkzycIcAOwUaPsKBlMphgunz1Ffw';
|
||||
// mockRequest.method = 'GET';
|
||||
// mockRequest.route = {
|
||||
// path: '/inputs/',
|
||||
// stack: [
|
||||
// {
|
||||
// method: 'get',
|
||||
// },
|
||||
// ],
|
||||
// methods: {
|
||||
// get: true,
|
||||
// },
|
||||
// };
|
||||
// const authMiddleware = new LoggerMiddleware();
|
||||
|
||||
// // const t = await authMiddleware.useTest(
|
||||
// // mockRequest as Request,
|
||||
// // mockResponse as Response,
|
||||
// // nextFunction,
|
||||
// // );
|
||||
// // expect(nextFunction).toHaveBeenCalled();
|
||||
|
||||
// expect(async () => {
|
||||
// const t = await authMiddleware.useTest(
|
||||
// mockRequest as Request,
|
||||
// mockResponse as Response,
|
||||
// nextFunction,
|
||||
// );
|
||||
// console.log(t);
|
||||
// }).toThrow('Unauthorized');
|
||||
|
||||
// expect(1).toBe(2);
|
||||
// // expect(t).toThrow(UnauthorizedException);
|
||||
// });
|
||||
});
|
||||
|
||||
@@ -17,9 +17,7 @@ export class CatalogController {
|
||||
async catalogAll(@Body() body) {
|
||||
console.log(`/catalog`, 'ON CATALOG ALL ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.catalogAll(body);
|
||||
const res = await this.catalogService.catalogAll(body);
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -28,9 +26,7 @@ export class CatalogController {
|
||||
async dataAppsAll(@Body() body) {
|
||||
console.log(`/catalog`, 'ON FIND ALL DATA APPS ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.dataAppsAll(body);
|
||||
const res = await this.catalogService.dataAppsAll(body);
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -39,9 +35,8 @@ export class CatalogController {
|
||||
async dataAppsOne(@Param() params, @Body() body) {
|
||||
console.log(`/catalog`, 'ON FIND ONE DATA APP ROUTE');
|
||||
const { id } = params;
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.dataAppsOne(id, body);
|
||||
const res = await this.catalogService.dataAppsOne(id, body);
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -50,9 +45,7 @@ export class CatalogController {
|
||||
async getAllDashboardMetabase(@Body() body) {
|
||||
console.log(`/catalog`, 'ON GET ALL DASHBOARDS METABASE ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.getAllDashboardMetabase(body);
|
||||
const res = await this.catalogService.getAllDashboardMetabase(body);
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -62,9 +55,7 @@ export class CatalogController {
|
||||
const { id } = params;
|
||||
console.log(`/catalog`, 'ON GET ONE DASHBOARD METABASE ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.getOneDashboardMetabase(id, body);
|
||||
const res = await this.catalogService.getOneDashboardMetabase(id, body);
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -73,12 +64,11 @@ export class CatalogController {
|
||||
async getAllTableMetadata(@Body() body, @Query() query) {
|
||||
console.log(`/catalog`, 'ON GET ALL TABLES METADATA ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
if (!query) {
|
||||
const res = await catalogService.getAllTableMetadata(body);
|
||||
const res = await this.catalogService.getAllTableMetadata(body);
|
||||
return res;
|
||||
} else {
|
||||
const res = await catalogService.getOneTableMetadata(body, query);
|
||||
const res = await this.catalogService.getOneTableMetadata(body, query);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -88,9 +78,7 @@ export class CatalogController {
|
||||
const { id } = params;
|
||||
console.log(`/catalog`, 'ON DELETE ONE TABLE METADATA ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.deleteOneTableMetadata(id, body);
|
||||
const res = await this.catalogService.deleteOneTableMetadata(id, body);
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -99,9 +87,7 @@ export class CatalogController {
|
||||
async getOneColumnMetadata(@Body() body, @Query() params) {
|
||||
console.log(`/catalog`, 'ON GET ONE COLUMN METADATA ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.getOneColumnMetadata(body, params);
|
||||
const res = await this.catalogService.getOneColumnMetadata(body, params);
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -111,9 +97,7 @@ export class CatalogController {
|
||||
console.log(`/catalog`, 'ON DELETE ONE COLUMN METADATA ROUTE');
|
||||
const { id } = params;
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.deleteOneColumnMetadata(id, body);
|
||||
const res = await this.catalogService.deleteOneColumnMetadata(id, body);
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -122,9 +106,7 @@ export class CatalogController {
|
||||
async getOneDataPreview(@Body() body, @Query() params) {
|
||||
console.log(`/catalog`, 'ON GET ONE DATAPREVIEW ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.getOneDataPreview(body, params);
|
||||
const res = await this.catalogService.getOneDataPreview(body, params);
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -133,9 +115,7 @@ export class CatalogController {
|
||||
async getDataStatus(@Body() body) {
|
||||
console.log(`/catalog`, 'ON GET DATA STATUS ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.getDataStatus(body);
|
||||
const res = await this.catalogService.getDataStatus(body);
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -144,9 +124,7 @@ export class CatalogController {
|
||||
async createDataStatus(@Body() body) {
|
||||
console.log(`/catalog`, 'ON CREATE DATA STATUS ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.createDataStatus(body);
|
||||
const res = await this.catalogService.createDataStatus(body);
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -155,9 +133,7 @@ export class CatalogController {
|
||||
async getDataDescription(@Body() body) {
|
||||
console.log(`/catalog`, 'ON GET DATA DESCRIPTION ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.getDataDescription(body);
|
||||
const res = await this.catalogService.getDataDescription(body);
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -166,9 +142,7 @@ export class CatalogController {
|
||||
async createDataDescription(@Body() body) {
|
||||
console.log(`/catalog`, 'ON CREATE DATA DESCRIPTION ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.createDataDescription(body);
|
||||
const res = await this.catalogService.createDataDescription(body);
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -177,9 +151,7 @@ export class CatalogController {
|
||||
async getDataDocs(@Body() body) {
|
||||
console.log(`/catalog`, 'ON GET DATA DOCS ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.getDataDocs(body);
|
||||
const res = await this.catalogService.getDataDocs(body);
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -188,9 +160,7 @@ export class CatalogController {
|
||||
async createDataDocs(@Body() body) {
|
||||
console.log(`/catalog`, 'ON CREATE DATA DOCS ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.createDataDocs(body);
|
||||
const res = await this.catalogService.createDataDocs(body);
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -199,9 +169,7 @@ export class CatalogController {
|
||||
async getDataRating(@Body() body) {
|
||||
console.log(`/catalog`, 'ON GET DATA RATING ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.getDataRating(body);
|
||||
const res = await this.catalogService.getDataRating(body);
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -210,9 +178,7 @@ export class CatalogController {
|
||||
async createDataRating(@Body() body) {
|
||||
console.log(`/catalog`, 'ON GET DATA RATING ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.createDataRating(body);
|
||||
const res = await this.catalogService.createDataRating(body);
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -222,9 +188,9 @@ export class CatalogController {
|
||||
console.log(`/catalog`, 'ON GET SUMMARY RATING ROUTE');
|
||||
//const { id } = params;
|
||||
|
||||
//const catalogService = new CatalogService();
|
||||
//
|
||||
|
||||
//const res = await catalogService.getSummaryRating(id, body);
|
||||
//const res = await this.catalogService.getSummaryRating(id, body);
|
||||
|
||||
return {
|
||||
avg_rating: 0,
|
||||
@@ -236,9 +202,7 @@ export class CatalogController {
|
||||
async getDataComment(@Body() body) {
|
||||
console.log(`/catalog`, 'ON GET DATA COMMENT ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.getDataComment(body);
|
||||
const res = await this.catalogService.getDataComment(body);
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -247,9 +211,7 @@ export class CatalogController {
|
||||
async createDataComment(@Body() body) {
|
||||
console.log(`/catalog`, 'ON GET DATA COMMENT ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.createDataComment(body);
|
||||
const res = await this.catalogService.createDataComment(body);
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -258,9 +220,7 @@ export class CatalogController {
|
||||
async getDataReview(@Body() body, @Query() params) {
|
||||
console.log(`/catalog`, 'ON GET DATA REVIEW ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.getDataReview(body, params);
|
||||
const res = await this.catalogService.getDataReview(body, params);
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -269,9 +229,7 @@ export class CatalogController {
|
||||
async createTags(@Body() body) {
|
||||
console.log(`/catalog`, 'ON CREATE TAG ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.createTags(body);
|
||||
const res = await this.catalogService.createTags(body);
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -280,9 +238,7 @@ export class CatalogController {
|
||||
async findAllTags(@Body() body) {
|
||||
console.log(`/catalog`, 'ON FIND ALL TAGS ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.findAllTags(body);
|
||||
const res = await this.catalogService.findAllTags(body);
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -292,9 +248,7 @@ export class CatalogController {
|
||||
console.log(`/catalog`, 'ON DELETE TAG ROUTE');
|
||||
const { id } = params;
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.deleteTags(id, body);
|
||||
const res = await this.catalogService.deleteTags(id, body);
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -303,9 +257,7 @@ export class CatalogController {
|
||||
async createTableTags(@Body() body) {
|
||||
console.log(`/catalog`, 'ON CREATE TABLE TAG ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.createTableTags(body);
|
||||
const res = await this.catalogService.createTableTags(body);
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -314,9 +266,7 @@ export class CatalogController {
|
||||
async getAllTableTags(@Body() body) {
|
||||
console.log(`/catalog`, 'ON GET ALL TABLE TAGS ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.findAllTableTags(body);
|
||||
const res = await this.catalogService.findAllTableTags(body);
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -326,9 +276,7 @@ export class CatalogController {
|
||||
console.log(`/catalog`, 'ON CREATE TABLE TAGS ROUTE');
|
||||
const { id } = params;
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.deleteTableTags(id, body);
|
||||
const res = await this.catalogService.deleteTableTags(id, body);
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -337,9 +285,7 @@ export class CatalogController {
|
||||
async getTableRules(@Body() body) {
|
||||
console.log(`/catalog`, 'ON GET TABLE RULES ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.getTableRules(body);
|
||||
const res = await this.catalogService.getTableRules(body);
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -349,9 +295,7 @@ export class CatalogController {
|
||||
console.log(`/catalog`, 'ON DELETE TABLE RULES ROUTE');
|
||||
const { id } = params;
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.deleteTableRules(id, body);
|
||||
const res = await this.catalogService.deleteTableRules(id, body);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -1,48 +1,31 @@
|
||||
import axios from 'axios';
|
||||
|
||||
class CatalogService {
|
||||
_getNimbusUrl(body) {
|
||||
const customer = body.info.customer.toLowerCase();
|
||||
|
||||
if (process.env.ENV === 'prd') {
|
||||
return `https://nimbus-${customer}.dadosfera.ai`;
|
||||
}
|
||||
|
||||
return `https://nimbus-${customer}.${process.env.ENV}.dadosfera.ai`;
|
||||
}
|
||||
|
||||
async catalogAll(body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const nimbusUrl =
|
||||
process.env.ENV === 'prd'
|
||||
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
|
||||
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
|
||||
|
||||
const nimbusUrl = this._getNimbusUrl(body);
|
||||
const { data } = await axios.get(`${nimbusUrl}/api/catalog/all/`);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
async dataAppsAll(body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const nimbusUrl =
|
||||
process.env.ENV === 'prd'
|
||||
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
|
||||
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
|
||||
|
||||
const nimbusUrl = this._getNimbusUrl(body);
|
||||
const { data } = await axios.get(`${nimbusUrl}/api/catalog/data_apps/`);
|
||||
return data;
|
||||
}
|
||||
|
||||
async dataAppsOne(id, body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const nimbusUrl =
|
||||
process.env.ENV === 'prd'
|
||||
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
|
||||
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
|
||||
|
||||
const nimbusUrl = this._getNimbusUrl(body);
|
||||
const { data } = await axios.get(
|
||||
`${nimbusUrl}/api/catalog/data_apps/${id}/`,
|
||||
);
|
||||
@@ -51,16 +34,7 @@ class CatalogService {
|
||||
}
|
||||
|
||||
async getAllDashboardMetabase(body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const nimbusUrl =
|
||||
process.env.ENV === 'prd'
|
||||
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
|
||||
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
|
||||
|
||||
const nimbusUrl = this._getNimbusUrl(body);
|
||||
const { data } = await axios.get(
|
||||
`${nimbusUrl}/api/catalog/dashboard-metabase/`,
|
||||
);
|
||||
@@ -68,16 +42,7 @@ class CatalogService {
|
||||
}
|
||||
|
||||
async getOneDashboardMetabase(id, body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const nimbusUrl =
|
||||
process.env.ENV === 'prd'
|
||||
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
|
||||
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
|
||||
|
||||
const nimbusUrl = this._getNimbusUrl(body);
|
||||
const { data } = await axios.get(
|
||||
`${nimbusUrl}/api/catalog/dashboard-metabase/${id}`,
|
||||
);
|
||||
@@ -91,16 +56,7 @@ class CatalogService {
|
||||
}
|
||||
|
||||
async getAllTableMetadata(body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const nimbusUrl =
|
||||
process.env.ENV === 'prd'
|
||||
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
|
||||
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
|
||||
|
||||
const nimbusUrl = this._getNimbusUrl(body);
|
||||
const { data } = await axios.get(
|
||||
`${nimbusUrl}/api/catalog/table-metadata/`,
|
||||
);
|
||||
@@ -108,16 +64,7 @@ class CatalogService {
|
||||
}
|
||||
|
||||
async getOneTableMetadata(body, params) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const nimbusUrl =
|
||||
process.env.ENV === 'prd'
|
||||
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
|
||||
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
|
||||
|
||||
const nimbusUrl = this._getNimbusUrl(body);
|
||||
const { data } = await axios.get(
|
||||
`${nimbusUrl}/api/catalog/table-metadata/`,
|
||||
{ params: params },
|
||||
@@ -126,16 +73,7 @@ class CatalogService {
|
||||
}
|
||||
|
||||
async deleteOneTableMetadata(id, body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const nimbusUrl =
|
||||
process.env.ENV === 'prd'
|
||||
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
|
||||
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
|
||||
|
||||
const nimbusUrl = this._getNimbusUrl(body);
|
||||
const { data } = await axios.delete(
|
||||
`${nimbusUrl}/api/catalog/table-metadata/${id}`,
|
||||
);
|
||||
@@ -143,16 +81,7 @@ class CatalogService {
|
||||
}
|
||||
|
||||
async getOneColumnMetadata(body, params) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const nimbusUrl =
|
||||
process.env.ENV === 'prd'
|
||||
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
|
||||
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
|
||||
|
||||
const nimbusUrl = this._getNimbusUrl(body);
|
||||
const { data } = await axios.get(
|
||||
`${nimbusUrl}/api/catalog/column-metadata/`,
|
||||
{ params: params },
|
||||
@@ -161,16 +90,7 @@ class CatalogService {
|
||||
}
|
||||
|
||||
async deleteOneColumnMetadata(id, body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const nimbusUrl =
|
||||
process.env.ENV === 'prd'
|
||||
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
|
||||
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
|
||||
|
||||
const nimbusUrl = this._getNimbusUrl(body);
|
||||
const { data } = await axios.delete(
|
||||
`${nimbusUrl}/api/catalog/column-metadata/${id}/`,
|
||||
);
|
||||
@@ -178,16 +98,7 @@ class CatalogService {
|
||||
}
|
||||
|
||||
async getOneDataPreview(body, params) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const nimbusUrl =
|
||||
process.env.ENV === 'prd'
|
||||
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
|
||||
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
|
||||
|
||||
const nimbusUrl = this._getNimbusUrl(body);
|
||||
const { data } = await axios.get(`${nimbusUrl}/api/catalog/data-preview/`, {
|
||||
params: params,
|
||||
});
|
||||
@@ -195,31 +106,13 @@ class CatalogService {
|
||||
}
|
||||
|
||||
async getDataStatus(body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const nimbusUrl =
|
||||
process.env.ENV === 'prd'
|
||||
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
|
||||
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
|
||||
|
||||
const nimbusUrl = this._getNimbusUrl(body);
|
||||
const { data } = await axios.get(`${nimbusUrl}/api/catalog/data-status/`);
|
||||
return data;
|
||||
}
|
||||
|
||||
async createDataStatus(body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const nimbusUrl =
|
||||
process.env.ENV === 'prd'
|
||||
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
|
||||
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
|
||||
|
||||
const nimbusUrl = this._getNimbusUrl(body);
|
||||
const { data } = await axios.post(
|
||||
`${nimbusUrl}/api/catalog/data-status/`,
|
||||
body,
|
||||
@@ -228,16 +121,7 @@ class CatalogService {
|
||||
}
|
||||
|
||||
async getDataDescription(body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const nimbusUrl =
|
||||
process.env.ENV === 'prd'
|
||||
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
|
||||
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
|
||||
|
||||
const nimbusUrl = this._getNimbusUrl(body);
|
||||
const { data } = await axios.get(
|
||||
`${nimbusUrl}/api/catalog/data-description/`,
|
||||
);
|
||||
@@ -245,16 +129,7 @@ class CatalogService {
|
||||
}
|
||||
|
||||
async createDataDescription(body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const nimbusUrl =
|
||||
process.env.ENV === 'prd'
|
||||
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
|
||||
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
|
||||
|
||||
const nimbusUrl = this._getNimbusUrl(body);
|
||||
const { data } = await axios.post(
|
||||
`${nimbusUrl}/api/catalog/data-description/`,
|
||||
body,
|
||||
@@ -263,31 +138,13 @@ class CatalogService {
|
||||
}
|
||||
|
||||
async getDataDocs(body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const nimbusUrl =
|
||||
process.env.ENV === 'prd'
|
||||
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
|
||||
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
|
||||
|
||||
const nimbusUrl = this._getNimbusUrl(body);
|
||||
const { data } = await axios.get(`${nimbusUrl}/api/catalog/data-docs/`);
|
||||
return data;
|
||||
}
|
||||
|
||||
async createDataDocs(body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const nimbusUrl =
|
||||
process.env.ENV === 'prd'
|
||||
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
|
||||
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
|
||||
|
||||
const nimbusUrl = this._getNimbusUrl(body);
|
||||
const { data } = await axios.post(
|
||||
`${nimbusUrl}/api/catalog/data-docs/`,
|
||||
body,
|
||||
@@ -296,31 +153,13 @@ class CatalogService {
|
||||
}
|
||||
|
||||
async getDataRating(body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const nimbusUrl =
|
||||
process.env.ENV === 'prd'
|
||||
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
|
||||
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
|
||||
|
||||
const nimbusUrl = this._getNimbusUrl(body);
|
||||
const { data } = await axios.get(`${nimbusUrl}/api/catalog/data-rating/`);
|
||||
return data;
|
||||
}
|
||||
|
||||
async createDataRating(body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const nimbusUrl =
|
||||
process.env.ENV === 'prd'
|
||||
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
|
||||
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
|
||||
|
||||
const nimbusUrl = this._getNimbusUrl(body);
|
||||
const { data } = await axios.post(
|
||||
`${nimbusUrl}/api/catalog/data-rating/`,
|
||||
body,
|
||||
@@ -329,16 +168,7 @@ class CatalogService {
|
||||
}
|
||||
|
||||
async getSummaryRating(id, body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const nimbusUrl =
|
||||
process.env.ENV === 'prd'
|
||||
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
|
||||
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
|
||||
|
||||
const nimbusUrl = this._getNimbusUrl(body);
|
||||
const { data } = await axios.get(
|
||||
`${nimbusUrl}/api/catalog/summary-rating/${id}`,
|
||||
);
|
||||
@@ -346,31 +176,13 @@ class CatalogService {
|
||||
}
|
||||
|
||||
async getDataComment(body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const nimbusUrl =
|
||||
process.env.ENV === 'prd'
|
||||
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
|
||||
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
|
||||
|
||||
const nimbusUrl = this._getNimbusUrl(body);
|
||||
const { data } = await axios.get(`${nimbusUrl}/api/catalog/data-comment/`);
|
||||
return data;
|
||||
}
|
||||
|
||||
async createDataComment(body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const nimbusUrl =
|
||||
process.env.ENV === 'prd'
|
||||
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
|
||||
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
|
||||
|
||||
const nimbusUrl = this._getNimbusUrl(body);
|
||||
const { data } = await axios.post(
|
||||
`${nimbusUrl}/api/catalog/data-comment/`,
|
||||
body,
|
||||
@@ -379,16 +191,7 @@ class CatalogService {
|
||||
}
|
||||
|
||||
async getDataReview(body, params) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const nimbusUrl =
|
||||
process.env.ENV === 'prd'
|
||||
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
|
||||
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
|
||||
|
||||
const nimbusUrl = this._getNimbusUrl(body);
|
||||
const { data } = await axios.get(`${nimbusUrl}/api/catalog/data-review/`, {
|
||||
params: params,
|
||||
});
|
||||
@@ -396,46 +199,19 @@ class CatalogService {
|
||||
}
|
||||
|
||||
async createTags(body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const nimbusUrl =
|
||||
process.env.ENV === 'prd'
|
||||
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
|
||||
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
|
||||
|
||||
const nimbusUrl = this._getNimbusUrl(body);
|
||||
const { data } = await axios.post(`${nimbusUrl}/api/catalog/tags/`, body);
|
||||
return data;
|
||||
}
|
||||
|
||||
async findAllTags(body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const nimbusUrl =
|
||||
process.env.ENV === 'prd'
|
||||
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
|
||||
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
|
||||
|
||||
const nimbusUrl = this._getNimbusUrl(body);
|
||||
const { data } = await axios.get(`${nimbusUrl}/api/catalog/tags/`, body);
|
||||
return data;
|
||||
}
|
||||
|
||||
async findAllTableTags(body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const nimbusUrl =
|
||||
process.env.ENV === 'prd'
|
||||
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
|
||||
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
|
||||
|
||||
const nimbusUrl = this._getNimbusUrl(body);
|
||||
const { data } = await axios.get(
|
||||
`${nimbusUrl}/api/catalog/table-tags/`,
|
||||
body,
|
||||
@@ -444,31 +220,13 @@ class CatalogService {
|
||||
}
|
||||
|
||||
async deleteTags(id, body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const nimbusUrl =
|
||||
process.env.ENV === 'prd'
|
||||
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
|
||||
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
|
||||
|
||||
const nimbusUrl = this._getNimbusUrl(body);
|
||||
const { data } = await axios.delete(`${nimbusUrl}/api/catalog/tags/${id}`);
|
||||
return data;
|
||||
}
|
||||
|
||||
async createTableTags(body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const nimbusUrl =
|
||||
process.env.ENV === 'prd'
|
||||
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
|
||||
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
|
||||
|
||||
const nimbusUrl = this._getNimbusUrl(body);
|
||||
const { data } = await axios.post(
|
||||
`${nimbusUrl}/api/catalog/table-tags/`,
|
||||
body,
|
||||
@@ -477,16 +235,7 @@ class CatalogService {
|
||||
}
|
||||
|
||||
async deleteTableTags(id, body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const nimbusUrl =
|
||||
process.env.ENV === 'prd'
|
||||
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
|
||||
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
|
||||
|
||||
const nimbusUrl = this._getNimbusUrl(body);
|
||||
const { data } = await axios.delete(
|
||||
`${nimbusUrl}/api/catalog/table-tags/${id}`,
|
||||
);
|
||||
@@ -494,16 +243,7 @@ class CatalogService {
|
||||
}
|
||||
|
||||
async getTableRules(body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const nimbusUrl =
|
||||
process.env.ENV === 'prd'
|
||||
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
|
||||
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
|
||||
|
||||
const nimbusUrl = this._getNimbusUrl(body);
|
||||
const { data } = await axios.get(
|
||||
`${nimbusUrl}/api/catalog/table-rules/`,
|
||||
body,
|
||||
@@ -512,16 +252,7 @@ class CatalogService {
|
||||
}
|
||||
|
||||
async deleteTableRules(id, body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const nimbusUrl =
|
||||
process.env.ENV === 'prd'
|
||||
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
|
||||
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
|
||||
|
||||
const nimbusUrl = this._getNimbusUrl(body);
|
||||
const { data } = await axios.delete(
|
||||
`${nimbusUrl}/api/catalog/table-rules/${id}`,
|
||||
);
|
||||
|
||||
@@ -4,8 +4,8 @@ import {
|
||||
Delete,
|
||||
Get,
|
||||
Param,
|
||||
Patch,
|
||||
Post,
|
||||
Put,
|
||||
} from '@nestjs/common';
|
||||
import { InputsService } from './inputs.service';
|
||||
import { InputsClientService } from 'src/clients/inputs/client.service';
|
||||
@@ -71,7 +71,7 @@ export class InputsController {
|
||||
return response;
|
||||
}
|
||||
|
||||
@Put(':id')
|
||||
@Patch(':id')
|
||||
async update(@Body() updateInputDto: UpdateInputRequest, @Param() params) {
|
||||
const { id } = params;
|
||||
const { info } = updateInputDto;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Body, HttpException, HttpStatus, Injectable } from '@nestjs/common';
|
||||
import { InputNewCreateRequest } from '@victorradael/protospack';
|
||||
import { Timeout } from '@nestjs/schedule';
|
||||
import { InputsClientService } from 'src/clients/inputs/client.service';
|
||||
import { IIdRequest, Info } from 'src/clients/inputs/interfaces';
|
||||
|
||||
@@ -7,11 +7,30 @@ import { IIdRequest, Info } from 'src/clients/inputs/interfaces';
|
||||
export class InputsService {
|
||||
constructor(private inputClient: InputsClientService) {}
|
||||
|
||||
async create(@Body() data: InputNewCreateRequest) {
|
||||
adjustInputPayload(payload) {
|
||||
return payload?.input_s3 || payload?.input_jdbc;
|
||||
}
|
||||
async create(@Body() data) {
|
||||
try {
|
||||
const createInputResponse = await this.inputClient.create(data);
|
||||
|
||||
return createInputResponse;
|
||||
if (
|
||||
data.plugin == 'csv' ||
|
||||
data.plugin == 'json' ||
|
||||
data.plugin == 'parquet'
|
||||
) {
|
||||
const { info, ...input } = data;
|
||||
const inputPayload = this.generateInputS3Payload(input);
|
||||
const createInputResponse = await this.inputClient.createS3Inputs({
|
||||
input: inputPayload,
|
||||
info,
|
||||
});
|
||||
return createInputResponse;
|
||||
} else {
|
||||
const createInputResponse: any = await this.inputClient.create(data);
|
||||
if (createInputResponse?.input?.input_jdbc) {
|
||||
return { input: createInputResponse?.input?.input_jdbc };
|
||||
}
|
||||
return createInputResponse;
|
||||
}
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
@@ -19,8 +38,12 @@ export class InputsService {
|
||||
|
||||
async findAll(body) {
|
||||
try {
|
||||
const findAllInputResponse = await this.inputClient.findAll(body);
|
||||
|
||||
const findAllInputResponse: any = await this.inputClient.findAll(body);
|
||||
if (findAllInputResponse?.inputs?.length) {
|
||||
findAllInputResponse.inputs = findAllInputResponse.inputs.map((input) =>
|
||||
this.adjustInputPayload(input),
|
||||
);
|
||||
}
|
||||
return findAllInputResponse;
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
@@ -29,7 +52,12 @@ export class InputsService {
|
||||
|
||||
async findOne(idRequest: IIdRequest) {
|
||||
try {
|
||||
const findOneInputResponse = await this.inputClient.findOne(idRequest);
|
||||
const findOneInputResponse: any = await this.inputClient.findOne(
|
||||
idRequest,
|
||||
);
|
||||
findOneInputResponse.input = this.adjustInputPayload(
|
||||
findOneInputResponse.input,
|
||||
);
|
||||
return findOneInputResponse;
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
@@ -38,12 +66,15 @@ export class InputsService {
|
||||
|
||||
async update(id: string, data, info: Info) {
|
||||
try {
|
||||
const updateInputResponse = await this.inputClient.update({
|
||||
const updateInputResponse: any = await this.inputClient.update({
|
||||
id,
|
||||
info,
|
||||
...data,
|
||||
});
|
||||
|
||||
updateInputResponse.input = this.adjustInputPayload(
|
||||
updateInputResponse?.input,
|
||||
);
|
||||
return updateInputResponse;
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
@@ -60,6 +91,7 @@ export class InputsService {
|
||||
}
|
||||
}
|
||||
|
||||
@Timeout(60000 * 10) // Timeout set for 10 minutes
|
||||
async testConnection(data) {
|
||||
try {
|
||||
const testConnectionInputResponse = await this.inputClient.testConnection(
|
||||
@@ -82,4 +114,29 @@ export class InputsService {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
generateInputS3Payload(payload) {
|
||||
const { credentials, plugin } = payload;
|
||||
if (!credentials) return payload;
|
||||
|
||||
const {
|
||||
client_aws_access_key_id,
|
||||
client_aws_secret_access_key,
|
||||
file_format_params,
|
||||
format_file_params,
|
||||
client_bucket,
|
||||
file_to_extract,
|
||||
} = credentials;
|
||||
const formatedPayload = {
|
||||
plugin,
|
||||
source_bucket: client_bucket,
|
||||
source_prefix: file_to_extract,
|
||||
auth_parameters: {
|
||||
aws_access_key_id: client_aws_access_key_id,
|
||||
aws_secret_access_key: client_aws_secret_access_key,
|
||||
},
|
||||
file_format_params: file_format_params || format_file_params,
|
||||
};
|
||||
return formatedPayload;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,13 +7,20 @@ import { objectCamelToSnake } from 'src/utils/CaseConverter';
|
||||
export class PipelinesService {
|
||||
constructor(private pipelineClient: PipelinesClientService) {}
|
||||
|
||||
adjustPayload(payload) {
|
||||
payload.input = payload.input?.input_s3 || payload.input?.input_jdbc;
|
||||
}
|
||||
|
||||
async create(createPipelineDto) {
|
||||
try {
|
||||
const createPipelineResponse = await this.pipelineClient.create(
|
||||
createPipelineDto,
|
||||
);
|
||||
|
||||
return objectCamelToSnake(createPipelineResponse);
|
||||
const pipeline = objectCamelToSnake(createPipelineResponse);
|
||||
this.adjustPayload(pipeline.pipeline);
|
||||
|
||||
return pipeline;
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
@@ -23,7 +30,11 @@ export class PipelinesService {
|
||||
async findOne(data: IIdRequest) {
|
||||
try {
|
||||
const findOnePipelineResponse = await this.pipelineClient.findOne(data);
|
||||
return objectCamelToSnake(findOnePipelineResponse);
|
||||
|
||||
const pipeline = objectCamelToSnake(findOnePipelineResponse);
|
||||
this.adjustPayload(pipeline.pipeline);
|
||||
|
||||
return pipeline;
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
@@ -33,7 +44,11 @@ export class PipelinesService {
|
||||
try {
|
||||
const findAllPipelineResponse = await this.pipelineClient.findAll(data);
|
||||
|
||||
return objectCamelToSnake(findAllPipelineResponse);
|
||||
const pipelines = objectCamelToSnake(findAllPipelineResponse);
|
||||
pipelines.forEach((pipeline) => {
|
||||
this.adjustPayload(pipeline);
|
||||
});
|
||||
return { pipelines };
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
@@ -47,7 +62,10 @@ export class PipelinesService {
|
||||
...data,
|
||||
});
|
||||
|
||||
return objectCamelToSnake(updatePipelineResponse);
|
||||
const pipeline = objectCamelToSnake(updatePipelineResponse);
|
||||
this.adjustPayload(pipeline);
|
||||
|
||||
return pipeline;
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
import { HttpStatus, HttpException } from '@nestjs/common';
|
||||
|
||||
import ErrorCodes from './errorCodes';
|
||||
|
||||
function Builder({ statusCode, message, error, code }) {
|
||||
return new HttpException({ statusCode, message, error, code }, statusCode);
|
||||
}
|
||||
|
||||
export default function ErrorBuilder(code: string) {
|
||||
console.log(code);
|
||||
|
||||
switch (code) {
|
||||
case ErrorCodes.AUTH.WRONG_CREDENTIALS:
|
||||
return Builder({
|
||||
statusCode: HttpStatus.UNAUTHORIZED,
|
||||
error: 'Não autenticado',
|
||||
message: 'Usuário ou senha incorretos',
|
||||
code,
|
||||
});
|
||||
|
||||
case ErrorCodes.AUTH.WRONG_PASSWORD_CONFIRMATION:
|
||||
return Builder({
|
||||
statusCode: HttpStatus.UNAUTHORIZED,
|
||||
error: 'Senha incorreta',
|
||||
message: 'Confirmação de senha incorreta',
|
||||
code,
|
||||
});
|
||||
|
||||
case ErrorCodes.AUTH.TOTP_NOT_ENABLED:
|
||||
return Builder({
|
||||
statusCode: HttpStatus.PRECONDITION_FAILED,
|
||||
error: 'Não permitido',
|
||||
message: 'A autenticação multifator não está habilitada',
|
||||
code,
|
||||
});
|
||||
|
||||
case ErrorCodes.AUTH.TOTP_ALREADY_ENABLED:
|
||||
return Builder({
|
||||
statusCode: HttpStatus.PRECONDITION_FAILED,
|
||||
error: 'Não permitido',
|
||||
message: 'A autenticação multifator já está habilitada',
|
||||
code,
|
||||
});
|
||||
|
||||
case ErrorCodes.AUTH.TOTP_ALREADY_DISABLED:
|
||||
return Builder({
|
||||
statusCode: HttpStatus.PRECONDITION_FAILED,
|
||||
error: 'Não permitido',
|
||||
message: 'A autenticação multifator já está desabilitada',
|
||||
code,
|
||||
});
|
||||
|
||||
case ErrorCodes.AUTH.TOTP_REQUIRED:
|
||||
return Builder({
|
||||
statusCode: HttpStatus.UNAUTHORIZED,
|
||||
error: 'Não autenticado',
|
||||
message: 'Informe o token de autenticação multifator',
|
||||
code,
|
||||
});
|
||||
|
||||
case ErrorCodes.AUTH.CODE_MISMATCH:
|
||||
case ErrorCodes.AUTH.CODE_ALREADY_USED:
|
||||
return Builder({
|
||||
statusCode: HttpStatus.UNAUTHORIZED,
|
||||
error: 'Não autenticado',
|
||||
message: 'Token de autenticação multifator inválido',
|
||||
code,
|
||||
});
|
||||
|
||||
case ErrorCodes.RATE_LIMIT:
|
||||
return Builder({
|
||||
statusCode: HttpStatus.TOO_MANY_REQUESTS,
|
||||
error: 'Limite excedido',
|
||||
message:
|
||||
'Você tentou realizar essa operação muitas vezes. Tente novamente mais tarde',
|
||||
code,
|
||||
});
|
||||
|
||||
case ErrorCodes.AUTH.UNAUTHORIZED:
|
||||
return Builder({
|
||||
statusCode: HttpStatus.UNAUTHORIZED,
|
||||
error: 'Não autenticado',
|
||||
message: 'É necessário estar logado para realizar essa operação',
|
||||
code,
|
||||
});
|
||||
|
||||
case ErrorCodes.AUTH.FORBIDDEN:
|
||||
return Builder({
|
||||
statusCode: HttpStatus.FORBIDDEN,
|
||||
error: 'Não autorizado',
|
||||
message:
|
||||
'Você não tem permissões suficientes para realizar essa operação',
|
||||
code,
|
||||
});
|
||||
|
||||
case ErrorCodes.UNKNOWN:
|
||||
default:
|
||||
return Builder({
|
||||
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
error: 'Desconhecido',
|
||||
message:
|
||||
'Erro desconhecido. Tente novamente ou entre em contato com o suporte',
|
||||
code: ErrorCodes.UNKNOWN,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
export const Auth = {
|
||||
UNAUTHORIZED: 'AUTH.UNAUTHORIZED',
|
||||
FORBIDDEN: 'AUTH.FORBIDDEN',
|
||||
WRONG_CREDENTIALS: 'AUTH.WRONG_CREDENTIALS',
|
||||
WRONG_PASSWORD_CONFIRMATION: 'AUTH.WRONG_PASSWORD_CONFIRMATION',
|
||||
TOTP_NOT_ENABLED: 'AUTH.TOTP_NOT_ENABLED',
|
||||
TOTP_ALREADY_ENABLED: 'AUTH.TOTP_ALREADY_ENABLED',
|
||||
TOTP_ALREADY_DISABLED: 'AUTH.TOTP_ALREADY_DISABLED',
|
||||
TOTP_REQUIRED: 'AUTH.TOTP_REQUIRED',
|
||||
CODE_MISMATCH: 'AUTH.CODE_MISMATCH',
|
||||
CODE_ALREADY_USED: 'AUTH.CODE_ALREADY_USED',
|
||||
};
|
||||
|
||||
const ErrorCodes = {
|
||||
UNKNOWN: 'UNKNOWN',
|
||||
RATE_LIMIT: 'RATE_LIMIT',
|
||||
AUTH: Auth,
|
||||
};
|
||||
|
||||
export default ErrorCodes;
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user