diff --git a/app/globals.css b/app/globals.css index 875c01e..34c47ab 100644 --- a/app/globals.css +++ b/app/globals.css @@ -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; + } } diff --git a/app/page.tsx b/app/page.tsx index f5d8806..9fb065e 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,4 +1,3 @@ -import React from "react"; import Link from "next/link"; export default function Home() { diff --git a/bun.lockb b/bun.lockb index 93b7a6d..984398d 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/jsdoc.json b/jsdoc.json deleted file mode 100644 index 887a4b4..0000000 --- a/jsdoc.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "opts": { - "destination": "./docs", - "recurse": true - }, - "source": { - "include": ["pages/api"], - "includePattern": ".+\\.js(doc|x)?$", - "excludePattern": "(^|\\/|\\\\)_" - } -} diff --git a/next.config.mjs b/next.config.mjs index 03eb4b0..f4961ef 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -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; diff --git a/package.json b/package.json index 8b0f47e..2cefddf 100644 --- a/package.json +++ b/package.json @@ -1,20 +1,19 @@ { "name": "bestcodes_wordworks_api", - "version": "0.2.1", + "version": "1.0.2", "packageManager": "bun@1.1.38", "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", @@ -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", diff --git a/pages/api/nlp/emotion.js b/pages/api/nlp/emotion.js index 6992a45..ff21134 100644 --- a/pages/api/nlp/emotion.js +++ b/pages/api/nlp/emotion.js @@ -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; @@ -15,7 +12,7 @@ export default async function handler(req, res) { }, method: "POST", body: JSON.stringify({ inputs: text }), - } + }, ); if (!response.ok) { diff --git a/pages/api/nlp/parts-of-speech.js b/pages/api/nlp/parts-of-speech.js index 678013b..827ae80 100644 --- a/pages/api/nlp/parts-of-speech.js +++ b/pages/api/nlp/parts-of-speech.js @@ -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", "*"); diff --git a/pages/api/nlp/sentiment.js b/pages/api/nlp/sentiment.js index 0fbf66c..ea1bb94 100644 --- a/pages/api/nlp/sentiment.js +++ b/pages/api/nlp/sentiment.js @@ -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", "*"); diff --git a/pages/api/nlp/tokenize.js b/pages/api/nlp/tokenize.js index e9c33d5..d7c056b 100644 --- a/pages/api/nlp/tokenize.js +++ b/pages/api/nlp/tokenize.js @@ -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", "*"); diff --git a/pages/api/sentence/random.js b/pages/api/sentence/random.js index 645ef49..02f43d0 100644 --- a/pages/api/sentence/random.js +++ b/pages/api/sentence/random.js @@ -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 }); - } -} \ No newline at end of file + res.status(200).json({ data: sentence }); + } catch (error) { + res.status(500).json({ error: error.message }); + } +} diff --git a/pages/api/words/index.js b/pages/api/words/index.js index 390edef..af0023f 100644 --- a/pages/api/words/index.js +++ b/pages/api/words/index.js @@ -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", "*"); diff --git a/pages/api/words/random.js b/pages/api/words/random.js index ecfae56..9ce34a1 100644 --- a/pages/api/words/random.js +++ b/pages/api/words/random.js @@ -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", "*"); diff --git a/pages/api/words/search.js b/pages/api/words/search.js index 0e43f26..d27cf99 100644 --- a/pages/api/words/search.js +++ b/pages/api/words/search.js @@ -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", "*"); diff --git a/pages/api/words/wordList.json b/pages/api/words/wordList.json index b9d7759..1c019e3 100644 --- a/pages/api/words/wordList.json +++ b/pages/api/words/wordList.json @@ -178216,4 +178216,4 @@ "ZYZZYVAS", "ZZZ", "" -] \ No newline at end of file +] diff --git a/public/next.svg b/public/next.svg deleted file mode 100644 index 5174b28..0000000 --- a/public/next.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/vercel.svg b/public/vercel.svg deleted file mode 100644 index d2f8422..0000000 --- a/public/vercel.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file