refactor: use NextResponse
This commit is contained in:
@@ -8,11 +8,12 @@ import {
|
|||||||
STATUS_OK
|
STATUS_OK
|
||||||
} from '@utils/statusCodes';
|
} from '@utils/statusCodes';
|
||||||
import { ConfirmationSchema, ResponseType } from '@utils/validationSchemas';
|
import { ConfirmationSchema, ResponseType } from '@utils/validationSchemas';
|
||||||
|
import { NextRequest } from 'next/server';
|
||||||
import { Resend } from 'resend';
|
import { Resend } from 'resend';
|
||||||
|
|
||||||
export const dynamic = 'force-dynamic'; // defaults to force-static
|
export const dynamic = 'force-dynamic'; // defaults to force-static
|
||||||
|
|
||||||
export async function POST(request: Request) {
|
export async function POST(request: NextRequest) {
|
||||||
try {
|
try {
|
||||||
if (!process.env.RESEND_KEY || !process.env.RESEND_AUDIENCE) {
|
if (!process.env.RESEND_KEY || !process.env.RESEND_AUDIENCE) {
|
||||||
throw new Error('RESEND_AUDIENCE is not set');
|
throw new Error('RESEND_AUDIENCE is not set');
|
||||||
|
|||||||
@@ -8,9 +8,10 @@ import {
|
|||||||
} from '@utils/statusCodes';
|
} from '@utils/statusCodes';
|
||||||
import { getSingleNews, getTopNews } from '@utils/urls';
|
import { getSingleNews, getTopNews } from '@utils/urls';
|
||||||
import { NewsDatabaseSchema, NewsDatabaseType } from '@utils/validationSchemas';
|
import { NewsDatabaseSchema, NewsDatabaseType } from '@utils/validationSchemas';
|
||||||
|
import { NextRequest } from 'next/server';
|
||||||
import { Resend } from 'resend';
|
import { Resend } from 'resend';
|
||||||
|
|
||||||
export async function GET(request: Request) {
|
export async function GET(request: NextRequest) {
|
||||||
if (
|
if (
|
||||||
request.headers.get('Authorization') !== `Bearer ${process.env.CRON_SECRET}`
|
request.headers.get('Authorization') !== `Bearer ${process.env.CRON_SECRET}`
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -8,12 +8,13 @@ import {
|
|||||||
STATUS_OK,
|
STATUS_OK,
|
||||||
STATUS_UNAUTHORIZED
|
STATUS_UNAUTHORIZED
|
||||||
} from '@utils/statusCodes';
|
} from '@utils/statusCodes';
|
||||||
|
import { NextRequest } from 'next/server';
|
||||||
import { Resend } from 'resend';
|
import { Resend } from 'resend';
|
||||||
|
|
||||||
const ONE_DAY_IN_MS = 1000 * 60 * 60 * 24;
|
const ONE_DAY_IN_MS = 1000 * 60 * 60 * 24;
|
||||||
const TEN_MINUTES_IN_MS = 1000 * 10 * 60;
|
const TEN_MINUTES_IN_MS = 1000 * 10 * 60;
|
||||||
|
|
||||||
export async function GET(request: Request) {
|
export async function GET(request: NextRequest) {
|
||||||
if (
|
if (
|
||||||
request.headers.get('Authorization') !== `Bearer ${process.env.CRON_SECRET}`
|
request.headers.get('Authorization') !== `Bearer ${process.env.CRON_SECRET}`
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -11,9 +11,10 @@ import {
|
|||||||
} from '@utils/statusCodes';
|
} from '@utils/statusCodes';
|
||||||
import { ResponseType, SubscribeFormSchema } from '@utils/validationSchemas';
|
import { ResponseType, SubscribeFormSchema } from '@utils/validationSchemas';
|
||||||
import * as crypto from 'crypto';
|
import * as crypto from 'crypto';
|
||||||
|
import { NextRequest } from 'next/server';
|
||||||
import { Resend } from 'resend';
|
import { Resend } from 'resend';
|
||||||
|
|
||||||
export async function POST(request: Request) {
|
export async function POST(request: NextRequest) {
|
||||||
try {
|
try {
|
||||||
if (!process.env.RESEND_KEY || !process.env.RESEND_AUDIENCE) {
|
if (!process.env.RESEND_KEY || !process.env.RESEND_AUDIENCE) {
|
||||||
throw new Error('RESEND_KEY is not set');
|
throw new Error('RESEND_KEY is not set');
|
||||||
|
|||||||
@@ -10,11 +10,12 @@ import {
|
|||||||
STATUS_OK
|
STATUS_OK
|
||||||
} from '@utils/statusCodes';
|
} from '@utils/statusCodes';
|
||||||
import { ResponseType, UnsubscribeFormSchema } from '@utils/validationSchemas';
|
import { ResponseType, UnsubscribeFormSchema } from '@utils/validationSchemas';
|
||||||
|
import { NextRequest } from 'next/server';
|
||||||
import { Resend } from 'resend';
|
import { Resend } from 'resend';
|
||||||
|
|
||||||
export const dynamic = 'force-dynamic'; // defaults to force-static
|
export const dynamic = 'force-dynamic'; // defaults to force-static
|
||||||
|
|
||||||
export async function POST(request: Request) {
|
export async function POST(request: NextRequest) {
|
||||||
try {
|
try {
|
||||||
if (!process.env.RESEND_KEY || !process.env.RESEND_AUDIENCE) {
|
if (!process.env.RESEND_KEY || !process.env.RESEND_AUDIENCE) {
|
||||||
throw new Error('RESEND_AUDIENCE is not set');
|
throw new Error('RESEND_AUDIENCE is not set');
|
||||||
|
|||||||
Reference in New Issue
Block a user