From 3be5ebc9f4161bfa9d8d4ba34eb2dc7b4e00a9e9 Mon Sep 17 00:00:00 2001 From: Dhyey Thumar Date: Mon, 17 Jan 2022 13:20:36 +0530 Subject: [PATCH] updated complete project file structure --- app.arc | 7 +- package-lock.json | 30 +++------ package.json | 15 ++--- src/{graphql => http/any-catchall}/index.js | 33 +--------- .../any-catchall}/package-lock.json | 65 ++++++++++--------- .../any-catchall}/package.json | 4 +- src/{ => http/any-catchall}/schema.graphql | 0 src/{ => shared}/lib/AlbumModule.js | 2 +- src/{ => shared}/lib/CommentModule.js | 2 +- src/{ => shared}/lib/PhotoModule.js | 2 +- src/{ => shared}/lib/PostModule.js | 2 +- src/{ => shared}/lib/TodoModule.js | 2 +- src/{ => shared}/lib/UserModule.js | 2 +- src/shared/package-lock.json | 54 +++++++++++++++ src/shared/package.json | 6 ++ src/{ => shared}/resolvers/Album.js | 2 +- src/{ => shared}/resolvers/Comment.js | 0 src/{ => shared}/resolvers/Mutation.js | 0 src/{ => shared}/resolvers/Photo.js | 0 src/{ => shared}/resolvers/Post.js | 2 +- src/{ => shared}/resolvers/Query.js | 2 +- src/{ => shared}/resolvers/Todo.js | 0 src/{ => shared}/resolvers/User.js | 2 +- src/{ => shared}/resolvers/index.js | 0 src/{utils/common.js => shared/utils.js} | 7 ++ src/utils/base-axios.js | 6 -- tests/graphqlServer.test.js | 2 +- 27 files changed, 135 insertions(+), 114 deletions(-) rename src/{graphql => http/any-catchall}/index.js (63%) rename src/{graphql => http/any-catchall}/package-lock.json (99%) rename src/{graphql => http/any-catchall}/package.json (65%) rename src/{ => http/any-catchall}/schema.graphql (100%) rename src/{ => shared}/lib/AlbumModule.js (97%) rename src/{ => shared}/lib/CommentModule.js (97%) rename src/{ => shared}/lib/PhotoModule.js (97%) rename src/{ => shared}/lib/PostModule.js (97%) rename src/{ => shared}/lib/TodoModule.js (97%) rename src/{ => shared}/lib/UserModule.js (98%) create mode 100644 src/shared/package-lock.json create mode 100644 src/shared/package.json rename src/{ => shared}/resolvers/Album.js (86%) rename src/{ => shared}/resolvers/Comment.js (100%) rename src/{ => shared}/resolvers/Mutation.js (100%) rename src/{ => shared}/resolvers/Photo.js (100%) rename src/{ => shared}/resolvers/Post.js (86%) rename src/{ => shared}/resolvers/Query.js (98%) rename src/{ => shared}/resolvers/Todo.js (100%) rename src/{ => shared}/resolvers/User.js (95%) rename src/{ => shared}/resolvers/index.js (100%) rename src/{utils/common.js => shared/utils.js} (52%) delete mode 100644 src/utils/base-axios.js diff --git a/app.arc b/app.arc index 53b0c47..5b0de2c 100644 --- a/app.arc +++ b/app.arc @@ -4,7 +4,8 @@ graphql-proxy-api @aws runtime nodejs14.x +@shared +src src/shared + @http -/* - method any - src /src/graphql \ No newline at end of file +any /* \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 36b74e9..923199b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,21 +1,21 @@ { "name": "graphql-proxy-api", - "version": "1.0.0", + "version": "1.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "graphql-proxy-api", - "version": "1.0.0", + "version": "1.1.0", "license": "MIT", - "dependencies": { - "axios": "^0.21.4" - }, "devDependencies": { "@architect/sandbox": "^4.5.2", "tap-spec": "^5.0.0", "tape": "^5.4.1", "tiny-json-http": "^7.3.1" + }, + "engines": { + "node": ">=14" } }, "node_modules/@architect/asap": { @@ -342,14 +342,6 @@ "node": ">= 0.8.0" } }, - "node_modules/axios": { - "version": "0.21.4", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz", - "integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==", - "dependencies": { - "follow-redirects": "^1.14.0" - } - }, "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -1104,6 +1096,7 @@ "version": "1.14.7", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.7.tgz", "integrity": "sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ==", + "dev": true, "funding": [ { "type": "individual", @@ -3909,14 +3902,6 @@ "xml2js": "0.4.19" } }, - "axios": { - "version": "0.21.4", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz", - "integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==", - "requires": { - "follow-redirects": "^1.14.0" - } - }, "balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -4515,7 +4500,8 @@ "follow-redirects": { "version": "1.14.7", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.7.tgz", - "integrity": "sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ==" + "integrity": "sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ==", + "dev": true }, "for-each": { "version": "0.3.3", diff --git a/package.json b/package.json index 9b9155f..0aba6b8 100644 --- a/package.json +++ b/package.json @@ -1,16 +1,18 @@ { "name": "graphql-proxy-api", - "version": "1.0.0", + "version": "1.1.0", "description": "GraphQL Proxy API for testing and prototyping.", "author": "Dhyey Thumar", "email": "dhyeythumar@gmail.com", "license": "MIT", - "main": "api/graphql.js", + "main": "src/http/any-catchall/index.js", "type": "module", + "engines": { + "node": ">=14" + }, "scripts": { "start": "npx sandbox", - "test": "echo 'Test not working on Begin.com'", - "test:dev": "tape tests/*.test.js | tap-spec" + "test": "tape tests/*.test.js | tap-spec" }, "repository": { "type": "git", @@ -26,13 +28,10 @@ "url": "https://github.com/dhyeythumar/graphql-proxy-api/issues" }, "homepage": "https://github.com/dhyeythumar/graphql-proxy-api#readme", - "dependencies": { - "axios": "^0.21.4" - }, "devDependencies": { "@architect/sandbox": "^4.5.2", "tap-spec": "^5.0.0", "tape": "^5.4.1", "tiny-json-http": "^7.3.1" } -} \ No newline at end of file +} diff --git a/src/graphql/index.js b/src/http/any-catchall/index.js similarity index 63% rename from src/graphql/index.js rename to src/http/any-catchall/index.js index 3d270a9..4f0c4cd 100644 --- a/src/graphql/index.js +++ b/src/http/any-catchall/index.js @@ -1,45 +1,18 @@ import arc from "@architect/functions"; -import { promisify } from "util"; -import path, { resolve } from "path"; +import path from "path"; import fs from "fs"; import { ApolloServer } from "apollo-server-lambda"; import { ApolloServerPluginLandingPageProductionDefault, ApolloServerPluginLandingPageLocalDefault, } from "apollo-server-core"; +import resolvers from "@architect/shared/resolvers/index.js"; const __dirname = path.resolve(); -const readdir = promisify(fs.readdir); -async function* getFiles(dir) { - const dirents = await readdir(dir, { withFileTypes: true }); - for (const dirent of dirents) { - const res = resolve(dir, dirent.name); - if (dirent.isDirectory()) { - yield* getFiles(res); - } else { - yield res; - } - } -} - -(async () => { - try { - for await (const f of getFiles("../../var")) { - console.log(f); - } - } catch (err) { - console.error(err); - } -})(); - -console.info("__dirname", __dirname); - -import resolvers from "../resolvers/index.js"; - const ServerHandler = new ApolloServer({ typeDefs: fs.readFileSync( - path.join(__dirname, "../", "schema.graphql"), + path.join(__dirname, "./", "schema.graphql"), "utf8" ), resolvers, diff --git a/src/graphql/package-lock.json b/src/http/any-catchall/package-lock.json similarity index 99% rename from src/graphql/package-lock.json rename to src/http/any-catchall/package-lock.json index fa9f764..addeb4a 100644 --- a/src/graphql/package-lock.json +++ b/src/http/any-catchall/package-lock.json @@ -1,16 +1,19 @@ { - "name": "graphql", + "name": "any-catchall", "lockfileVersion": 2, "requires": true, "packages": { "": { "dependencies": { - "@architect/functions": "latest", + "@architect/functions": "^4.1.1", "apollo-server-core": "^3.3.0", "apollo-server-lambda": "^3.6.1", "graphql": "^15.5.3" } }, + "../../shared": { + "extraneous": true + }, "node_modules/@apollo/protobufjs": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/@apollo/protobufjs/-/protobufjs-1.2.2.tgz", @@ -221,11 +224,15 @@ } }, "node_modules/@vendia/serverless-express": { - "version": "4.5.2", - "resolved": "https://registry.npmjs.org/@vendia/serverless-express/-/serverless-express-4.5.2.tgz", - "integrity": "sha512-mekBOPnBxfhIvBYKVwfvjp9NtS+bOs3F08Vudxa3Fb7zkxtdjRn0UMLRT6zwWf6i4V5rjk2aEhzbIDSCV1GQ0w==", + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/@vendia/serverless-express/-/serverless-express-3.4.0.tgz", + "integrity": "sha512-/UAAbi9qRjUtjRISt5MJ1sfhtrHb26hqQ0nvE5qhMLsAdR5H7ErBwPD8Q/v2OENKm0iWsGwErIZEg7ebUeFDjQ==", + "dependencies": { + "binary-case": "^1.0.0", + "type-is": "^1.6.16" + }, "engines": { - "node": ">=12" + "node": ">=6" } }, "node_modules/accepts": { @@ -440,6 +447,14 @@ "graphql": "^15.3.0 || ^16.0.0" } }, + "node_modules/apollo-server-lambda/node_modules/@vendia/serverless-express": { + "version": "4.5.2", + "resolved": "https://registry.npmjs.org/@vendia/serverless-express/-/serverless-express-4.5.2.tgz", + "integrity": "sha512-mekBOPnBxfhIvBYKVwfvjp9NtS+bOs3F08Vudxa3Fb7zkxtdjRn0UMLRT6zwWf6i4V5rjk2aEhzbIDSCV1GQ0w==", + "engines": { + "node": ">=12" + } + }, "node_modules/apollo-server-lambda/node_modules/apollo-server-express": { "version": "3.6.1", "resolved": "https://registry.npmjs.org/apollo-server-express/-/apollo-server-express-3.6.1.tgz", @@ -507,18 +522,6 @@ "node": ">=6" } }, - "node_modules/aws-serverless-express/node_modules/@vendia/serverless-express": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/@vendia/serverless-express/-/serverless-express-3.4.0.tgz", - "integrity": "sha512-/UAAbi9qRjUtjRISt5MJ1sfhtrHb26hqQ0nvE5qhMLsAdR5H7ErBwPD8Q/v2OENKm0iWsGwErIZEg7ebUeFDjQ==", - "dependencies": { - "binary-case": "^1.0.0", - "type-is": "^1.6.16" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/binary-case": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/binary-case/-/binary-case-1.1.4.tgz", @@ -1495,9 +1498,13 @@ } }, "@vendia/serverless-express": { - "version": "4.5.2", - "resolved": "https://registry.npmjs.org/@vendia/serverless-express/-/serverless-express-4.5.2.tgz", - "integrity": "sha512-mekBOPnBxfhIvBYKVwfvjp9NtS+bOs3F08Vudxa3Fb7zkxtdjRn0UMLRT6zwWf6i4V5rjk2aEhzbIDSCV1GQ0w==" + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/@vendia/serverless-express/-/serverless-express-3.4.0.tgz", + "integrity": "sha512-/UAAbi9qRjUtjRISt5MJ1sfhtrHb26hqQ0nvE5qhMLsAdR5H7ErBwPD8Q/v2OENKm0iWsGwErIZEg7ebUeFDjQ==", + "requires": { + "binary-case": "^1.0.0", + "type-is": "^1.6.16" + } }, "accepts": { "version": "1.3.7", @@ -1656,6 +1663,11 @@ "express": "^4.17.1" }, "dependencies": { + "@vendia/serverless-express": { + "version": "4.5.2", + "resolved": "https://registry.npmjs.org/@vendia/serverless-express/-/serverless-express-4.5.2.tgz", + "integrity": "sha512-mekBOPnBxfhIvBYKVwfvjp9NtS+bOs3F08Vudxa3Fb7zkxtdjRn0UMLRT6zwWf6i4V5rjk2aEhzbIDSCV1GQ0w==" + }, "apollo-server-express": { "version": "3.6.1", "resolved": "https://registry.npmjs.org/apollo-server-express/-/apollo-server-express-3.6.1.tgz", @@ -1709,17 +1721,6 @@ "@vendia/serverless-express": "^3.4.0", "binary-case": "^1.0.0", "type-is": "^1.6.16" - }, - "dependencies": { - "@vendia/serverless-express": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/@vendia/serverless-express/-/serverless-express-3.4.0.tgz", - "integrity": "sha512-/UAAbi9qRjUtjRISt5MJ1sfhtrHb26hqQ0nvE5qhMLsAdR5H7ErBwPD8Q/v2OENKm0iWsGwErIZEg7ebUeFDjQ==", - "requires": { - "binary-case": "^1.0.0", - "type-is": "^1.6.16" - } - } } }, "binary-case": { diff --git a/src/graphql/package.json b/src/http/any-catchall/package.json similarity index 65% rename from src/graphql/package.json rename to src/http/any-catchall/package.json index 92e4728..edeb51f 100644 --- a/src/graphql/package.json +++ b/src/http/any-catchall/package.json @@ -1,9 +1,9 @@ { "type": "module", "dependencies": { - "@architect/functions": "latest", "apollo-server-core": "^3.3.0", "apollo-server-lambda": "^3.6.1", - "graphql": "^15.5.3" + "graphql": "^15.5.3", + "@architect/functions": "^4.1.1" } } \ No newline at end of file diff --git a/src/schema.graphql b/src/http/any-catchall/schema.graphql similarity index 100% rename from src/schema.graphql rename to src/http/any-catchall/schema.graphql diff --git a/src/lib/AlbumModule.js b/src/shared/lib/AlbumModule.js similarity index 97% rename from src/lib/AlbumModule.js rename to src/shared/lib/AlbumModule.js index c312d4a..a86fe88 100644 --- a/src/lib/AlbumModule.js +++ b/src/shared/lib/AlbumModule.js @@ -1,4 +1,4 @@ -import { jsonPlaceholder } from "../utils/base-axios.js"; +import { jsonPlaceholder } from "../utils.js"; export default class AlbumModule { //* create an Album diff --git a/src/lib/CommentModule.js b/src/shared/lib/CommentModule.js similarity index 97% rename from src/lib/CommentModule.js rename to src/shared/lib/CommentModule.js index bb40568..97406ab 100644 --- a/src/lib/CommentModule.js +++ b/src/shared/lib/CommentModule.js @@ -1,4 +1,4 @@ -import { jsonPlaceholder } from "../utils/base-axios.js"; +import { jsonPlaceholder } from "../utils.js"; export default class CommentModule { //* create a Comment diff --git a/src/lib/PhotoModule.js b/src/shared/lib/PhotoModule.js similarity index 97% rename from src/lib/PhotoModule.js rename to src/shared/lib/PhotoModule.js index 8c9b094..261ce18 100644 --- a/src/lib/PhotoModule.js +++ b/src/shared/lib/PhotoModule.js @@ -1,4 +1,4 @@ -import { jsonPlaceholder } from "../utils/base-axios.js"; +import { jsonPlaceholder } from "../utils.js"; export default class PhotoModule { //* create a Photo diff --git a/src/lib/PostModule.js b/src/shared/lib/PostModule.js similarity index 97% rename from src/lib/PostModule.js rename to src/shared/lib/PostModule.js index dc06403..a8e5de6 100644 --- a/src/lib/PostModule.js +++ b/src/shared/lib/PostModule.js @@ -1,4 +1,4 @@ -import { jsonPlaceholder } from "../utils/base-axios.js"; +import { jsonPlaceholder } from "../utils.js"; export default class PostModule { //* create a Post diff --git a/src/lib/TodoModule.js b/src/shared/lib/TodoModule.js similarity index 97% rename from src/lib/TodoModule.js rename to src/shared/lib/TodoModule.js index 493a45f..8755673 100644 --- a/src/lib/TodoModule.js +++ b/src/shared/lib/TodoModule.js @@ -1,4 +1,4 @@ -import { jsonPlaceholder } from "../utils/base-axios.js"; +import { jsonPlaceholder } from "../utils.js"; export default class TodoModule { //* create a Todo diff --git a/src/lib/UserModule.js b/src/shared/lib/UserModule.js similarity index 98% rename from src/lib/UserModule.js rename to src/shared/lib/UserModule.js index f571264..22b3219 100644 --- a/src/lib/UserModule.js +++ b/src/shared/lib/UserModule.js @@ -1,4 +1,4 @@ -import { jsonPlaceholder } from "../utils/base-axios.js"; +import { jsonPlaceholder } from "../utils.js"; export default class UserModule { //* create a User diff --git a/src/shared/package-lock.json b/src/shared/package-lock.json new file mode 100644 index 0000000..40086bf --- /dev/null +++ b/src/shared/package-lock.json @@ -0,0 +1,54 @@ +{ + "name": "shared", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "dependencies": { + "axios": "^0.24.0" + } + }, + "node_modules/axios": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.24.0.tgz", + "integrity": "sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==", + "dependencies": { + "follow-redirects": "^1.14.4" + } + }, + "node_modules/follow-redirects": { + "version": "1.14.7", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.7.tgz", + "integrity": "sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + } + }, + "dependencies": { + "axios": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.24.0.tgz", + "integrity": "sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==", + "requires": { + "follow-redirects": "^1.14.4" + } + }, + "follow-redirects": { + "version": "1.14.7", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.7.tgz", + "integrity": "sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ==" + } + } +} diff --git a/src/shared/package.json b/src/shared/package.json new file mode 100644 index 0000000..e360e74 --- /dev/null +++ b/src/shared/package.json @@ -0,0 +1,6 @@ +{ + "type": "module", + "dependencies": { + "axios": "^0.24.0" + } +} diff --git a/src/resolvers/Album.js b/src/shared/resolvers/Album.js similarity index 86% rename from src/resolvers/Album.js rename to src/shared/resolvers/Album.js index 3d951de..6be8f8b 100644 --- a/src/resolvers/Album.js +++ b/src/shared/resolvers/Album.js @@ -1,4 +1,4 @@ -import { sort } from "../utils/common.js"; +import { sort } from "../utils.js"; import Album from "../lib/AlbumModule.js"; export default { diff --git a/src/resolvers/Comment.js b/src/shared/resolvers/Comment.js similarity index 100% rename from src/resolvers/Comment.js rename to src/shared/resolvers/Comment.js diff --git a/src/resolvers/Mutation.js b/src/shared/resolvers/Mutation.js similarity index 100% rename from src/resolvers/Mutation.js rename to src/shared/resolvers/Mutation.js diff --git a/src/resolvers/Photo.js b/src/shared/resolvers/Photo.js similarity index 100% rename from src/resolvers/Photo.js rename to src/shared/resolvers/Photo.js diff --git a/src/resolvers/Post.js b/src/shared/resolvers/Post.js similarity index 86% rename from src/resolvers/Post.js rename to src/shared/resolvers/Post.js index ca363bf..2bddd7f 100644 --- a/src/resolvers/Post.js +++ b/src/shared/resolvers/Post.js @@ -1,4 +1,4 @@ -import { sort } from "../utils/common.js"; +import { sort } from "../utils.js"; import Post from "../lib/PostModule.js"; export default { diff --git a/src/resolvers/Query.js b/src/shared/resolvers/Query.js similarity index 98% rename from src/resolvers/Query.js rename to src/shared/resolvers/Query.js index de51a4a..4ec22ac 100644 --- a/src/resolvers/Query.js +++ b/src/shared/resolvers/Query.js @@ -4,7 +4,7 @@ import Comment from "../lib/CommentModule.js"; import Album from "../lib/AlbumModule.js"; import Photo from "../lib/PhotoModule.js"; import Todo from "../lib/TodoModule.js"; -import { sort } from "../utils/common.js"; +import { sort } from "../utils.js"; export default { info: () => `Simple GraphQL Proxy API for testing and prototyping`, diff --git a/src/resolvers/Todo.js b/src/shared/resolvers/Todo.js similarity index 100% rename from src/resolvers/Todo.js rename to src/shared/resolvers/Todo.js diff --git a/src/resolvers/User.js b/src/shared/resolvers/User.js similarity index 95% rename from src/resolvers/User.js rename to src/shared/resolvers/User.js index 3c4e79a..4adb2bd 100644 --- a/src/resolvers/User.js +++ b/src/shared/resolvers/User.js @@ -1,4 +1,4 @@ -import { sort } from "../utils/common.js"; +import { sort } from "../utils.js"; import User from "../lib/UserModule.js"; // 'parent' parameter carries the return value of the previous resolver execution level diff --git a/src/resolvers/index.js b/src/shared/resolvers/index.js similarity index 100% rename from src/resolvers/index.js rename to src/shared/resolvers/index.js diff --git a/src/utils/common.js b/src/shared/utils.js similarity index 52% rename from src/utils/common.js rename to src/shared/utils.js index b63be2d..ccff701 100644 --- a/src/utils/common.js +++ b/src/shared/utils.js @@ -1,3 +1,10 @@ +import axios from "axios"; + +//* Creating an instance of axios containing a URL so whenever there is a need to change the url it whould be this place only +export const jsonPlaceholder = axios.create({ + baseURL: "https://jsonplaceholder.typicode.com/", +}); + //* ip: array, sortType: "desc" | "asc" export const sort = (ip, sortType) => { if (sortType.toString() == "desc") diff --git a/src/utils/base-axios.js b/src/utils/base-axios.js deleted file mode 100644 index 0d77958..0000000 --- a/src/utils/base-axios.js +++ /dev/null @@ -1,6 +0,0 @@ -import axios from "axios"; - -// Creating an instance of axios containing a URL so whenever there is a need to change the url it whould be this place only -export const jsonPlaceholder = axios.create({ - baseURL: "https://jsonplaceholder.typicode.com/", -}); diff --git a/tests/graphqlServer.test.js b/tests/graphqlServer.test.js index 310ce5a..60dcfad 100644 --- a/tests/graphqlServer.test.js +++ b/tests/graphqlServer.test.js @@ -1,7 +1,7 @@ import test from "tape"; import tiny from "tiny-json-http"; -import Queries from "./queries.js"; import sandbox from "@architect/sandbox"; +import Queries from "./queries.js"; const postReq = async (queryObj) => { const variables = queryObj.variables ? queryObj.variables : {};