diff --git a/.prettierrc.json b/.prettierrc.json index a241d4d..2125623 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1,13 +1,15 @@ { - "trailingComma": "es5", + "trailingComma": "none", "tabWidth": 2, - "semi": true, + "semi": false, "singleQuote": true, - "printWidth": 160, + "printWidth": 100, "jsxSingleQuote": true, "useTabs": false, "useEditorConfig": true, "htmlWhitespaceSensitivity": "css", + "bracketSameLine": true, "bracketSpacing": true, - "prettier.arrowParens": "always" + "arrowParens": "always", + "quoteProps": "as-needed" } diff --git a/__tests__/supertest.js b/__tests__/supertest.js index c7652cf..a6dd2c1 100644 --- a/__tests__/supertest.js +++ b/__tests__/supertest.js @@ -1,53 +1,48 @@ -const request = require('supertest'); - - - -const server = 'http://localhost:8080'; - -describe('Route integration', function(){ - describe('/', () => { - describe('GET', () => { - it('responds with 200 status and text/html content type', function(done){ - request(server) - .get('/convert-demo-db') - .set('Accept', 'application/json') - .expect('Content-Type', /json/) - .expect(200, done); - }); - }); - - - describe('POST', () => { - it('responds with 200 status and text/html content type', function(done){ - request(server) - .get('/convert-sql-db') - .set('Accept', 'application/json') - .expect('Content-Type', /json/) - .expect(200, done); - }); - }); +const request = require('supertest') + +const server = 'http://localhost:8080' + +describe('Route integration', function () { + describe('/', () => { + describe('GET', () => { + it('responds with 200 status and text/html content type', function (done) { + request(server) + .get('/convert-demo-db') + .set('Accept', 'application/json') + .expect('Content-Type', /json/) + .expect(200, done) + }) + }) - describe('POST', () => { - it('responds with 200 status and text/html content type', function(done){ - request(server) - .get('/convert-mongo-db') - .set('Accept', 'application/json') - .expect('Content-Type', /json/) - .expect(200, done); - }); - }); + describe('POST', () => { + it('responds with 200 status and text/html content type', function (done) { + request(server) + .get('/convert-sql-db') + .set('Accept', 'application/json') + .expect('Content-Type', /json/) + .expect(200, done) + }) + }) + describe('POST', () => { + it('responds with 200 status and text/html content type', function (done) { + request(server) + .get('/convert-mongo-db') + .set('Accept', 'application/json') + .expect('Content-Type', /json/) + .expect(200, done) + }) }) - describe('/', () => { - describe('GET', () => { - it('responds with 404 not found', function(done){ - request(server) - .get('/fake') - .set('Accept', 'application/json') - .expect('Content-Type', /json/) - .expect(404, done); - }); - }); + }) + describe('/', () => { + describe('GET', () => { + it('responds with 404 not found', function (done) { + request(server) + .get('/fake') + .set('Accept', 'application/json') + .expect('Content-Type', /json/) + .expect(404, done) + }) }) -}); - + }) +}) diff --git a/components/CodeBoxContainer.js b/components/CodeBoxContainer.js index 4800cdc..f09fe60 100644 --- a/components/CodeBoxContainer.js +++ b/components/CodeBoxContainer.js @@ -1,50 +1,50 @@ -import React from 'react'; -import { saveAs } from 'file-saver'; -import { useSelector } from 'react-redux'; -import SyntaxHighlighter from 'react-syntax-highlighter'; -import { Button } from '@nextui-org/react'; +import React from 'react' +import { saveAs } from 'file-saver' +import { useSelector } from 'react-redux' +import SyntaxHighlighter from 'react-syntax-highlighter' +import { Button } from '@nextui-org/react' -import qtCreator from '../node_modules/react-syntax-highlighter/dist/esm/styles/hljs/qtcreator_dark'; -import styles from '../styles/CodeBoxContainer.module.css'; -import { SampleGQLServerCode, SampleGQLClientQueriesCode, SampleGQLClientMutationsCode } from '../server/sampleDB'; +import qtCreator from '../node_modules/react-syntax-highlighter/dist/esm/styles/hljs/qtcreator_dark' +import styles from '../styles/CodeBoxContainer.module.css' +import { SampleGQLServerCode, SampleGQLClientQueriesCode, SampleGQLClientMutationsCode } from '../server/sampleDB' function CodeBoxContainer() { - const showDemo = useSelector((state) => state.demo.showDemo); - const data = useSelector((state) => state.demo.queries); + const showDemo = useSelector((state) => state.demo.showDemo) + const data = useSelector((state) => state.demo.queries) - const uriDataGQLServerCode = data ? data.GQLServerCode : ''; - const uriDataGQLClientMutationsCode = data ? data.GQLClientMutationsCode : ''; - const uriDataGQLClientQueriesCode = data ? data.GQLClientQueriesCode : ''; + const uriDataGQLServerCode = data ? data.GQLServerCode : '' + const uriDataGQLClientMutationsCode = data ? data.GQLClientMutationsCode : '' + const uriDataGQLClientQueriesCode = data ? data.GQLClientQueriesCode : '' /* EXPORT GQL SERVER CODE */ const exportGQLServerCode = () => { if (showDemo) { - saveAs(new File([`${SampleGQLServerCode}`], 'GQLServerCode.js', { type: 'text/plain;charset=utf-8' })); + saveAs(new File([`${SampleGQLServerCode}`], 'GQLServerCode.js', { type: 'text/plain;charset=utf-8' })) } if (!showDemo && uriDataGQLServerCode !== '') { - saveAs(new File([`${uriDataGQLServerCode}`], 'GQLServerCode.js', { type: 'text/plain;charset=utf-8' })); + saveAs(new File([`${uriDataGQLServerCode}`], 'GQLServerCode.js', { type: 'text/plain;charset=utf-8' })) } - }; + } /* EXPORT GQL CLIENT MUTATIONS CODE */ const exportGQLClientMutationsCode = () => { if (showDemo) { - saveAs(new File([`${SampleGQLClientMutationsCode}`], 'GQLClientMutationsCode.js', { type: 'text/plain;charset=utf-8' })); + saveAs(new File([`${SampleGQLClientMutationsCode}`], 'GQLClientMutationsCode.js', { type: 'text/plain;charset=utf-8' })) } if (!showDemo && uriDataGQLClientMutationsCode !== '') { - saveAs(new File([`${uriDataGQLClientMutationsCode}`], 'GQLClientMutationsCode.js', { type: 'text/plain;charset=utf-8' })); + saveAs(new File([`${uriDataGQLClientMutationsCode}`], 'GQLClientMutationsCode.js', { type: 'text/plain;charset=utf-8' })) } - }; + } /* EXPORT GQL CLIENT QUERIES CODE */ const exportGQLClientQueriesCode = () => { if (showDemo) { - saveAs(new File([`${SampleGQLClientQueriesCode}`], 'GQLClientQueriesCode.js', { type: 'text/plain;charset=utf-8' })); + saveAs(new File([`${SampleGQLClientQueriesCode}`], 'GQLClientQueriesCode.js', { type: 'text/plain;charset=utf-8' })) } if (!showDemo && uriDataGQLClientQueriesCode !== '') { - saveAs(new File([`${uriDataGQLClientQueriesCode}`], 'GQLClientQueriesCode.js', { type: 'text/plain;charset=utf-8' })); + saveAs(new File([`${uriDataGQLClientQueriesCode}`], 'GQLClientQueriesCode.js', { type: 'text/plain;charset=utf-8' })) } - }; + } return (
@@ -60,7 +60,7 @@ function CodeBoxContainer() { size='sm' css={{ px: '$4', height: '$10' }} onClick={() => { - exportGQLClientMutationsCode(); + exportGQLClientMutationsCode() }} > Export Code @@ -81,7 +81,7 @@ function CodeBoxContainer() { size='sm' css={{ px: '$4', height: '$10' }} onClick={() => { - exportGQLClientQueriesCode(); + exportGQLClientQueriesCode() }} > Export Code @@ -103,7 +103,7 @@ function CodeBoxContainer() { size='sm' css={{ px: '$4', height: '$10' }} onClick={() => { - exportGQLServerCode(); + exportGQLServerCode() }} > Export Code @@ -114,7 +114,7 @@ function CodeBoxContainer() {
- ); + ) } -export default CodeBoxContainer; +export default CodeBoxContainer diff --git a/components/DbInfo.js b/components/DbInfo.js index 6fd51e8..41cc3f0 100644 --- a/components/DbInfo.js +++ b/components/DbInfo.js @@ -1,15 +1,21 @@ -import React, { useState } from 'react'; -import { Button, Spacer } from '@nextui-org/react'; -import { useDispatch, useSelector } from 'react-redux'; +import React, { useState } from 'react' +import { Button, Spacer } from '@nextui-org/react' +import { useDispatch, useSelector } from 'react-redux' -import { setQueries, showDemo, setIsError, setShowDBInfo, setShowFlowModal } from '../features/demoSlice'; -import styles from '../styles/DbInfo.module.css'; +import { + setQueries, + showDemo, + setIsError, + setShowDBInfo, + setShowFlowModal +} from '../features/demoSlice' +import styles from '../styles/DbInfo.module.css' function DbInfo({ dbData, hidePanel, setDbData }) { - const [dbName, setDBName] = useState(!dbData ? 'Sample Database' : dbData.name); - const [dbType, setDBType] = useState(!dbData ? 'PostgreSQL' : dbData.type); + const [dbName, setDBName] = useState(!dbData ? 'Sample Database' : dbData.name) + const [dbType, setDBType] = useState(!dbData ? 'PostgreSQL' : dbData.type) - const dispatch = useDispatch(); + const dispatch = useDispatch() return (
@@ -21,17 +27,16 @@ function DbInfo({ dbData, hidePanel, setDbData }) {
- ); + ) } -export default DbInfo; +export default DbInfo diff --git a/components/DbInput.js b/components/DbInput.js index 061f84f..783bfa3 100644 --- a/components/DbInput.js +++ b/components/DbInput.js @@ -1,45 +1,52 @@ -import React, { useRef } from 'react'; -import { Input, Spacer, Button } from '@nextui-org/react'; -import { useDispatch, useSelector } from 'react-redux'; -import CryptoJS from 'crypto-js'; +import React, { useRef } from 'react' +import { Input, Spacer, Button } from '@nextui-org/react' +import { useDispatch, useSelector } from 'react-redux' +import CryptoJS from 'crypto-js' -import { setQueries, showDemo, setIsError, setErrorMsg, setShowLoader, setShowDBInfo } from '../features/demoSlice'; -import styles from '../styles/DbUri.module.css'; -import secretKey from '../server/secretKey'; +import { + setQueries, + showDemo, + setIsError, + setErrorMsg, + setShowLoader, + setShowDBInfo +} from '../features/demoSlice' +import styles from '../styles/DbUri.module.css' +import secretKey from '../server/secretKey' function DbInput({ fetchData }) { - const uriField = useRef(); - const isError = useSelector((state) => state.demo.isError); - const errorMsg = useSelector((state) => state.demo.errorMsg); - const dispatch = useDispatch(); + const uriField = useRef() + const isError = useSelector((state) => state.demo.isError) + const errorMsg = useSelector((state) => state.demo.errorMsg) + const dispatch = useDispatch() const handleClick = async (e) => { - dispatch(showDemo(false)); - const URILink = uriField.current.value; - e.preventDefault(); + dispatch(showDemo(false)) + const URILink = uriField.current.value + e.preventDefault() - const fetchEndpoint = await checkEndpoint(URILink); + const fetchEndpoint = await checkEndpoint(URILink) if (URILink.length > 0 && fetchEndpoint.length > 0) { - const encryptedURL = CryptoJS.AES.encrypt(URILink, secretKey).toString(); //Encrypting user-inputted DB URI string - fetchData(encryptedURL, fetchEndpoint); + const encryptedURL = CryptoJS.AES.encrypt(URILink, secretKey).toString() //Encrypting user-inputted DB URI string + fetchData(encryptedURL, fetchEndpoint) } else { - dispatch(setErrorMsg('Please enter a valid PostgreSQL or MongoDB URI')); - dispatch(setIsError(true)); + dispatch(setErrorMsg('Please enter a valid PostgreSQL or MongoDB URI')) + dispatch(setIsError(true)) } - }; + } const checkEndpoint = async (URILink) => { - const mongodbURI = 'convert-mongo-db'; - const sqlURI = 'convert-sql-db'; + const mongodbURI = 'convert-mongo-db' + const sqlURI = 'convert-sql-db' if (URILink.includes('postgres://')) { - return sqlURI; + return sqlURI } else if (URILink.includes('mongodb+srv://')) { - return mongodbURI; + return mongodbURI } else { - return ''; + return '' } - }; + } return ( <> @@ -54,7 +61,7 @@ function DbInput({ fetchData }) { initialValue='' ref={uriField} onKeyDown={(e) => { - if (e.key === 'Enter') handleClick(e); + if (e.key === 'Enter') handleClick(e) }} /> @@ -68,12 +75,11 @@ function DbInput({ fetchData }) { size='sm' css={{ px: '$14' }} onClick={(e) => { - dispatch(setQueries('')); - dispatch(setIsError(false)); - dispatch(setErrorMsg('')); - handleClick(e); - }} - > + dispatch(setQueries('')) + dispatch(setIsError(false)) + dispatch(setErrorMsg('')) + handleClick(e) + }}> Generate @@ -89,22 +95,21 @@ function DbInput({ fetchData }) { size='sm' css={{ px: '$10' }} onClick={() => { - dispatch(setIsError(false)); - dispatch(showDemo(false)); //update showDemo state in redux - dispatch(setQueries('')); - dispatch(setShowLoader(true)); + dispatch(setIsError(false)) + dispatch(showDemo(false)) //update showDemo state in redux + dispatch(setQueries('')) + dispatch(setShowLoader(true)) setTimeout(() => { - dispatch(setShowLoader(false)); - dispatch(showDemo(true)); //update showDemo state in redux - dispatch(setShowDBInfo(true)); - }, 700); - }} - > + dispatch(setShowLoader(false)) + dispatch(showDemo(true)) //update showDemo state in redux + dispatch(setShowDBInfo(true)) + }, 700) + }}> Sample Database - ); + ) } -export default DbInput; +export default DbInput diff --git a/components/DbUri.js b/components/DbUri.js index 0ec96ee..4883fd2 100644 --- a/components/DbUri.js +++ b/components/DbUri.js @@ -1,17 +1,17 @@ -import React from 'react'; -import { useSelector } from 'react-redux'; -import { motion, AnimatePresence } from 'framer-motion'; +import React from 'react' +import { useSelector } from 'react-redux' +import { motion, AnimatePresence } from 'framer-motion' -import DbInput from '../components/DbInput'; -import DbInfo from '../components/DbInfo'; -import styles from '../styles/DbUri.module.css'; +import DbInput from '../components/DbInput' +import DbInfo from '../components/DbInfo' +import styles from '../styles/DbUri.module.css' -const easing = [0.83, 0, 0.17, 1]; +const easing = [0.83, 0, 0.17, 1] const fadeInRight = { initial: { x: [-400, 50, 0], - opacity: 1, + opacity: 1 }, animate: { x: 0, @@ -20,25 +20,34 @@ const fadeInRight = { delay: 10, // type: 'spring', duration: 1.0, - ease: easing, - }, + ease: easing + } }, exit: { opacity: 1, - x: [-400, 50, 0], - }, -}; + x: [-400, 50, 0] + } +} function DbUri({ hidePanel, fetchData, dbData, setDbData }) { - const showDBInfo = useSelector((state) => state.demo.showDBInfo); + const showDBInfo = useSelector((state) => state.demo.showDBInfo) return ( - - {showDBInfo ? : } + + {showDBInfo ? ( + + ) : ( + + )} - ); + ) } -export default DbUri; +export default DbUri diff --git a/components/Features.js b/components/Features.js index d4236f6..0425172 100644 --- a/components/Features.js +++ b/components/Features.js @@ -1,11 +1,11 @@ -import React from 'react'; -import Image from 'next/image'; +import React from 'react' +import Image from 'next/image' -import styles from '../styles/Learn.module.css'; -import DbInput from '../public/home1.gif'; -import GQLCode from '../public/home2.gif'; -import ExportCode from '../public/home3.gif'; -import Visualize from '../public/home4.gif'; +import styles from '../styles/Learn.module.css' +import DbInput from '../public/home1.gif' +import GQLCode from '../public/home2.gif' +import ExportCode from '../public/home3.gif' +import Visualize from '../public/home4.gif' function Features({ index, title, description }) { if (index === 0) { @@ -20,7 +20,7 @@ function Features({ index, title, description }) { demo-gif - ); + ) } if (index === 1) { return ( @@ -34,7 +34,7 @@ function Features({ index, title, description }) { demo-gif - ); + ) } if (index === 2) { return ( @@ -48,7 +48,7 @@ function Features({ index, title, description }) { demo-gif - ); + ) } if (index === 3) { return ( @@ -62,8 +62,8 @@ function Features({ index, title, description }) { demo-gif - ); + ) } } -export default Features; +export default Features diff --git a/components/GQLevated.js b/components/GQLevated.js index e1e2b21..ac39980 100644 --- a/components/GQLevated.js +++ b/components/GQLevated.js @@ -1,9 +1,9 @@ -import React from 'react'; -import Link from 'next/link'; -import Image from 'next/image'; +import React from 'react' +import Link from 'next/link' +import Image from 'next/image' -import GQLevatedLogo from '../public/GQL_ASSET.svg'; -import styles from '../styles/Nav.module.css'; +import GQLevatedLogo from '../public/GQL_ASSET.svg' +import styles from '../styles/Nav.module.css' function GQLevated() { return ( @@ -12,7 +12,7 @@ function GQLevated() { logo-gif - ); + ) } -export default GQLevated; +export default GQLevated diff --git a/components/GitHubStar.js b/components/GitHubStar.js index a12a990..b45acfb 100644 --- a/components/GitHubStar.js +++ b/components/GitHubStar.js @@ -1,12 +1,12 @@ -import React from 'react'; -import Image from 'next/image'; +import React from 'react' +import Image from 'next/image' -import styles from '../styles/GitHubStar.module.css'; -import LinkedInLogo from '../public/Linkedin-logo-on-transparent-Background-PNG-.png'; -import GitHubLogo from '../public/GitHub-Mark-64px.png'; -import GitHubButton from 'react-github-btn'; -import GraphqlLogo from '../public/graphql2.png'; -import MediumLogo from '../public/medium-monogram-480.png'; +import styles from '../styles/GitHubStar.module.css' +import LinkedInLogo from '../public/Linkedin-logo-on-transparent-Background-PNG-.png' +import GitHubLogo from '../public/GitHub-Mark-64px.png' +import GitHubButton from 'react-github-btn' +import GraphqlLogo from '../public/graphql2.png' +import MediumLogo from '../public/medium-monogram-480.png' function GitHubStar() { return ( @@ -20,20 +20,31 @@ function GitHubStar() { + rel='noreferrer noopener'>
  • logo-gif
  • - +
  • logo-gif
  • - +
  • - logo-gif + logo-gif
  • @@ -43,14 +54,13 @@ function GitHubStar() { data-icon='octicon-star' data-size='large' data-show-count='true' - aria-label='Star oslabs-beta/GQLevated on GitHub' - > + aria-label='Star oslabs-beta/GQLevated on GitHub'> Star
  • - ); + ) } -export default GitHubStar; +export default GitHubStar diff --git a/components/Hero.js b/components/Hero.js index eb913bd..e59aa5e 100644 --- a/components/Hero.js +++ b/components/Hero.js @@ -1,23 +1,23 @@ -import React from 'react'; -import Link from 'next/link'; -import Image from 'next/image'; -import { motion } from 'framer-motion'; -import { Spacer } from '@nextui-org/react'; +import React from 'react' +import Link from 'next/link' +import Image from 'next/image' +import { motion } from 'framer-motion' +import { Spacer } from '@nextui-org/react' -import styles from '../styles/Hero.module.css'; -import GQLLogo from '../public/LOGO.svg'; +import styles from '../styles/Hero.module.css' +import GQLLogo from '../public/LOGO.svg' -const easing = [0.17, 0.67, 0.84, 0.66]; +const easing = [0.17, 0.67, 0.84, 0.66] const rotate = { initial: { rotate: [0, 750, 720], transition: { linear: easing, - duration: 2.2, - }, - }, -}; + duration: 2.2 + } + } +} function Hero() { return ( @@ -34,7 +34,7 @@ function Hero() { - ); + ) } -export default Hero; +export default Hero diff --git a/components/HiddenURIPanel.js b/components/HiddenURIPanel.js index 5d35bc9..00d4611 100644 --- a/components/HiddenURIPanel.js +++ b/components/HiddenURIPanel.js @@ -1,14 +1,14 @@ -import React, { useRef, useState, useEffect } from 'react'; -import { motion } from 'framer-motion'; +import React, { useRef, useState, useEffect } from 'react' +import { motion } from 'framer-motion' -import styles from '../styles/HiddenURIPanel.module.css'; +import styles from '../styles/HiddenURIPanel.module.css' -const easing = [0.83, 0, 0.17, 1]; +const easing = [0.83, 0, 0.17, 1] const fadeInLeft = { initial: { x: [0, 10, 0], - opacity: 1, + opacity: 1 }, animate: { x: 0, @@ -16,31 +16,31 @@ const fadeInLeft = { transition: { delay: 10, type: 'bounce', - duration: 1.0, - }, - }, -}; + duration: 1.0 + } + } +} function HiddenURIPanel({ showPanel }) { - const [showHoverPanel, setShowHoverPanel] = useState(false); - const panelRef = useRef(); + const [showHoverPanel, setShowHoverPanel] = useState(false) + const panelRef = useRef() useEffect(() => { if (showHoverPanel) { - panelRef.current.style.boxShadow = '0 0 10px #cbcdd0'; - panelRef.current.style.backgroundColor = 'var(--secondary-color)'; - panelRef.current.style.opacity = '0.5'; + panelRef.current.style.boxShadow = '0 0 10px #cbcdd0' + panelRef.current.style.backgroundColor = 'var(--secondary-color)' + panelRef.current.style.opacity = '0.5' } else { - panelRef.current.style.boxShadow = ''; - panelRef.current.style.backgroundColor = ''; + panelRef.current.style.boxShadow = '' + panelRef.current.style.backgroundColor = '' } - }, [showHoverPanel]); + }, [showHoverPanel]) const bounceTransition = { duration: 0.4, yoyo: Infinity, - ease: 'easeOut', - }; + ease: 'easeOut' + } return ( showPanel()} onMouseOver={() => setShowHoverPanel(true)} - onMouseLeave={() => setShowHoverPanel(false)} - > - ); + onMouseLeave={() => setShowHoverPanel(false)}> + ) } -export default HiddenURIPanel; +export default HiddenURIPanel diff --git a/components/Layout.js b/components/Layout.js index 1019a52..e3285d5 100644 --- a/components/Layout.js +++ b/components/Layout.js @@ -1,7 +1,7 @@ -import React from 'react'; +import React from 'react' -import Nav from '../components/Nav'; -import styles from '../styles/Layout.module.css'; +import Nav from '../components/Nav' +import styles from '../styles/Layout.module.css' function Layout({ children }) { return ( @@ -9,7 +9,7 @@ function Layout({ children }) {