diff --git a/docs/DATAFLOW.md b/docs/DATAFLOW.md new file mode 100644 index 0000000..4732a1f --- /dev/null +++ b/docs/DATAFLOW.md @@ -0,0 +1,41 @@ +# Routes Scratchpad + +```mermaid + graph TD + + input + output + + subgraph jason + inSEvent + inSGenre + inDDate + appApp + appOut + end + + subgraph tanya + toOpenAI + fromOpenAI + end + + openai + + subgraph gaj + toSpotify + fromSpotify + end + + spotify + + input --> inSEvent & inSGenre & inDDate + inSEvent & inSGenre --> toOpenAI + toOpenAI --> openai + openai --> fromOpenAI + inDDate & fromOpenAI --> appApp + appApp --> toSpotify + toSpotify --> spotify + spotify --> fromSpotify + fromSpotify --> appOut + appOut --> output +``` diff --git a/docs/folders b/docs/folders new file mode 100644 index 0000000..d489594 --- /dev/null +++ b/docs/folders @@ -0,0 +1,34 @@ +src +├── app.ts +├── controllers +│ ├── openAI +│ │ └── extractEmotion.ts +│ ├── spotify +│ │ └── searchGenre.ts +│ └── user +│ ├── getInput.ts +│ └── showOutput.ts +├── data +│ ├── demo +│ │ └── album.json +│ └── schema +│ └── categories.json +├── models +│ ├── openai +│ └── spotify +│ └── searchGenre.ts +├── routes +│ ├── internal +│ │ └── user.ts +│ ├── openAI +│ │ └── index.ts +│ ├── routes.ts +│ └── spotify +│ └── index.ts +├── swagger.ts +└── types + ├── openaiQuery.ts + ├── openaiResponse.ts + ├── spotifyQuery.ts + ├── spotifyResponse.ts + └── userInput.ts diff --git a/nodemon.json b/nodemon.json index 502d93b..4cc6d6a 100644 --- a/nodemon.json +++ b/nodemon.json @@ -1,5 +1,5 @@ { "watch": ["src"], "ext": "ts", - "exec": "ts-node --esm -r tsconfig-paths/register ./src/app.ts" + "exec": "tsx src/app.ts" } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 3df8162..f973583 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,11 +12,12 @@ "@spotify/web-api-ts-sdk": "^1.2.0", "dotenv": "^16.4.5", "express": "^4.21.0", + "itty-router": "^5.0.18", "openai": "^4.63.0", "spotify-web-api-node": "^5.0.2", + "prompt-sync": "^4.2.0", "swagger-jsdoc": "^6.2.8", - "swagger-ui-express": "^5.0.1", - "tsx": "^4.19.1" + "swagger-ui-express": "^5.0.1" }, "devDependencies": { "@definitelytyped/dtslint": "^0.2.23", @@ -24,7 +25,8 @@ "@tsconfig/node20": "^20.1.4", "@types/dotenv": "^6.1.1", "@types/express": "^4.17.21", - "@types/node": "^22.5.5", + "@types/node": "^22.7.4", + "@types/prompt-sync": "^4.2.3", "@types/spotify-web-api-node": "^5.0.11", "@types/swagger-jsdoc": "^6.0.4", "@types/swagger-ui-express": "^4.1.6", @@ -34,6 +36,7 @@ "prettier": "^3.3.3", "ts-node": "^10.9.2", "tsconfig-paths": "^4.2.0", + "tsx": "^4.19.1", "typescript": "^5.6.2", "typescript-eslint": "^8.6.0" } @@ -836,6 +839,7 @@ "cpu": [ "ppc64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -852,6 +856,7 @@ "cpu": [ "arm" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -868,6 +873,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -884,6 +890,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -900,6 +907,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -916,6 +924,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -932,6 +941,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -948,6 +958,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -964,6 +975,7 @@ "cpu": [ "arm" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -980,6 +992,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -996,6 +1009,7 @@ "cpu": [ "ia32" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1012,6 +1026,7 @@ "cpu": [ "loong64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1028,6 +1043,7 @@ "cpu": [ "mips64el" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1044,6 +1060,7 @@ "cpu": [ "ppc64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1060,6 +1077,7 @@ "cpu": [ "riscv64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1076,6 +1094,7 @@ "cpu": [ "s390x" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1092,6 +1111,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1108,6 +1128,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1124,6 +1145,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1140,6 +1162,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1156,6 +1179,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1172,6 +1196,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1188,6 +1213,7 @@ "cpu": [ "ia32" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1204,6 +1230,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1507,7 +1534,8 @@ "node_modules/@spotify/web-api-ts-sdk": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@spotify/web-api-ts-sdk/-/web-api-ts-sdk-1.2.0.tgz", - "integrity": "sha512-JUaebva3Ohwo5I5tuTqyW/FKGOMbb40YevJMySAOINRxP7qQ/AMjBzfJx0zeO6yS+wAPfQSoGNsZaUggHw8vsA==" + "integrity": "sha512-JUaebva3Ohwo5I5tuTqyW/FKGOMbb40YevJMySAOINRxP7qQ/AMjBzfJx0zeO6yS+wAPfQSoGNsZaUggHw8vsA==", + "license": "Apache" }, "node_modules/@tsconfig/node10": { "version": "1.0.11", @@ -1629,9 +1657,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "22.5.5", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.5.tgz", - "integrity": "sha512-Xjs4y5UPO/CLdzpgR6GirZJx36yScjh73+2NlLlkFRSoQN8B0DpfXPdZGnvVmLRLOsqDpOfTNv7D9trgGhmOIA==", + "version": "22.7.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.4.tgz", + "integrity": "sha512-y+NPi1rFzDs1NdQHHToqeiX2TIS79SWEAw9GYhkkx8bD0ChpfqC+n2j5OXOCpzfojBEBt6DnEnnG9MY0zk1XLg==", "license": "MIT", "dependencies": { "undici-types": "~6.19.2" @@ -1661,6 +1689,13 @@ "node": ">= 6" } }, + "node_modules/@types/prompt-sync": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/@types/prompt-sync/-/prompt-sync-4.2.3.tgz", + "integrity": "sha512-Ox77gCSx0YyeakGt/qfOZUSFNSSi+sh3ABoGOiCwiO2KODx492BJnUm9oIXS+AHJtqp12iM4RduY6viTJ9bYwA==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/qs": { "version": "6.9.16", "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.16.tgz", @@ -3241,6 +3276,7 @@ "version": "0.23.1", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.23.1.tgz", "integrity": "sha512-VVNz/9Sa0bs5SELtn3f7qhJCDPCF5oMEl5cO9/SSinpE9hbPVvxbd572HH5AKiP7WD8INO53GgfDDhRjkylHEg==", + "dev": true, "hasInstallScript": true, "license": "MIT", "bin": { @@ -3887,6 +3923,7 @@ "version": "2.3.3", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, "hasInstallScript": true, "license": "MIT", "optional": true, @@ -4050,6 +4087,7 @@ "version": "4.8.1", "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.8.1.tgz", "integrity": "sha512-k9PN+cFBmaLWtVz29SkUoqU5O0slLuHJXt/2P+tMVFT+phsSGXGkp9t3rQIqdz0e+06EHNGs3oM6ZX1s2zHxRg==", + "dev": true, "license": "MIT", "dependencies": { "resolve-pkg-maps": "^1.0.0" @@ -4773,6 +4811,12 @@ "dev": true, "license": "MIT" }, + "node_modules/itty-router": { + "version": "5.0.18", + "resolved": "https://registry.npmjs.org/itty-router/-/itty-router-5.0.18.tgz", + "integrity": "sha512-mK3ReOt4ARAGy0V0J7uHmArG2USN2x0zprZ+u+YgmeRjXTDbaowDy3kPcsmQY6tH+uHhDgpWit9Vqmv/4rTXwA==", + "license": "MIT" + }, "node_modules/js-yaml": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", @@ -5711,6 +5755,36 @@ "license": "MIT", "optional": true }, + "node_modules/prompt-sync": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/prompt-sync/-/prompt-sync-4.2.0.tgz", + "integrity": "sha512-BuEzzc5zptP5LsgV5MZETjDaKSWfchl5U9Luiu8SKp7iZWD5tZalOxvNcZRwv+d2phNFr8xlbxmFNcRKfJOzJw==", + "license": "MIT", + "dependencies": { + "strip-ansi": "^5.0.0" + } + }, + "node_modules/prompt-sync/node_modules/ansi-regex": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz", + "integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/prompt-sync/node_modules/strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "license": "MIT", + "dependencies": { + "ansi-regex": "^4.1.0" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/proxy-addr": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", @@ -5946,6 +6020,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", + "dev": true, "license": "MIT", "funding": { "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" @@ -6880,6 +6955,7 @@ "version": "4.19.1", "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.19.1.tgz", "integrity": "sha512-0flMz1lh74BR4wOvBjuh9olbnwqCPc35OOlfyzHba0Dc+QNUeWX/Gq2YTbnwcWPO3BMd8fkzRVrHcsR+a7z7rA==", + "dev": true, "license": "MIT", "dependencies": { "esbuild": "~0.23.0", diff --git a/package.json b/package.json index b7982f2..d2ee46b 100644 --- a/package.json +++ b/package.json @@ -5,11 +5,10 @@ "description": "A thing that will, at some point, do a thing.", "main": "index.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", "dtslint": "dtslint types", "compile": "npx tsc", "server": "node dist/app.js", - "dev": "nodemon" + "dev": "nodemon --exec tsx src/app.ts" }, "keywords": [], "author": "", @@ -20,7 +19,8 @@ "@tsconfig/node20": "^20.1.4", "@types/dotenv": "^6.1.1", "@types/express": "^4.17.21", - "@types/node": "^22.5.5", + "@types/node": "^22.7.4", + "@types/prompt-sync": "^4.2.3", "@types/spotify-web-api-node": "^5.0.11", "@types/swagger-jsdoc": "^6.0.4", "@types/swagger-ui-express": "^4.1.6", @@ -30,6 +30,7 @@ "prettier": "^3.3.3", "ts-node": "^10.9.2", "tsconfig-paths": "^4.2.0", + "tsx": "^4.19.1", "typescript": "^5.6.2", "typescript-eslint": "^8.6.0" }, @@ -37,10 +38,11 @@ "@spotify/web-api-ts-sdk": "^1.2.0", "dotenv": "^16.4.5", "express": "^4.21.0", + "itty-router": "^5.0.18", "openai": "^4.63.0", "spotify-web-api-node": "^5.0.2", + "prompt-sync": "^4.2.0", "swagger-jsdoc": "^6.2.8", - "swagger-ui-express": "^5.0.1", - "tsx": "^4.19.1" + "swagger-ui-express": "^5.0.1" } } diff --git a/src/app.ts b/src/app.ts index 278164c..3fa6845 100644 --- a/src/app.ts +++ b/src/app.ts @@ -1,32 +1,40 @@ -import express, { Express, Request, Response } from 'express'; +//h1 SETUP import * as dotenv from 'dotenv'; +import express, { Request, Response, Router } from 'express'; import swaggerDocs from './swagger.js'; +import { router as hub } from "./routes/routes.js"; +//h2 CONFIG dotenv.config(); - const keys = { port: process.env.PORT }; -const app: Express = express(); - -// Initialize Swagger +const app = express(); +const router = Router(); swaggerDocs(app); -//h1 Routers -console.log(`Now in ./app`); - -app.get('/openai', (req: Request, res: Response) => { - res.send({ message: "Server --> OpenAI" }); +//h1 ACTIVE +app.listen(keys.port, () => { + console.log(`Server Listening on Port ${keys.port}`) }); -app.get('/spotify', (req: Request, res: Response) => { - res.send({ message: "Server --> Spotify" }); -}); +//h2 Routers +app.use('/api', hub); -//h2 Fallback +//h2 Endpoints app.get('/', (req: Request, res: Response) => { - res.send({ message: "Server --> Server" }); + res.send(` +