Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
keyurboss committed Jun 16, 2024
2 parents f9f2826 + d5e00fa commit 2660bd6
Show file tree
Hide file tree
Showing 5 changed files with 1,514 additions and 52 deletions.
55 changes: 4 additions & 51 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,57 +21,10 @@ services:
environment:
- APP_ENV=${APP_ENV}
- PORT=${PORT}
- DB_URL=${DB_URL}
- DB_NAME=${DB_NAME}
- REDIS_DB_HOST=redis
- REDIS_DB_PORT=${REDIS_DB_PORT}
- REDIS_DB_PASSWORD=${REDIS_DB_PASSWORD}
- REDIS_DB_DATABASE=${REDIS_DB_DATABASE}
- ACCESS_TOKEN_KEY=${ACCESS_TOKEN_KEY}
- REFRESH_TOKEN_KEY=${REFRESH_TOKEN_KEY}
- FIREBASE_JSON_STRING=${FIREBASE_JSON_STRING}
- FIREBASE_DATABASE_URL=${FIREBASE_DATABASE_URL}
- ALLOW_LOCAL_NO_AUTH=${ALLOW_LOCAL_NO_AUTH}
- AUTO_CONNECT_TO_WHATSAPP=${AUTO_CONNECT_TO_WHATSAPP}
- OPEN_BROWSER_FOR_SCAN=${OPEN_BROWSER_FOR_SCAN}
ports:
- 5000:${PORT}

redis:
image: redis:alpine
command:
- '--port ${REDIS_DB_PORT}'
- '--requirepass ${REDIS_DB_PASSWORD}'
ports:
- '${REDIS_DB_PORT}:${REDIS_DB_PORT}'

# The commented out section below is an example of how to define a PostgreSQL
# database that your application can use. `depends_on` tells Docker Compose to
# start the database before your application. The `db-data` volume persists the
# database data between container restarts. The `db-password` secret is used
# to set the database password. You must create `db/password.txt` and add
# a password of your choosing to it before running `docker compose up`.
# depends_on:
# db:
# condition: service_healthy
# db:
# image: postgres
# restart: always
# user: postgres
# secrets:
# - db-password
# volumes:
# - db-data:/var/lib/postgresql/data
# environment:
# - POSTGRES_DB=example
# - POSTGRES_PASSWORD_FILE=/run/secrets/db-password
# expose:
# - 5432
# healthcheck:
# test: [ "CMD", "pg_isready" ]
# interval: 10s
# timeout: 5s
# retries: 5
# volumes:
# db-data:
# secrets:
# db-password:
# file: db/password.txt


8 changes: 7 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
)

var version string
var app *fiber.App

func main() {
println(version)
Expand All @@ -38,6 +39,11 @@ func main() {
os.Mkdir("./tmp", 0777)
}()
env.ServerConfig = ReadConfigFileAndReturnIt(env.CurrentDirectory)
outputLogFolderDir := filepath.Join(env.CurrentDirectory, "whatsapp_server_logs")

if _, err := os.Stat(outputLogFolderDir); errors.Is(err, os.ErrNotExist) {
os.MkdirAll(outputLogFolderDir, 0777)
}
whatsapp.OutPutFilePath = ReturnOutPutFilePath(env.CurrentDirectory)
whatsapp.InitSqlContainer()
if env.Env.AUTO_CONNECT_TO_WHATSAPP {
Expand Down Expand Up @@ -121,7 +127,7 @@ func ReadConfigFileAndReturnIt(currentDir string) *env.IServerConfig {
func ReturnOutPutFilePath(currentDir string) string {
t := time.Now()
today := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, t.Nanosecond(), t.Location()).Unix()
return filepath.Join(currentDir, "whatsapp_server_logs", fmt.Sprintf("%d.log.csv", today))
return filepath.Join(currentDir, fmt.Sprintf("%d.log.csv", today))
}
func check(e error) {
if e != nil {
Expand Down
23 changes: 23 additions & 0 deletions swagger/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="SwaggerUI" />
<title>SwaggerUI</title>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/swagger-ui.css" />
</head>
<body>
<div id="swagger-ui"></div>
<script src="https://unpkg.com/[email protected]/swagger-ui-bundle.js" crossorigin></script>
<script>
window.onload = () => {
window.ui = SwaggerUIBundle({
// url: `${location.protocol}//${location.host}/swagger/swagger.json`,
url: '/swagger/swagger.json',
dom_id: '#swagger-ui',
});
};
</script>
</body>
</html>
Loading

0 comments on commit 2660bd6

Please sign in to comment.