Skip to content

Commit

Permalink
Update deps and format
Browse files Browse the repository at this point in the history
  • Loading branch information
The-Best-Codes committed Dec 12, 2024
1 parent 550008e commit d8d3c07
Show file tree
Hide file tree
Showing 17 changed files with 91 additions and 120 deletions.
36 changes: 18 additions & 18 deletions app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,31 @@
@tailwind utilities;

:root {
--foreground-rgb: 0, 0, 0;
--background-start-rgb: 214, 219, 220;
--background-end-rgb: 255, 255, 255;
--foreground-rgb: 0, 0, 0;
--background-start-rgb: 214, 219, 220;
--background-end-rgb: 255, 255, 255;
}

@media (prefers-color-scheme: dark) {
:root {
--foreground-rgb: 255, 255, 255;
--background-start-rgb: 0, 0, 0;
--background-end-rgb: 0, 0, 0;
}
:root {
--foreground-rgb: 255, 255, 255;
--background-start-rgb: 0, 0, 0;
--background-end-rgb: 0, 0, 0;
}
}

body {
color: rgb(var(--foreground-rgb));
background: linear-gradient(
to bottom,
transparent,
rgb(var(--background-end-rgb))
)
rgb(var(--background-start-rgb));
color: rgb(var(--foreground-rgb));
background: linear-gradient(
to bottom,
transparent,
rgb(var(--background-end-rgb))
)
rgb(var(--background-start-rgb));
}

@layer utilities {
.text-balance {
text-wrap: balance;
}
.text-balance {
text-wrap: balance;
}
}
1 change: 0 additions & 1 deletion app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from "react";
import Link from "next/link";

