Skip to content

Commit

Permalink
Apply formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ama-cantabile authored and github-actions[bot] committed May 10, 2024
1 parent 6d1c816 commit e3b6bfa
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 84 deletions.
42 changes: 24 additions & 18 deletions src/app/api/job-posting/disabled/route.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
import { NextResponse } from 'next/server';
import { getPaginationParams, fetchJobPostings, handleError } from '../siteRequestUtils';

import {
getPaginationParams,
fetchJobPostings,
handleError,
} from '../siteRequestUtils';

export async function GET(req) {
try {
//Todo: Update the site3 name to disabled
const siteCriteria = { site3: true };

// Extract pagination parameters
const { skip, pageSize } = getPaginationParams(req);
try {
//Todo: Update the site3 name to disabled
const siteCriteria = { site3: true };

// Query job postings with pagination
const jobPostings = await fetchJobPostings(siteCriteria, skip, pageSize);
// Extract pagination parameters
const { skip, pageSize } = getPaginationParams(req);

if (jobPostings.length === 0) {
return NextResponse.json({ message: 'Not Found - No job postings found on this page' }, { status: 404 });
}
// Query job postings with pagination
const jobPostings = await fetchJobPostings(siteCriteria, skip, pageSize);

// Return success response with the paginated job postings
return NextResponse.json({ jobPostings }, { status: 200 });
} catch (error) {
// Handle errors
return handleError(error);
if (jobPostings.length === 0) {
return NextResponse.json(
{ message: 'Not Found - No job postings found on this page' },
{ status: 404 }
);
}

// Return success response with the paginated job postings
return NextResponse.json({ jobPostings }, { status: 200 });
} catch (error) {
// Handle errors
return handleError(error);
}
}
42 changes: 24 additions & 18 deletions src/app/api/job-posting/indigenous/route.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
import { NextResponse } from 'next/server';
import { getPaginationParams, fetchJobPostings, handleError } from '../siteRequestUtils';

import {
getPaginationParams,
fetchJobPostings,
handleError,
} from '../siteRequestUtils';

export async function GET(req) {
try {
//Todo: Update the site1 name to indigenous
const siteCriteria = { site1: true };

// Extract pagination parameters
const { skip, pageSize } = getPaginationParams(req);
try {
//Todo: Update the site1 name to indigenous
const siteCriteria = { site1: true };

// Query job postings with pagination
const jobPostings = await fetchJobPostings(siteCriteria, skip, pageSize);
// Extract pagination parameters
const { skip, pageSize } = getPaginationParams(req);

if (jobPostings.length === 0) {
return NextResponse.json({ message: 'Not Found - No job postings found on this page' }, { status: 404 });
}
// Query job postings with pagination
const jobPostings = await fetchJobPostings(siteCriteria, skip, pageSize);

// Return success response with the paginated job postings
return NextResponse.json({ jobPostings }, { status: 200 });
} catch (error) {
// Handle errors
return handleError(error);
if (jobPostings.length === 0) {
return NextResponse.json(
{ message: 'Not Found - No job postings found on this page' },
{ status: 404 }
);
}

// Return success response with the paginated job postings
return NextResponse.json({ jobPostings }, { status: 200 });
} catch (error) {
// Handle errors
return handleError(error);
}
}
42 changes: 24 additions & 18 deletions src/app/api/job-posting/newcomers/route.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
import { NextResponse } from 'next/server';
import { getPaginationParams, fetchJobPostings, handleError } from '../siteRequestUtils';

import {
getPaginationParams,
fetchJobPostings,
handleError,
} from '../siteRequestUtils';

export async function GET(req) {
try {
//Todo: Update the site2 name to newcomers
const siteCriteria = { site2: true };

// Extract pagination parameters
const { skip, pageSize } = getPaginationParams(req);
try {
//Todo: Update the site2 name to newcomers
const siteCriteria = { site2: true };

// Query job postings with pagination
const jobPostings = await fetchJobPostings(siteCriteria, skip, pageSize);
// Extract pagination parameters
const { skip, pageSize } = getPaginationParams(req);

if (jobPostings.length === 0) {
return NextResponse.json({ message: 'Not Found - No job postings found on this page' }, { status: 404 });
}
// Query job postings with pagination
const jobPostings = await fetchJobPostings(siteCriteria, skip, pageSize);

// Return success response with the paginated job postings
return NextResponse.json({ jobPostings }, { status: 200 });
} catch (error) {
// Handle errors
return handleError(error);
if (jobPostings.length === 0) {
return NextResponse.json(
{ message: 'Not Found - No job postings found on this page' },
{ status: 404 }
);
}

// Return success response with the paginated job postings
return NextResponse.json({ jobPostings }, { status: 200 });
} catch (error) {
// Handle errors
return handleError(error);
}
}
42 changes: 24 additions & 18 deletions src/app/api/job-posting/students/route.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
import { NextResponse } from 'next/server';
import { getPaginationParams, fetchJobPostings, handleError } from '../siteRequestUtils';

import {
getPaginationParams,
fetchJobPostings,
handleError,
} from '../siteRequestUtils';

export async function GET(req) {
try {
//Todo: Update the site4 name to students
const siteCriteria = { site4: true };

// Extract pagination parameters
const { skip, pageSize } = getPaginationParams(req);
try {
//Todo: Update the site4 name to students
const siteCriteria = { site4: true };

// Query job postings with pagination
const jobPostings = await fetchJobPostings(siteCriteria, skip, pageSize);
// Extract pagination parameters
const { skip, pageSize } = getPaginationParams(req);

if (jobPostings.length === 0) {
return NextResponse.json({ message: 'Not Found - No job postings found on this page' }, { status: 404 });
}
// Query job postings with pagination
const jobPostings = await fetchJobPostings(siteCriteria, skip, pageSize);

// Return success response with the paginated job postings
return NextResponse.json({ jobPostings }, { status: 200 });
} catch (error) {
// Handle errors
return handleError(error);
if (jobPostings.length === 0) {
return NextResponse.json(
{ message: 'Not Found - No job postings found on this page' },
{ status: 404 }
);
}

// Return success response with the paginated job postings
return NextResponse.json({ jobPostings }, { status: 200 });
} catch (error) {
// Handle errors
return handleError(error);
}
}
24 changes: 12 additions & 12 deletions src/libs/mongodb.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import mongoose from "mongoose";
import mongoose from 'mongoose';

let isConnected = false;
let db = null;

export const connectMongoDB = async () => {
try {
if (!isConnected) {
db = await mongoose.connect(process.env.MONGO_CONNECT);
isConnected = true;
console.log('Connected to MongoDB');
}
return db;
} catch (error) {
console.log('Error connecting to MongoDB', error);
throw error;
try {
if (!isConnected) {
db = await mongoose.connect(process.env.MONGO_CONNECT);
isConnected = true;
console.log('Connected to MongoDB');
}
};
return db;
} catch (error) {
console.log('Error connecting to MongoDB', error);
throw error;
}
};

0 comments on commit e3b6bfa

Please sign in to comment.