Skip to content

Commit

Permalink
🔄💻🛠️ general code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
jrCleber committed Dec 9, 2023
1 parent 0b16a32 commit ba667a9
Show file tree
Hide file tree
Showing 74 changed files with 5,711 additions and 7,263 deletions.
178 changes: 68 additions & 110 deletions src/dev-env.yml → .env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# │ @filename dev-env.yml │
# │ Developed by: Cleber Wilson │
# │ File name: dev-env.yml │
# │ Creation date: Nov 27, 2022
# │ Creation date: Dez 03, 2023
# │ Contact: [email protected]
# ├──────────────────────────────────────────────────────────────────────────────┤
# │ @copyright © Cleber Wilson 2022. All rights reserved. │
Expand Down Expand Up @@ -36,118 +36,76 @@
# ⚠️ COPY THIS FILE TO env.yml

# Choose the server type for the application
SERVER:
TYPE: http # https
PORT: 8083 # 443

CORS:
ORIGIN:
- '*'
# - yourdomain.com
METHODS:
- POST
- GET
- PUT
- DELETE
CREDENTIALS: true

# Install ssl certificate and replace string <domain> with domain name
# Access: https://certbot.eff.org/instructions?ws=other&os=ubuntufocal
SSL_CONF:
PRIVKEY: /etc/letsencrypt/live/<domain>/privkey.pem
FULLCHAIN: /etc/letsencrypt/live/<domain>/fullchain.pem

# Determine the logs to be displayed
LOG:
LEVEL:
- ERROR
- WARN
- DEBUG
- INFO
- LOG
- VERBOSE
- DARK
COLOR: true

SERVER_PORT=8084
SESSION_HTTP_SECRET=W0NvZGVDaGF0XTpbU2Vzc

LOG_LEVEL=ERROR|WARN|INFO|DEBUG|LOG
LOG_COLOR=true

# Temporary data storage
STORE_CLEANING_INTERVAL=7200 # 2 hours
STORE_MESSAGES=true
STORE_CONTACTS=true
STORE_CHATS=true

# Permanente data storage
DATABASE_ENABLED=true
DATABASE_URL=postgres://USER:PASS@HOST:PORT/codechat_api_v1?schema=public
DATABASE_SYNC_MESSAGES=true
DATABASE_SAVE_DATA_NEW_MESSAGE=true
DATABASE_SAVE_MESSAGE_UPDATE=true
DATABASE_SAVE_DATA_CONTACTS=true
DATABASE_SAVE_DATA_CHATS=true
DATABASE_SAVE_LOGS=true

# Global Webhook
# It will notify all events of all businesses and instances.
GLOBAL_WEBHOOK_URL=url
GLOBAL_WEBHOOK_ENABLED=false

# Determine how long the instance should be deleted from memory in case of no connection.
# Default time: 5 minutes
# If you don't even want an expiration, enter the value false
DEL_INSTANCE: 5 # or false

# Temporary data storage
STORE:
CLEANING_INTERVAL: 7200 # seconds === 2h
MESSAGE: true
CONTACTS: false
CHATS: false

# Permanent data storage
DATABASE:
ENABLED: false
CONNECTION:
URI: 'mongodb://<USER>:<PASSWORD>@<HOST>/?authSource=admin&readPreference=primary&ssl=false&directConnection=true'
DB_PREFIX_NAME: codechat
# Choose the data you want to save in the application's database or store
SAVE_DATA:
INSTANCE: false
OLD_MESSAGE: false
NEW_MESSAGE: true
MESSAGE_UPDATE: true
CONTACTS: true
CHATS: true

REDIS:
ENABLED: false
URI: 'redis://<HOST>'
PREFIX_KEY: 'codechat'

# Webhook Settings
WEBHOOK:
# Define a global webhook that will listen for enabled events from all instances
GLOBAL:
URL: <url>
ENABLED: false
# Automatically maps webhook paths
# Set the events you want to hear
EVENTS:
QRCODE_UPDATED: true
MESSAGES_SET: true
MESSAGES_UPSERT: true
MESSAGES_UPDATE: true
SEND_MESSAGE: true
CONTACTS_SET: true
CONTACTS_UPSERT: true
CONTACTS_UPDATE: true
PRESENCE_UPDATE: true
CHATS_SET: true
CHATS_UPSERT: true
CHATS_UPDATE: true
CHATS_DELETE: true
GROUPS_UPSERT: true
GROUP_UPDATE: true
GROUP_PARTICIPANTS_UPDATE: true
CONNECTION_UPDATE: true
# This event fires every time a new token is requested via the refresh route
NEW_JWT_TOKEN: true

CONFIG_SESSION_PHONE:
# Name that will be displayed on smartphone connection
CLIENT: CodeChat
NAME: Chrome # firefox | edge | opera | safari
INSTANCE_EXPIRATION_TIME=false

# Name that will be displayed on smartphone connection
CONFIG_SESSION_PHONE_CLIENT=CodeChat_V1
CONFIG_SESSION_PHONE_NAME=Edge
# Set qrcode display limit
QRCODE:
LIMIT: 6

