Skip to content
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
14,310 changes: 14,310 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion src/controllers/kitchen-sink/statuscode.controllers.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import fs from "fs";
import { asyncHandler } from "../../utils/asyncHandler.js";
import statusCodesJson from "../../json/status-codes.json" assert { type: "json" };
import { ApiError } from "../../utils/ApiError.js";
import { ApiResponse } from "../../utils/ApiResponse.js";

// use fs.readFileSync to load JSON synchronously in ES module context.
const statusCodesJson = JSON.parse(
fs.readFileSync(
new URL("../../json/status-codes.json", import.meta.url),
"utf-8"
)
);

/**
* @description status codes which are avoiding sending response due to their nature
*/
Expand Down
7 changes: 6 additions & 1 deletion src/controllers/public/book.controllers.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import booksJson from "../../json/books.json" assert { type: "json" };
import fs from "fs";
import { filterObjectKeys, getPaginatedPayload } from "../../utils/helpers.js";
import { ApiError } from "../../utils/ApiError.js";
import { ApiResponse } from "../../utils/ApiResponse.js";
import { asyncHandler } from "../../utils/asyncHandler.js";

// use fs.readFileSync to load JSON synchronously in ES module context.
const booksJson = JSON.parse(
fs.readFileSync(new URL("../../json/books.json", import.meta.url), "utf-8")
);

