Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: newsletter pagination #569

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/pr-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

jobs:
deploy-pr:
environment:
environment:
name: preview
url: ${{ steps.deploy.outputs.preview-url }}
runs-on: ubuntu-latest
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/NewsLetterSubscriptionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@ const getAllNewsletter = async (
});

return res.status(200).json({
status: "",
message: "",
status: "ok",
message: "Successful",
data: data,
meta,
});
Expand Down
2 changes: 2 additions & 0 deletions src/middleware/error.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { NextFunction, Request, Response } from "express";
import log from "../utils/logger";

class HttpError extends Error {
status_code: number;
Expand Down Expand Up @@ -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",
Expand Down
7 changes: 1 addition & 6 deletions src/models/newsLetterSubscription.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
Entity,
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
} from "typeorm";
import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";

@Entity()
export class NewsLetterSubscriber {
Expand Down
4 changes: 3 additions & 1 deletion src/services/newsLetterSubscription.service.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions src/utils/mail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading