diff --git a/Package.resolved b/Package.resolved index 33e2fb0..41bbd92 100644 --- a/Package.resolved +++ b/Package.resolved @@ -59,8 +59,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/vapor/console-kit.git", "state" : { - "revision" : "7d0898ed481e1855ec549924ab701bdc6f754b18", - "version" : "4.10.2" + "revision" : "a7dd7001196d39b758e4990ec0f26f80162f4c84", + "version" : "4.14.0" } }, { @@ -131,8 +131,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/vapor/leaf-kit.git", "state" : { - "revision" : "13f2fc4c8479113cd23876d9a434ef4573e368bb", - "version" : "1.10.2" + "revision" : "547a1340b3a063ca738be4351660f59179c8dc34", + "version" : "1.10.3" } }, { @@ -167,8 +167,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/vapor/multipart-kit.git", "state" : { - "revision" : "1adfd69df2da08f7931d4281b257475e32c96734", - "version" : "4.5.4" + "revision" : "12ee56f25bd3fc4c2d09c2aa16e69de61dc786e8", + "version" : "4.6.0" } }, { @@ -203,8 +203,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/swift-server/RediStack.git", "state" : { - "revision" : "a476f69cbbe31de5ba040309630d365d13c687f8", - "version" : "1.6.1" + "revision" : "622ce440f90d79b58e45f3a3efdd64c51d1dfd17", + "version" : "1.6.2" } }, { @@ -248,8 +248,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/swift-case-paths", "state" : { - "revision" : "ed7facdd4a361514b46e3bbc6238cd41c84be4ec", - "version" : "1.1.1" + "revision" : "bba1111185863c9288c5f047770f421c3b7793a4", + "version" : "1.1.3" } }, { @@ -275,8 +275,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-http-types", "state" : { - "revision" : "99d066e29effa8845e4761dd3f2f831edfdf8925", - "version" : "1.0.0" + "revision" : "1827dc94bdab2eb5f2fc804e9b0cb43574282566", + "version" : "1.0.2" } }, { @@ -383,8 +383,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/vapor/vapor.git", "state" : { - "revision" : "d682e05fdb64c9f7da01af096a73cd11bb7ab755", - "version" : "4.86.2" + "revision" : "67fe736c37b0ad958b9d248f010cff6c1baa5c3a", + "version" : "4.89.3" } }, { diff --git a/Sources/App/Jobs/EmailJobMongoQueue.swift b/Sources/App/Jobs/EmailJobMongoQueue.swift index 995b798..0fd557d 100644 --- a/Sources/App/Jobs/EmailJobMongoQueue.swift +++ b/Sources/App/Jobs/EmailJobMongoQueue.swift @@ -40,7 +40,7 @@ struct EmailJobMongoQueue: RecurringTask { do { _ = try await context.mailgun().send(mailgunMessage).get() } catch { - print(error) + print("EmailJobMongoQueue ExecutionContext: \(error)") } } @@ -53,7 +53,7 @@ struct EmailJobMongoQueue: RecurringTask { // If we failed to run the job for whatever reason (SMTP issue, database issue or otherwise) func onExecutionFailure(failureContext: QueuedTaskFailure) async throws -> TaskExecutionFailureAction { // Retry in 1 hour, `nil` for maxAttempts means we never stop retrying - print(failureContext.error) + print("QueuedTaskFailure: \(failureContext.error)") return .retryAfter(3600, maxAttempts: nil) } } diff --git a/Sources/App/RouteHandlers/AuthEngineHandlers/AuthenticationHandler.swift b/Sources/App/RouteHandlers/AuthEngineHandlers/AuthenticationHandler.swift index 1b3dea5..9140ef4 100644 --- a/Sources/App/RouteHandlers/AuthEngineHandlers/AuthenticationHandler.swift +++ b/Sources/App/RouteHandlers/AuthEngineHandlers/AuthenticationHandler.swift @@ -43,7 +43,10 @@ public func authenticationHandler( ) _ = try await smsAttempt.save(on: request.db).get() - let attemptId = try! smsAttempt.requireID() + //let attemptId = try! smsAttempt.requireID() + guard let attemptId = smsAttempt.id else { + throw Abort(.internalServerError, reason: "Failed to retrieve attempt ID after saving.") + } let emailPayload = EmailPayload(otpEmail, to: email) @@ -51,8 +54,9 @@ public func authenticationHandler( do { try await request.mongoQueue.queueTask(task) + request.logger.info("create queueTask success") } catch { - request.logger.info("\(error)") + request.logger.error("create queueTask: \(error)") } return EmailLoginOutput( diff --git a/docker-compose.yml b/docker-compose.yml index b82ce91..14bb7ac 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,12 +1,14 @@ version: '3.9' x-shared_environment: &shared_environment - LOG_LEVEL: ${LOG_LEVEL:-debug} + LOG_LEVEL: ${LOG_LEVEL:-info} JWTS: "${JWTS}" - MONGO_DB_PRODUCTION_URL: '${MONGO_DB_PRODUCTION_URL}' + MONGO_DB_PRODUCTION_URL: "${MONGO_DB_PRODUCTION_URL}" + TWILIO_ACCOUNT_ID: "${TWILIO_ACCOUNT_ID}" TWILIO_ACCOUNT_SECRET: "${TWILIO_ACCOUNT_SECRET}" SENDER_NUMBER: "+16097579519" + APNS_KEY_ID: "${APNS_KEY_ID}" APNS_PRIVATE_KEY: "${APNS_PRIVATE_KEY}" APNS_TEAM_ID: "${APNS_TEAM_ID}" @@ -15,28 +17,27 @@ x-shared_environment: &shared_environment REDIS_URL_PRODUCTION: '${REDIS_URL_PRODUCTION}' services: - mongo: - image: mongo:latest - container_name: AddameProduction - environment: - - AUTH=yes - - MONGODB_ADMIN_USER='${MONGODB_ADMIN_USER}' - - MONGODB_ADMIN_PASS='${MONGODB_ADMIN_PASS}' - - MONGO_INITDB_ROOT_USERNAME='${MONGODB_USER_PRODUCTION}' - - MONGO_INITDB_ROOT_PASSWORD='${MONGODB_PASS_PRODUCTION}' - - MONGO_INITDB_DATABASE='${MONGODB_DATABASE_PRODUCTION}' - volumes: - - ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro - - ./mongodb/data:/data/db - networks: - - production_gateway - restart: unless-stopped - ports: - - "27018:27017" + mongo: + image: mongo:latest + container_name: AddameMongoPro + environment: + - AUTH=yes + - MONGODB_ADMIN_USER='${MONGODB_ADMIN_USER}' + - MONGODB_ADMIN_PASS='${MONGODB_ADMIN_PASS}' + - MONGO_INITDB_ROOT_USERNAME='${MONGODB_USER_PRODUCTION}' + - MONGO_INITDB_ROOT_PASSWORD='${MONGODB_PASS_PRODUCTION}' + - MONGO_INITDB_DATABASE='${MONGODB_DATABASE_PRODUCTION}' + + volumes: + - ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro + - ./mongodb/data:/data/db + networks: + - addame_pro_gateway + restart: unless-stopped addame_server: image: addamespb/addame_server:latest - container_name: agateway + container_name: addameServer build: context: addameServer environment: @@ -44,14 +45,19 @@ services: ports: - '80:8080' - '443:8080' + - '8080:8080' command: ["serve", "--env", "production", "--hostname", "0.0.0.0", "--port", "8080"] volumes: - ~/addameServer:/addameServer_data - ./.env:/app/.env - ./.env.production:/app/.env.production + depends_on: + - mongo networks: - - production_gateway + - addame_pro_gateway restart: unless-stopped + env_file: + - ./.env redis: container_name: redisProAddame @@ -63,12 +69,12 @@ services: volumes: - redis-persistence-production:/bitnami/redis/data networks: - - production_gateway + - addame_pro_gateway volumes: addameServer: redis-persistence-production: networks: - production_gateway: + addame_pro_gateway: name: Default