const getBooks = asyncHandler(async (req, res) => {
const page = +(req.query.page || 1);
const limit = +(req.query.limit || 10);
Expand Down
7 changes: 6 additions & 1 deletion src/controllers/public/cat.controllers.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import catsJson from "../../json/cats.json" assert { type: "json" };
import fs from "fs";
import { filterObjectKeys, getPaginatedPayload } from "../../utils/helpers.js";
import { ApiError } from "../../utils/ApiError.js";
import { ApiResponse } from "../../utils/ApiResponse.js";
import { asyncHandler } from "../../utils/asyncHandler.js";

// use fs.readFileSync to load JSON synchronously in ES module context.
const catsJson = JSON.parse(
fs.readFileSync(new URL("../../json/cats.json", import.meta.url), "utf-8")
);

const getCats = asyncHandler(async (req, res) => {
const page = +(req.query.page || 1);
const limit = +(req.query.limit || 10);
Expand Down
7 changes: 6 additions & 1 deletion src/controllers/public/dog.controllers.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import dogsJson from "../../json/dogs.json" assert { type: "json" };
import fs from "fs";
import { filterObjectKeys, getPaginatedPayload } from "../../utils/helpers.js";
import { ApiError } from "../../utils/ApiError.js";
import { ApiResponse } from "../../utils/ApiResponse.js";
import { asyncHandler } from "../../utils/asyncHandler.js";

// use fs.readFileSync to load JSON synchronously in ES module context.
const dogsJson = JSON.parse(
fs.readFileSync(new URL("../../json/dogs.json", import.meta.url), "utf-8")
);

const getDogs = asyncHandler(async (req, res) => {
const page = +(req.query.page || 1);
const limit = +(req.query.limit || 10);
Expand Down
7 changes: 6 additions & 1 deletion src/controllers/public/meal.controllers.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import mealsJson from "../../json/meals.json" assert { type: "json" };
import fs from "fs";
import { filterObjectKeys, getPaginatedPayload } from "../../utils/helpers.js";
import { ApiError } from "../../utils/ApiError.js";
import { ApiResponse } from "../../utils/ApiResponse.js";
import { asyncHandler } from "../../utils/asyncHandler.js";

// use fs.readFileSync to load JSON synchronously in ES module context.
const mealsJson = JSON.parse(
fs.readFileSync(new URL("../../json/meals.json", import.meta.url), "utf-8")
);

const getMeals = asyncHandler(async (req, res) => {
const page = +(req.query.page || 1);
const limit = +(req.query.limit || 10);
Expand Down
7 changes: 6 additions & 1 deletion src/controllers/public/quote.controllers.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import quotesJson from "../../json/quotes.json" assert { type: "json" };
import fs from "fs";
import { filterObjectKeys, getPaginatedPayload } from "../../utils/helpers.js";
import { ApiError } from "../../utils/ApiError.js";
import { ApiResponse } from "../../utils/ApiResponse.js";
import { asyncHandler } from "../../utils/asyncHandler.js";

// use fs.readFileSync to load JSON synchronously in ES module context.
const quotesJson = JSON.parse(
fs.readFileSync(new URL("../../json/quotes.json", import.meta.url), "utf-8")
);

const getQuotes = asyncHandler(async (req, res) => {
const page = +(req.query.page || 1);
const limit = +(req.query.limit || 10);
Expand Down
10 changes: 9 additions & 1 deletion src/controllers/public/randomjoke.controllers.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import randomJokesJson from "../../json/randomjoke.json" assert { type: "json" };
import fs from "fs";
import { filterObjectKeys, getPaginatedPayload } from "../../utils/helpers.js";
import { ApiError } from "../../utils/ApiError.js";
import { ApiResponse } from "../../utils/ApiResponse.js";
import { asyncHandler } from "../../utils/asyncHandler.js";

// use fs.readFileSync to load JSON synchronously in ES module context.
const randomJokesJson = JSON.parse(
fs.readFileSync(
new URL("../../json/randomjoke.json", import.meta.url),
"utf-8"
)
);

const getRandomJokes = asyncHandler(async (req, res) => {
const page = +(req.query.page || 1);
const limit = +(req.query.limit || 10);
Expand Down
10 changes: 9 additions & 1 deletion src/controllers/public/randomproduct.controllers.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import randomProductsJson from "../../json/randomproduct.json" assert { type: "json" };
import fs from "fs";
import { filterObjectKeys, getPaginatedPayload } from "../../utils/helpers.js";
import { ApiError } from "../../utils/ApiError.js";
import { ApiResponse } from "../../utils/ApiResponse.js";
import { asyncHandler } from "../../utils/asyncHandler.js";

// use fs.readFileSync to load JSON synchronously in ES module context.
const randomJokesJson = JSON.parse(
fs.readFileSync(
new URL("../../json/randomjoke.json", import.meta.url),
"utf-8"
)
);

const getRandomProducts = asyncHandler(async (req, res) => {
const page = +(req.query.page || 1);
const limit = +(req.query.limit || 10);
Expand Down
10 changes: 9 additions & 1 deletion src/controllers/public/randomuser.controllers.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import randomUsersJson from "../../json/randomuser.json" assert { type: "json" };
import fs from "fs";
import { filterObjectKeys, getPaginatedPayload } from "../../utils/helpers.js";
import { ApiError } from "../../utils/ApiError.js";
import { ApiResponse } from "../../utils/ApiResponse.js";
import { asyncHandler } from "../../utils/asyncHandler.js";

// use fs.readFileSync to load JSON synchronously in ES module context.
const randomUsersJson = JSON.parse(
fs.readFileSync(
new URL("../../json/randomuser.json", import.meta.url),
"utf-8"
)
);

const getRandomUsers = asyncHandler(async (req, res) => {
const page = +(req.query.page || 1);
const limit = +(req.query.limit || 10);
Expand Down
10 changes: 9 additions & 1 deletion src/controllers/public/stock.controllers.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import nseStocksJson from "../../json/nse-stocks.json" assert { type: "json" };
import fs from "fs";
import { filterObjectKeys, getPaginatedPayload } from "../../utils/helpers.js";
import { ApiError } from "../../utils/ApiError.js";
import { ApiResponse } from "../../utils/ApiResponse.js";
import { asyncHandler } from "../../utils/asyncHandler.js";

// use fs.readFileSync to load JSON synchronously in ES module context.
const nseStocksJson = JSON.parse(
fs.readFileSync(
new URL("../../json/nse-stocks.json", import.meta.url),
"utf-8"
)
);

const getStocks = asyncHandler(async (req, res) => {
const page = +(req.query.page || 1);
const limit = +(req.query.limit || 10);
Expand Down
42 changes: 37 additions & 5 deletions src/controllers/public/youtube.controllers.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,46 @@
import fs from "fs";
import { YouTubeFilterEnum, AvailableYouTubeFilters } from "../../constants.js";
import channelJson from "../../json/youtube/channel.json" assert { type: "json" };
import commentsJson from "../../json/youtube/comments.json" assert { type: "json" };
import playlistItemsJson from "../../json/youtube/playlistitems.json" assert { type: "json" };
import playlistsJson from "../../json/youtube/playlists.json" assert { type: "json" };
import videosJson from "../../json/youtube/videos.json" assert { type: "json" };
import { ApiError } from "../../utils/ApiError.js";
import { ApiResponse } from "../../utils/ApiResponse.js";
import { asyncHandler } from "../../utils/asyncHandler.js";
import { filterObjectKeys, getPaginatedPayload } from "../../utils/helpers.js";

// use fs.readFileSync to load JSON synchronously in ES module context.
const channelJson = JSON.parse(
fs.readFileSync(
new URL("../../json/youtube/channel.json", import.meta.url),
"utf-8"
)
);

const commentsJson = JSON.parse(
fs.readFileSync(
new URL("../../json/youtube/comments.json", import.meta.url),
"utf-8"
)
);

const playlistItemsJson = JSON.parse(
fs.readFileSync(
new URL("../../json/youtube/playlistitems.json", import.meta.url),
"utf-8"
)
);

const playlistsJson = JSON.parse(
fs.readFileSync(
new URL("../../json/youtube/playlists.json", import.meta.url),
"utf-8"
)
);

const videosJson = JSON.parse(
fs.readFileSync(
new URL("../../json/youtube/videos.json", import.meta.url),
"utf-8"
)
);

const getChannelDetails = asyncHandler(async (req, res) => {
const channelDetails = channelJson.channel;
return res
Expand Down
Loading