diff --git a/.github/workflows/pr-deploy.yml b/.github/workflows/pr-deploy.yml index 2c28b1a6..58672f1a 100644 --- a/.github/workflows/pr-deploy.yml +++ b/.github/workflows/pr-deploy.yml @@ -6,7 +6,7 @@ on: jobs: deploy-pr: - environment: + environment: name: preview url: ${{ steps.deploy.outputs.preview-url }} runs-on: ubuntu-latest @@ -23,11 +23,11 @@ jobs: server_password: ${{ secrets.SERVER_PASSWORD }} server_port: ${{ secrets.SERVER_PORT }} comment: true - context: '.' - dockerfile: 'Dockerfile' - exposed_port: '8000' - host_volume_path: '/var/appdata' - container_volume_path: '/app/data' + context: "." + dockerfile: "Dockerfile" + exposed_port: "8000" + host_volume_path: "/var/appdata" + container_volume_path: "/app/data" github_token: ${{ secrets.GITHUB_TOKEN }} - name: Print Preview URL diff --git a/src/controllers/NewsLetterSubscriptionController.ts b/src/controllers/NewsLetterSubscriptionController.ts index 9bb5a869..7475fd19 100644 --- a/src/controllers/NewsLetterSubscriptionController.ts +++ b/src/controllers/NewsLetterSubscriptionController.ts @@ -294,8 +294,8 @@ const getAllNewsletter = async ( }); return res.status(200).json({ - status: "", - message: "", + status: "ok", + message: "Successful", data: data, meta, }); diff --git a/src/middleware/error.ts b/src/middleware/error.ts index 32ce4a4f..2547ab99 100644 --- a/src/middleware/error.ts +++ b/src/middleware/error.ts @@ -1,4 +1,5 @@ import { NextFunction, Request, Response } from "express"; +import log from "../utils/logger"; class HttpError extends Error { status_code: number; @@ -65,6 +66,7 @@ const errorHandler = ( _next: NextFunction, ) => { const { success, status_code, message } = err; + log.error({ err }); const cleanedMessage = message.replace(/"/g, ""); res.status(status_code).json({ success: success || "unsuccessful", diff --git a/src/models/newsLetterSubscription.ts b/src/models/newsLetterSubscription.ts index a9a41829..1c0e4d30 100644 --- a/src/models/newsLetterSubscription.ts +++ b/src/models/newsLetterSubscription.ts @@ -1,9 +1,4 @@ -import { - Entity, - PrimaryGeneratedColumn, - Column, - CreateDateColumn, -} from "typeorm"; +import { Column, Entity, PrimaryGeneratedColumn } from "typeorm"; @Entity() export class NewsLetterSubscriber { diff --git a/src/services/newsLetterSubscription.service.ts b/src/services/newsLetterSubscription.service.ts index 24052042..e830327c 100644 --- a/src/services/newsLetterSubscription.service.ts +++ b/src/services/newsLetterSubscription.service.ts @@ -1,8 +1,8 @@ import { Repository } from "typeorm"; import AppDataSource from "../data-source"; +import { BadRequest, HttpError, ResourceNotFound } from "../middleware"; import { NewsLetterSubscriber } from "../models/newsLetterSubscription"; import { INewsLetterSubscriptionService } from "../types"; -import { BadRequest, HttpError, ResourceNotFound } from "../middleware"; export class NewsLetterSubscriptionService implements INewsLetterSubscriptionService @@ -75,6 +75,8 @@ export class NewsLetterSubscriptionService limit?: number; }) { try { + page = page ? page : 1; + limit = limit ? limit : 10; const [newsletters, total] = await this.newsLetterSubscriber.findAndCount( { skip: (page - 1) * limit, diff --git a/src/utils/mail.ts b/src/utils/mail.ts index c67bb0f2..20a8f9fd 100644 --- a/src/utils/mail.ts +++ b/src/utils/mail.ts @@ -5,10 +5,10 @@ import log from "./logger"; const Sendmail = async (emailcontent: any) => { const transporter = nodemailer.createTransport({ - service: config.SMTP_SERVICE, - host: "smtp.gmail.com", - port: 587, - secure: false, + // service: config.SMTP_SERVICE, + host: "sandbox.smtp.mailtrap.io", + port: 2525, + // secure: false, auth: { user: config.SMTP_USER, pass: config.SMTP_PASSWORD,