# Defines an authentication type for the api
AUTHENTICATION:
TYPE: jwt # or apikey->(deprecated)
# Define a global apikey to access all instances
# OBS: This key must be inserted in the request header to create an instance.
API_KEY: zYzP7ocstxh3SJ23D4FZTCu4ehnM8v4hu
# Set the secret key to encrypt and decrypt your token and its expiration time.
JWT:
EXPIRIN_IN: 0 # seconds - 3600s === 1h | zero (0) - never expires
SECRET: 3RFYiiRmvNiokSBrLZzx

SESSION_SECRET: W0NvZGVDaGF0XTpbU2Vzc2lvbiBTZWNyZXQgS2V5Ll0=
QRCODE_LIMIT=10

AUTHENTICATION_GLOBAL_AUTH_TOKEN=zYzP7ocstxh3Sscefew4FZTCu4ehnM8v4hu

# 0 = never expires | 3600 = 1 hour | 86400 = 1 day | 604800 = 1 week
AUTHENTICATION_JWT_EXPIRES_IN=0
AUTHENTICATION_JWT_SECRET=3RFYwe-fwf4fw4w8e-BrLZzx

REDIS_ENABLED=false
REDIS_URI=redis://localhost:6379
REDIS_PREFIX=codechat

# https://docs.codechat.dev/api/v1/whatsapp-api/whatsapp-api-configuration#s3
S3_ENABLED=false
S3_ACCESS_KEY=access_key_id
S3_SECRET_KEY=secret_access_key
S3_BUCKET=bucket_name
S3_PORT=9000
S3_ENDPOINT=127.0.0.1
S3_USE_SSL=false

# AMAZON S3 - Environment variables
# S3_ENABLED=true
# S3_BUCKET=bucket_name
# S3_ACCESS_KEY=access_key_id
# S3_SECRET_KEY=secret_access_key
# S3_ENDPOINT=s3.amazonaws.com # region: s3.eu-west-3.amazonaws.com

# MINIO Use SSL - Environment variables
# S3_ENABLED=true
# S3_ACCESS_KEY=access_key_id
# S3_SECRET_KEY=secret_access_key
# S3_BUCKET=bucket_name
# S3_PORT=443
# S3_ENDPOINT=s3.domain.com
# S3_USE_SSL=true
27 changes: 21 additions & 6 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CodeChat IMG
name: CodeChat Doker Image CI

on:
push:
Expand All @@ -7,12 +7,27 @@ on:
branches: [ "main" ]

jobs:

build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Build the Docker image
run: docker build . --file Dockerfile --tag my-image-name:$(date +%s)
- name: Checkout code
uses: actions/checkout@v3

- name: Get package version
id: get_version
run: echo "::set-output name=version::$(jq -r .version package.json)"

- name: Build and tag Docker image
run: |
docker build . --file Dockerfile --tag codechat/api:${{ steps.get_version.outputs.version }}
docker tag codechat/api:${{ steps.get_version.outputs.version }} codechat/api:latest
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Push Docker image to Docker Hub
run: docker push codechat/api:latest
31 changes: 31 additions & 0 deletions .github/workflows/release-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Generate Tags

on:
push:
branches:
- main

jobs:
tag:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install dependencies
run: npm ci

- name: Get version from package.json
id: version
run: echo "::set-output name=version::$(node -p -e "require('./package.json').version")"

- name: Generate tag
id: tag
run: echo "::set-output name=tag::v${{ steps.version.outputs.version }}.${{ github.run_number }}"

- name: Create tag
run: git tag ${{ steps.tag.outputs.tag }}

- name: Push tag to remote repository
run: git push origin ${{ steps.tag.outputs.tag }}
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,4 @@ lerna-debug.log*
/instances/*
!/instances/.gitkeep
/test/
/src/env.yml
/store
/public2
.env
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Changelog

Access the official endpoint documentation 👉🏼 [https://docs.codechat.dev/](https://docs.codechat.dev/api/v1.3.0).

<a name="1.3.0"></a>


## 1.3.0 (2023-12-09)

### Added

- 🆕💾 Subistituição do banco de dados mongodb pelo postgres. [[9b574ec](https://github.com/code-chat-br/whatsapp-api/commit/9b574ec)] [[7b2389f](https://github.com/code-chat-br/whatsapp-api/commit/7b2389f)]
- 🆕🔷 Prisma ORM. [[a2474ed](https://github.com/code-chat-br/whatsapp-api/commit/a2474ed)]
- 🆕🔗 Integração com o MinIO para armazenamento de midias em geral. [[e71a9f9](https://github.com/code-chat-br/whatsapp-api/commit/e71a9f9)]
- 🆕🔗 Integração com o Typebot - endpoints e serviços. [[88f2d1b](https://github.com/code-chat-br/whatsapp-api/commit/88f2d1b)]
-

### Changed

- 🐛💥 Reconfiguration of the code that saves the instances in redis. [[0b16a32](https://github.com/code-chat-br/whatsapp-api/commit/0b16a32)]
- 🔄💻🛠️
Loading

0 comments on commit ba667a9

Please sign in to comment.