export default function Home() {
Expand Down
Binary file modified bun.lockb
Binary file not shown.
11 changes: 0 additions & 11 deletions jsdoc.json

This file was deleted.

20 changes: 10 additions & 10 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
typescript: {
ignoreBuildErrors: true
typescript: {
ignoreBuildErrors: true,
},
eslint: {
ignoreDuringBuilds: true,
},
experimental: {
turbo: {
treeShaking: true,
},
eslint: {
ignoreDuringBuilds: true
},
experimental: {
turbo: {
treeShaking: true
}
}
},
};

export default nextConfig;
13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
{
"name": "bestcodes_wordworks_api",
"version": "0.2.1",
"version": "1.0.2",
"packageManager": "[email protected]",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"generate-docs": "jsdoc -c jsdoc.json"
"lint": "next lint"
},
"dependencies": {
"fs": "^0.0.1-security",
"huggingface": "^1.4.0",
"natural": "^8.0.1",
"next": "^15.0.4",
"next": "^15.1.0",
"node-fetch": "^3.3.2",
"react": "^19.0.0",
"react-dom": "^19.0.0",
Expand All @@ -27,11 +26,11 @@
"wink-pos-tagger": "^2.2.2"
},
"devDependencies": {
"@types/node": "^22.10.1",
"@types/node": "^22.10.2",
"@types/react": "^19.0.1",
"@types/react-dom": "^19.0.1",
"@types/react-dom": "^19.0.2",
"eslint": "^9.16.0",
"eslint-config-next": "15.0.4",
"eslint-config-next": "15.1.0",
"jsdoc": "^4.0.4",
"postcss": "^8.4.49",
"tailwindcss": "^3.4.16",
Expand Down
5 changes: 1 addition & 4 deletions pages/api/nlp/emotion.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// pages/api/nlp/emotion.js

import fetch from "node-fetch";


export default async function handler(req, res) {
try {
const { text } = req.query;
Expand All @@ -15,7 +12,7 @@ export default async function handler(req, res) {
},
method: "POST",
body: JSON.stringify({ inputs: text }),
}
},
);

if (!response.ok) {
Expand Down
3 changes: 0 additions & 3 deletions pages/api/nlp/parts-of-speech.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// pages/api/nlp/parts-of-speech.js

import posTagger from "wink-pos-tagger";
var tagger = posTagger();


export default async function handler(req, res) {
// Set CORS headers
res.setHeader("Access-Control-Allow-Origin", "*");
Expand Down
3 changes: 0 additions & 3 deletions pages/api/nlp/sentiment.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
// pages/api/nlp/sentiment.js

import natural from "natural";
const SentimentAnalyzer = natural.SentimentAnalyzer;
const stemmer = natural.PorterStemmer;
const analyzer = new SentimentAnalyzer("English", stemmer, "afinn");


export default async function handler(req, res) {
// Set CORS headers
res.setHeader("Access-Control-Allow-Origin", "*");
Expand Down
3 changes: 0 additions & 3 deletions pages/api/nlp/tokenize.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// pages/api/nlp/tokenize.js

import natural from "natural";
const tokenizer = new natural.WordTokenizer();


export default async function handler(req, res) {
// Set CORS headers
res.setHeader("Access-Control-Allow-Origin", "*");
Expand Down
103 changes: 55 additions & 48 deletions pages/api/sentence/random.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,68 +2,75 @@ import fetch from "node-fetch";

// Helper function to fetch words from a URL and return a random word
async function fetchRandomWord(url, key, wordType) {
const response = await fetch(url);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json(); // Assuming the response is JSON formatted
let words = data[key];
const response = await fetch(url);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json(); // Assuming the response is JSON formatted
let words = data[key];

//console.log(`Fetched ${words.length} ${wordType} words from ${url}`);
//console.log(`Fetched ${words.length} ${wordType} words from ${url}`);

// Special handling for verbs due to their structure
if (wordType === 'verb' || wordType === 'verbPresent') {
const randomVerbObject = words[Math.floor(Math.random() * words.length)];
// Assuming you want to randomly choose between 'past' and 'present'
const tense = ['past', 'present'][Math.floor(Math.random() * 2)];
return randomVerbObject[tense];
}
// Special handling for verbs due to their structure
if (wordType === "verb" || wordType === "verbPresent") {
const randomVerbObject = words[Math.floor(Math.random() * words.length)];
// Assuming you want to randomly choose between 'past' and 'present'
const tense = ["past", "present"][Math.floor(Math.random() * 2)];
return randomVerbObject[tense];
}

return words[Math.floor(Math.random() * words.length)];
return words[Math.floor(Math.random() * words.length)];
}

// Function to get the word types and their corresponding URLs
function getWordTypeUrl(wordType) {
const urls = {
noun: 'https://github.com/dariusk/corpora/raw/master/data/words/nouns.json',
verb: 'https://github.com/dariusk/corpora/raw/master/data/words/verbs.json',
verbPresent: 'https://github.com/dariusk/corpora/raw/master/data/words/verbs.json',
adj: 'https://github.com/dariusk/corpora/raw/master/data/words/adjs.json',
adverb: 'https://github.com/dariusk/corpora/raw/master/data/words/adverbs.json'
};
return { url: urls[wordType], key: wordType === 'verbPresent' ? 'verbs' : wordType + 's' };
const urls = {
noun: "https://github.com/dariusk/corpora/raw/master/data/words/nouns.json",
verb: "https://github.com/dariusk/corpora/raw/master/data/words/verbs.json",
verbPresent:
"https://github.com/dariusk/corpora/raw/master/data/words/verbs.json",
adj: "https://github.com/dariusk/corpora/raw/master/data/words/adjs.json",
adverb:
"https://github.com/dariusk/corpora/raw/master/data/words/adverbs.json",
};
return {
url: urls[wordType],
key: wordType === "verbPresent" ? "verbs" : wordType + "s",
};
}

export default async function handler(req, res) {
res.setHeader("Access-Control-Allow-Origin", "*");
res.setHeader("Access-Control-Allow-Methods", "GET, OPTIONS");
res.setHeader("Access-Control-Allow-Headers", "Content-Type");
res.setHeader("Access-Control-Allow-Origin", "*");
res.setHeader("Access-Control-Allow-Methods", "GET, OPTIONS");
res.setHeader("Access-Control-Allow-Headers", "Content-Type");

if (req.method === "OPTIONS") {
res.status(200).end();
return;
}
if (req.method === "OPTIONS") {
res.status(200).end();
return;
}

res.setHeader("Content-Type", "application/json");
res.setHeader("Content-Type", "application/json");

try {
const queryParams = req.query;
const wordsParam = queryParams.words ? JSON.parse(queryParams.words) : ["verb", "adj", "noun"];
const separator = queryParams.separator || '-';
try {
const queryParams = req.query;
const wordsParam = queryParams.words
? JSON.parse(queryParams.words)
: ["verb", "adj", "noun"];
const separator = queryParams.separator || "-";

//console.log(wordsParam, separator);
//console.log(JSON.stringify(wordsParam) + " <-- wordsParam");
//console.log(wordsParam, separator);
//console.log(JSON.stringify(wordsParam) + " <-- wordsParam");

const wordsPromises = wordsParam.map(wordType => {
const { url, key } = getWordTypeUrl(wordType);
return fetchRandomWord(url, key, wordType);
});
const wordsPromises = wordsParam.map((wordType) => {
const { url, key } = getWordTypeUrl(wordType);
return fetchRandomWord(url, key, wordType);
});

const words = await Promise.all(wordsPromises);
const sentence = words.join(separator);
const words = await Promise.all(wordsPromises);
const sentence = words.join(separator);

res.status(200).json({ data: sentence });
} catch (error) {
res.status(500).json({ error: error.message });
}
}
res.status(200).json({ data: sentence });
} catch (error) {
res.status(500).json({ error: error.message });
}
}
3 changes: 0 additions & 3 deletions pages/api/words/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// pages/api/words/index.js

import wordArray from "./wordList.json";


export default async function handler(req, res) {
// Set CORS headers
res.setHeader("Access-Control-Allow-Origin", "*");
Expand Down
3 changes: 0 additions & 3 deletions pages/api/words/random.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// pages/api/words/random.js

import wordArray from "./wordList.json";


export default async function handler(req, res) {
// Set CORS headers
res.setHeader("Access-Control-Allow-Origin", "*");
Expand Down
3 changes: 0 additions & 3 deletions pages/api/words/search.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// pages/api/words/search.js

import wordArray from "./wordList.json";


export default async function handler(req, res) {
// Set CORS headers
res.setHeader("Access-Control-Allow-Origin", "*");
Expand Down
2 changes: 1 addition & 1 deletion pages/api/words/wordList.json
Original file line number Diff line number Diff line change
Expand Up @@ -178216,4 +178216,4 @@
"ZYZZYVAS",
"ZZZ",
""
]
]
1 change: 0 additions & 1 deletion public/next.svg

This file was deleted.

1 change: 0 additions & 1 deletion public/vercel.svg

This file was deleted.

0 comments on commit d8d3c07

Please sign in to comment.