diff --git a/client-app/src/App.js b/client-app/src/App.js index e1856dd..de014b6 100644 --- a/client-app/src/App.js +++ b/client-app/src/App.js @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { useContext } from "react"; import "./App.css"; import Landing from "./components/shared/landing.js"; import Header from "./components/shared/header.js"; @@ -8,32 +8,27 @@ import Login from "./components/shared/login.js"; import Home from "./components/vendor/home.js"; import Heatmap from "./components/vendor/heatmap.js"; import Timetable from "./components/vendor/timetable.js"; +import CustomerMap from "./components/customer/map.js"; // For react router import { BrowserRouter as Router, Switch, Route } from "react-router-dom"; // For React context management import { AppContextProvider } from "./components/AppContext"; function App() { - const [isVendor, setIsVendor] = useState(true); - return (
- } /> + } /> } /> - } - /> - } - /> + } /> + } /> } /> } /> + } /> + } />
@@ -41,19 +36,4 @@ function App() { ); } -/* } /> - - } -/> */ - -/* } -/> */ - export default App; - -/* - */ diff --git a/client-app/src/components/AppContext.js b/client-app/src/components/AppContext.js index 11866a1..60cdd0a 100644 --- a/client-app/src/components/AppContext.js +++ b/client-app/src/components/AppContext.js @@ -3,7 +3,7 @@ import React, { useState, createContext } from "react"; const AppContext = createContext(); function AppContextProvider(props) { - const [logInStatus, setLogInStatus] = useState(true); + const [logInStatus, setLogInStatus] = useState(false); const [isVendor, setIsVendor] = useState(true); const [signUpStateVendor, setSignUpStateVendor] = useState({ name: "", diff --git a/client-app/src/components/customer/map.js b/client-app/src/components/customer/map.js index 0dcb0ca..b68baaa 100644 --- a/client-app/src/components/customer/map.js +++ b/client-app/src/components/customer/map.js @@ -3,17 +3,17 @@ import React from "react"; import LondonMap from "../../utils/london-map.js"; export default function CustomerMap() { - function signalInterest(e) { - e.preventDefault; - //API post request to customer location table INSERT INTO customer_location - } + // function signalInterest(e) { + // e.preventDefault; + // //API post request to customer location table INSERT INTO customer_location + // }; - return ( -
- - -
- ); + return

Customer map

; } + +/* //
+ // + // + //
*/ diff --git a/client-app/src/components/shared/extra.js b/client-app/src/components/shared/extra.js deleted file mode 100644 index d25735e..0000000 --- a/client-app/src/components/shared/extra.js +++ /dev/null @@ -1,100 +0,0 @@ -// https://github.com/fac18/signpost/blob/master/client/src/components/AddNewService/AddNewService.js - -// useEffect( -// //checks to see if a user is a customer or vendor and will render the relevant form fields -// () => { -// isVendor -// ? setSignUpState({ -// name: "", -// email: "", -// password: "", -// mobile: "", -// company_name: "", -// alcohol: "", -// vegan_option: "", -// }) -// : setSignUpState({ -// name: "", -// email: "", -// password: "", -// username: "", -// age: "", -// gender: "", -// icecream_flavour: "", -// }) -// }, -// [] -// ) - -// const [submission, handleSubmission] = React.useState([]) -// React.useEffect(() => { -// const reqOptions = { -// method: "POST", -// headers: { "Content-Type": "application/json" }, -// body: JSON.stringify({ title: "React POST Request Example" }), -// } -// fetch(url goes here, reqOptions) -// .then(data =>) - -// function reducer(state, { field, value }) { -// return { -// ...state, -// [field]: value, -// } -// } - -// if (isVendor) { -// const { -// name, -// email, -// password, -// mobile, -// company_name, -// alcohol, -// vegan_option, -// } = state -// } else { -// const { -// name, -// email, -// password, -// username, -// age, -// gender, -// icecream_flavour, -// } = state -// } - -//function handleFormSubmission(event){ -//const username = document.getElementById('customerName').value -//axios.post(api url) -//.then(result =>) -//} - -// function signUp({ redirect }) { -// document.title = "Sign Up" -// app.innerHTML = html -// app.querySelector("form").addEventListener("submit", (e) => { -// e.preventDefault() -// const formData = new FormData(e.target) -// const formObject = Object.fromEntries(formData) -// fetch("https://dogs-rest.herokuapp.com/v1/users/", { -// method: "POST", -// body: JSON.stringify(formObject), - -// headers: { -// "Content-Type": "application/json", -// }, -// }) -// .then((res) => res.json()) -// .then((json) => { -// window.localStorage.setItem("id", json.id) -// window.localStorage.setItem("token", json.access_token) -// redirect("/") -// }) -// .catch((error) => { -// console.log("error in signup!") -// app.querySelector("#message").innerHTML = `

${error} haha

` -// }) -// }) -// } diff --git a/client-app/src/components/shared/header.js b/client-app/src/components/shared/header.js index 09ecae9..e72db3f 100644 --- a/client-app/src/components/shared/header.js +++ b/client-app/src/components/shared/header.js @@ -1,14 +1,33 @@ -import React, { useContext } from "react" -import { AppContext } from "../AppContext" -import { Title, HeaderArea } from "../../styles/header.js" +import React, { useContext } from "react"; +import { AppContext } from "../AppContext"; +import { Title, HeaderArea, LogInOption } from "../../styles/header.js"; export default function Header() { - const { logInStatus } = useContext(AppContext) + const { logInStatus, setLogInStatus } = useContext(AppContext); + + function removeToken() { + window.localStorage.removeItem("token"); + } + + function headerStatus() { + let token = localStorage.getItem("token"); + if (!token) { + setLogInStatus(false); + return Log In or Sign Up Here!; + } else { + setLogInStatus(true); + return ( + + Log Out + + ); + } + } return ( Where's Whippy - {!logInStatus ? Log In : Log Out} + {headerStatus()} - ) + ); } diff --git a/client-app/src/components/shared/landing.js b/client-app/src/components/shared/landing.js index 7127913..2934446 100644 --- a/client-app/src/components/shared/landing.js +++ b/client-app/src/components/shared/landing.js @@ -7,30 +7,16 @@ import { BlueButton, PinkButton, PageContainer } from "../../styles/buttons.js"; export default function Landing() { const { isVendor, setIsVendor } = useContext(AppContext); - console.log("landing state: ", isVendor); - return ( -

Tired of waiting for the jingle?

- illustation +

Tired of waiting for the jingle?

+ illustation setIsVendor(true)}> - Vendors + Vendors setIsVendor(false)}> - Customers + Customers
); - - // function handleLoginLinkVendor() { - // alert("Vendor login button clicked") - // setIsVendor(true) - // } - - // function handleLoginLinkCustomer() { - // console.log(isVendor) - // setIsVendor(false) - // console.log(isVendor) - // // alert("Customer login button clicked") - // } } diff --git a/client-app/src/components/shared/login.js b/client-app/src/components/shared/login.js index 195218f..61e00ff 100644 --- a/client-app/src/components/shared/login.js +++ b/client-app/src/components/shared/login.js @@ -1,6 +1,15 @@ import React, { useContext } from "react"; +import { Button, BlueButton, PinkButton } from "../../styles/buttons"; +import { textStyle } from "../../styles/text"; +import { Label, Input, FormContainer } from "../../styles/form"; + +import { + postVendorLoginInformation, + postCustomerLoginInformation, +} from "../../utils/postData"; import { AppContext } from "../AppContext"; +import { BrowserRouter as Router, Redirect } from "react-router-dom"; export default function Login() { const { @@ -21,14 +30,6 @@ export default function Login() { } }; - const handleSubmit = (e) => { - if (isVendor) { - handleSubmitVendor(e); - } else { - handleSubmitCustomer(e); - } - }; - const handleOnChangeVendor = (e) => { let property = e.target.name; let value = e.target.value; @@ -40,31 +41,108 @@ export default function Login() { setSignUpStateVendor(newLogInStateVendor); }; - const handleOnChangeCustomer = (e) => {}; + const handleOnChangeCustomer = (e) => { + let property = e.target.name; + let value = e.target.value; - const handleSubmitVendor = (e) => {}; + const newLogInStateCustomer = { + ...signUpStateCustomer, + [property]: value, + }; + setSignUpStateCustomer(newLogInStateCustomer); + }; - const handleSubmitCustomer = (e) => {}; + const handleSubmit = (e) => { + if (isVendor) { + handleSubmitVendor(e); + } else { + handleSubmitCustomer(e); + } + }; + + const handleSubmitVendor = (e) => { + e.preventDefault(); + postVendorLoginInformation(signUpStateVendor) + .then((res) => { + if (!res.ok) { + throw new Error( + `Unable to login. API responded with status code: ${res.status}` + ); + } else { + return res.json(); + } + }) + .then((body) => { + window.localStorage.setItem("token", body.access_token); + setLogInStatus(true); + }) + .catch((err) => console.error(err)); + }; - const inputValue = isVendor + const handleSubmitCustomer = (e) => { + e.preventDefault(); + postCustomerLoginInformation(signUpStateCustomer) + .then((res) => { + if (!res.ok) { + throw new Error( + `Unable to login. API responded with status code: ${res.status}` + ); + } else { + return res.json(); + } + }) + .then((body) => { + window.localStorage.setItem("token", body.access_token); + setLogInStatus(true); + }) + .catch((err) => console.error(err)); + }; + + const inputValueEmail = isVendor ? signUpStateVendor.email : signUpStateCustomer.email; + + const inputValuePassword = isVendor + ? signUpStateVendor.password + : signUpStateCustomer.password; + + function loggedInStatusCheckerAndRedirect() { + if (logInStatus && isVendor) { + return ; + } + if (logInStatus && !isVendor) { + return ; + } + } + return ( -
- - + {loggedInStatusCheckerAndRedirect()} + + + - - - -
+ + + + {isVendor ? ( + Login + ) : ( + Login + )} + ); } diff --git a/client-app/src/components/shared/signup.js b/client-app/src/components/shared/signup.js index a0dfbcb..bf6d829 100644 --- a/client-app/src/components/shared/signup.js +++ b/client-app/src/components/shared/signup.js @@ -1,12 +1,23 @@ import React, { useEffect, useContext } from "react"; import { Link } from "react-router-dom"; -import postSignUpInformation from "../../utils/postData"; +import { + postVendorSignUpInformation, + postCustomerSignUpInformation, +} from "../../utils/postData"; import { AppContext } from "../AppContext"; import { Button, BlueButton, PinkButton } from "../../styles/buttons"; import { textStyle } from "../../styles/text"; -import { Label, Input, Legend, FormContainer } from "../../styles/form"; +import { + Label, + Input, + Legend, + FormContainer, + FieldSet, +} from "../../styles/form"; -// ***NOTES*** +import { BrowserRouter as Router, Redirect } from "react-router-dom"; + +// ***TEAM NOTES*** // Radio buttons are not much fun // The value attribute of a tag only be a string // The checked attribute on a radio button needs to a boolean (for alcohol or veganOption) @@ -19,6 +30,8 @@ import { Label, Input, Legend, FormContainer } from "../../styles/form"; export default function SignUp() { const { + logInStatus, + setLogInStatus, isVendor, setIsVendor, signUpStateVendor, @@ -27,8 +40,20 @@ export default function SignUp() { setSignUpStateCustomer, } = useContext(AppContext); + // ***NOTES*** + // name, pasword and email are common to both the vendor and customer + // A ternary is user to render the other customer or vendor inputs + // JS functions have been extracted from JSX into helper functions + + const handleChange = (e) => { + if (isVendor) { + handleOnChangeVendor(e); + } else { + handleOnChangeCustomer(e); + } + }; + const handleOnChangeVendor = (e) => { - debugger; let property = e.target.name; let value = e.target.value; if (value === "true") { @@ -60,42 +85,86 @@ export default function SignUp() { setSignUpStateCustomer(newSignUpStateCustomer); }; + const handleSubmit = (e) => { + if (isVendor) { + handleSubmitVendor(e); + } else { + handleSubmitCustomer(e); + } + }; + const handleSubmitVendor = (e) => { e.preventDefault(); - console.log(`Posting vendor object:`, signUpStateVendor); - postSignUpInformation(signUpStateVendor).then((token) => { - console.log(token); - // window.localStorage.setItem("token", body) - }); + postVendorSignUpInformation(signUpStateVendor) + .then((res) => { + if (!res.ok) { + throw new Error( + `Unable to signup. API responded with status code: ${res.status}` + ); + } else { + return res.json(); + } + }) + .then((body) => { + window.localStorage.setItem("token", body.access_token); + setLogInStatus(true); + }) + .catch((err) => console.error(err)); }; const handleSubmitCustomer = (e) => { e.preventDefault(); - console.log(`Posting customer object:`, signUpStateCustomer); + postCustomerSignUpInformation(signUpStateCustomer) + .then((res) => { + if (!res.ok) { + throw new Error( + `Unable to signup. API responded with status code: ${res.status}` + ); + } else { + return res.json(); + } + }) + .then((body) => { + window.localStorage.setItem("token", body.access_token); + setLogInStatus(true); + }) + .catch((err) => console.error(err)); }; - // ***NOTES*** - // name, pasword and email are common to both the vendor and customer - // A ternary is user to render the other customer or vendor inputs + // When component mounts checks to see if user is logged in + function loggedInStatusCheckerAndRedirect() { + if (logInStatus && isVendor) { + return ; + } + if (logInStatus && !isVendor) { + return ; + } + } + + // Input value helper functions + const inputValueName = isVendor + ? signUpStateVendor.name + : signUpStateCustomer.name; + + const inputValueEmail = isVendor + ? signUpStateVendor.email + : signUpStateCustomer.email; + + const inputValuePassword = isVendor + ? signUpStateVendor.password + : signUpStateCustomer.password; return ( - handleSubmitVendor(e) : (e) => handleSubmitCustomer(e) - } - > + + {loggedInStatusCheckerAndRedirect()} handleOnChangeVendor(e) - : (e) => handleOnChangeCustomer(e) - } - value={isVendor ? signUpStateVendor.name : signUpStateCustomer.name} + onChange={handleChange} + value={inputValueName} /> @@ -104,12 +173,8 @@ export default function SignUp() { id="email" name="email" required - onChange={ - isVendor - ? (e) => handleOnChangeVendor(e) - : (e) => handleOnChangeCustomer(e) - } - value={isVendor ? signUpStateVendor.email : signUpStateCustomer.email} + onChange={handleChange} + value={inputValueEmail} /> @@ -118,14 +183,8 @@ export default function SignUp() { id="password" name="password" required - onChange={ - isVendor - ? (e) => handleOnChangeVendor(e) - : (e) => handleOnChangeCustomer(e) - } - value={ - isVendor ? signUpStateVendor.password : signUpStateCustomer.password - } + onChange={handleChange} + value={inputValuePassword} /> {/* THIS IS THE TERNARY */} {isVendor ? ( @@ -137,7 +196,7 @@ export default function SignUp() { name="mobile" required value={signUpStateVendor.mobile} - onChange={(e) => handleOnChangeVendor(e)} + onChange={handleOnChangeVendor} /> @@ -147,10 +206,10 @@ export default function SignUp() { name="companyName" required value={signUpStateVendor.companyName} - onChange={(e) => handleOnChangeVendor(e)} + onChange={handleOnChangeVendor} /> -
+
Do you sell alcohol? handleOnChangeVendor(e)} + onChange={handleOnChangeVendor} /> @@ -169,11 +228,11 @@ export default function SignUp() { name="alcohol" value="false" checked={signUpStateVendor.alcohol === false} - onChange={(e) => handleOnChangeVendor(e)} + onChange={handleOnChangeVendor} /> -
+
-
+
Do you offer vegan options? handleOnChangeVendor(e)} + onChange={handleOnChangeVendor} /> @@ -192,15 +251,24 @@ export default function SignUp() { name="vegan" value="false" checked={signUpStateVendor.vegan === false} - onChange={(e) => handleOnChangeVendor(e)} + onChange={handleOnChangeVendor} /> -
- setIsVendor(true)}> - Sign Up - +
+ + Sign Up ) : ( <> + + +
What is your age group? @@ -210,7 +278,7 @@ export default function SignUp() { name="age" value="14-18" checked={signUpStateCustomer.age === "14-18"} - onChange={(e) => handleOnChangeCustomer(e)} + onChange={handleOnChangeCustomer} /> handleOnChangeCustomer(e)} + onChange={handleOnChangeCustomer} /> handleOnChangeCustomer(e)} + onChange={handleOnChangeCustomer} /> handleOnChangeCustomer(e)} + onChange={handleOnChangeCustomer} />
@@ -250,7 +318,7 @@ export default function SignUp() { name="gender" value="Male" checked={signUpStateCustomer.gender === "Male"} - onChange={(e) => handleOnChangeCustomer(e)} + onChange={handleOnChangeCustomer} /> handleOnChangeCustomer(e)} + onChange={handleOnChangeCustomer} /> handleOnChangeCustomer(e)} + onChange={handleOnChangeCustomer} /> handleOnChangeCustomer(e)} + onChange={handleOnChangeCustomer} /> @@ -288,7 +356,7 @@ export default function SignUp() { name="icecreamFlavour" required value={signUpStateCustomer.icecreamFlavour} - onChange={(e) => handleOnChangeCustomer(e)} + onChange={handleOnChangeCustomer} />
@@ -303,7 +371,7 @@ export default function SignUp() { name="consent" value="true" checked={signUpStateCustomer.consent === true} - onChange={(e) => handleOnChangeCustomer(e)} + onChange={handleOnChangeCustomer} /> handleOnChangeCustomer(e)} + onChange={handleOnChangeCustomer} />
- setIsVendor(false)}> - {signUpStateCustomer.consent && ( - Sign Up - )} - + + Sign Up )}
diff --git a/client-app/src/components/shared/user.js b/client-app/src/components/shared/user.js index c0980e9..04719da 100644 --- a/client-app/src/components/shared/user.js +++ b/client-app/src/components/shared/user.js @@ -1,40 +1,40 @@ //Second page (have chosen whether customer/vendor) - choice between login + signup -import React, { useContext } from "react" -import { Link } from "react-router-dom" -import { AppContext } from "../AppContext" -import { BlueButton, PinkButton } from "../../styles/buttons" +import React, { useContext } from "react"; +import { Link } from "react-router-dom"; +import { AppContext } from "../AppContext"; +import { BlueButton, PinkButton, PageContainer } from "../../styles/buttons"; export default function User() { - const { isVendor, setIsVendor } = useContext(AppContext) + const { isVendor, setIsVendor } = useContext(AppContext); return (
{isVendor ? ( -
-

Find ice cream lovers today

+ +

Find ice cream lovers today

setIsVendor(true)}> - Sign Up + Sign Up setIsVendor(true)}> - Log In + Log In -
+ ) : ( -
-

Find ice cream today

+ +

Find ice cream today

setIsVendor(false)}> - Sign Up + Sign Up setIsVendor(false)}> - Log In + Log In -
+ )}
- ) + ); } diff --git a/client-app/src/components/vendor/home.js b/client-app/src/components/vendor/home.js index a2f7696..0799a0e 100644 --- a/client-app/src/components/vendor/home.js +++ b/client-app/src/components/vendor/home.js @@ -1,11 +1,15 @@ // Home page for vendor - includes current route and links to add/ change route + see heatmap -import React from "react"; + +import React, { useContext } from "react"; import { Link } from "react-router-dom"; -import { PinkButton } from "../../styles/buttons"; +import { AppContext } from "../AppContext"; +import { PinkSmallButton, PageContainer } from "../../styles/buttons"; export default function Home() { const [routeName, setRouteName] = React.useState(""); + const { logInStatus, setLogInStatus } = useContext(AppContext); + function handleSubmit(event) { // PRINT THE SELECTED ROUTE // event.preventDefault(); @@ -23,60 +27,38 @@ export default function Home() { } return ( -
-

+ +

Welcome back name !

-

Today's route is:

+

Today's route is:

-
- - {/* Run displayOptions */} - +
-
+
-
-

Turn on alerts for customers

+
+

Turn on alerts for customers

-
- - - Edit Current Schedule - - - +
- - Create a New Schedule - + Create a New Schedule - - View Heatmap + + View Heatmap
-
+ ); } diff --git a/client-app/src/components/vendor/timetable.js b/client-app/src/components/vendor/timetable.js index a699e2d..7c5d652 100644 --- a/client-app/src/components/vendor/timetable.js +++ b/client-app/src/components/vendor/timetable.js @@ -1,114 +1,53 @@ import React, { useState } from "react"; +import { PinkButton, PageContainer } from "../../styles/buttons"; +import { Label, Input, FormContainer } from "../../styles/form"; export default function Timetable() { //Editing: fetch API - SELECT * FROM routes WHERE route_name == /whatever route name chosen // fill in form with data function generateNewRow(event) { event.preventDefault(); - const newRows = document.querySelector(".timetable-newRows"); + // const newRows = document.querySelector(".timetable-newRows"); return (
- - + + - - + + - - + +
); } return (
-
- - + + + - - + + - - + + - - + + - - + + - - + +
- - + Submit +
); } diff --git a/client-app/src/styles/buttons.js b/client-app/src/styles/buttons.js index 140ddbd..ba6e4e3 100644 --- a/client-app/src/styles/buttons.js +++ b/client-app/src/styles/buttons.js @@ -1,4 +1,5 @@ import styled from "styled-components"; +import { Link } from "react-router-dom"; const lightBlue = "#C3DDED"; const navy = "#1f4068"; @@ -6,25 +7,30 @@ const lightPink = "#F7DCD5"; const background = "#F7F4F0"; const Button = ` - width: 75%; - max-width: 250px; border-radius: 5px; color: ${navy}; - text-decoration: none; font-size: 2rem; padding: 0.25em 1em; margin-top: 2.5%; display: block; + width: 75vw; + max-width: 400px; `; -const BlueButton = styled.a` +const BlueButton = styled.button` ${Button} background-color: ${lightBlue} `; -const PinkButton = styled.a` - ${Button} +const PinkButton = styled.button` + ${Button}; + background-color: ${lightPink}; +`; + +const PinkSmallButton = styled.button` + ${Button}; background-color: ${lightPink}; + font-size: 1rem; `; const PageContainer = styled.section` @@ -34,11 +40,9 @@ const PageContainer = styled.section` align-items: center; height: 90vh; `; -/* - justify-content: center; - position: relative; - min-height: 90vh;*/ -//fix width of the buttons +const StyledLink = styled(Link)` + text-decoration: none; +`; -export { BlueButton, PinkButton, PageContainer }; +export { BlueButton, PinkButton, PinkSmallButton, PageContainer }; diff --git a/client-app/src/styles/form.js b/client-app/src/styles/form.js index 8e2c2c6..01c0a42 100644 --- a/client-app/src/styles/form.js +++ b/client-app/src/styles/form.js @@ -1,35 +1,42 @@ -import styled from "styled-components" +import styled from "styled-components"; -const background = "#F7F4F0" -const navy = "#1f4068" +const background = "#F7F4F0"; +const navy = "#1f4068"; const Label = styled.label` color: ${navy}; font-size: 1.25rem; text-align: left; margin-bottom: 0.45rem; -` +`; const Input = styled.input` background-color: ${background}; color: ${navy}; border-radius: 5px; margin-bottom: 0.2rem; - width: 240px; + width: 75%; + max-width: 500px; height: 31px; - justify-c: center; -` +`; const Legend = styled.legend` color: ${navy}; -` +`; const FormContainer = styled.form` display: flex; flex-direction: column; background-color: ${background}; -` + align-items: center; +`; -const radioBtnWrapper = styled.input`` +const radioBtnWrapper = styled.input``; -export { Label, Input, Legend, FormContainer } +const FieldSet = styled.fieldset` + border-radius: 5px; + width: 75%; + max-width: 250px; +`; + +export { Label, Input, Legend, FormContainer, FieldSet }; diff --git a/client-app/src/styles/header.js b/client-app/src/styles/header.js index 3100694..45a4823 100644 --- a/client-app/src/styles/header.js +++ b/client-app/src/styles/header.js @@ -19,14 +19,19 @@ const navy = "#1f4068"; const background = "#F7F4F0"; const Title = styled.h1` - width: 320px; - height: 80px; font-style: italic; color: ${navy}; + font-size: 2.5rem; + margin-bottom: 0; `; const HeaderArea = styled.header` background-color: ${background}; + display: flex; + flex-direction: column; + padding-bottom: 5%; `; -export { Title, HeaderArea }; +const LogInOption = styled.a``; + +export { Title, HeaderArea, LogInOption }; diff --git a/client-app/src/utils/getData.js b/client-app/src/utils/getData.js index b3d149a..edaca09 100644 --- a/client-app/src/utils/getData.js +++ b/client-app/src/utils/getData.js @@ -17,7 +17,13 @@ const getRequest = () => { }); }) .catch((err) => console.log(err)) - ); -}; + )}; + // : "https://where-is-whippy.herokuapp.com"; + +// const getRequest = (endpoint) => { +// return fetch(domain + endpoint) +// .then((res) => res.json()) +// .catch(console.log); +// }; export default getRequest; diff --git a/client-app/src/utils/postData.js b/client-app/src/utils/postData.js index 27c7d56..ef54d7f 100644 --- a/client-app/src/utils/postData.js +++ b/client-app/src/utils/postData.js @@ -1,32 +1,21 @@ -const hostname = window && window.location && window.location.hostname +const hostname = window && window.location && window.location.hostname; const domain = hostname === "localhost" ? "http://localhost:8080" - : "https://where-is-whippy.herokuapp.com" + : "https://where-is-whippy.herokuapp.com"; -// const postRequest = (endpoint) => { -// return fetch(domain + endpoint, { -// method: "post", -// data: JSON.stringify(data), -// }) -// .then((res) => res.json()) -// .catch(console.log) -// } - -// async function postSignUpInformation(state) { -// const response = await fetch(domain + "/customers/signup", { -// method: "POST", -// headers: { -// "Content-Type": "application/json", -// Accept: "application/json", -// }, -// body: JSON.stringify(state), -// }) -// console.log(await response.json()) -// return await response.json() -// } +const postObject = (state) => { + return { + method: "POST", + headers: { + "Content-Type": "application/json", + Accept: "application/json", + }, + body: JSON.stringify(state), + }; +}; -function postSignUpInformation(state) { +function postVendorSignUpInformation(state) { return fetch(domain + "/vendors/signup", { method: "POST", headers: { @@ -34,12 +23,45 @@ function postSignUpInformation(state) { Accept: "application/json", }, body: JSON.stringify(state), - }).then((res) => { - if (res.status !== 200) { - console.error("API responded with ", res.status) - } - return res.json() - }) + }); +} + +function postVendorLoginInformation(state) { + return fetch(domain + "/vendors/login", { + method: "POST", + headers: { + "Content-Type": "application/json", + Accept: "application/json", + }, + body: JSON.stringify(state), + }); +} + +function postCustomerSignUpInformation(state) { + return fetch(domain + "/customers/signup", { + method: "POST", + headers: { + "Content-Type": "application/json", + Accept: "application/json", + }, + body: JSON.stringify(state), + }); +} + +function postCustomerLoginInformation(state) { + return fetch(domain + "/customers/login", { + method: "POST", + headers: { + "Content-Type": "application/json", + Accept: "application/json", + }, + body: JSON.stringify(state), + }); } -export default postSignUpInformation +export { + postVendorSignUpInformation, + postCustomerSignUpInformation, + postVendorLoginInformation, + postCustomerLoginInformation, +}; diff --git a/package.json b/package.json index c5228e1..e21dd2d 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,6 @@ "husky": "^4.2.5" }, "dependencies": { - "jest": "^26.0.1", "lint-staged": "^10.2.6", "prettier": "^2.0.5", "pretty-quick": "^2.0.1" diff --git a/server-api/coverage/clover.xml b/server-api/coverage/clover.xml new file mode 100644 index 0000000..b7607aa --- /dev/null +++ b/server-api/coverage/clover.xml @@ -0,0 +1,293 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/server-api/coverage/coverage-final.json b/server-api/coverage/coverage-final.json new file mode 100644 index 0000000..3b4ac96 --- /dev/null +++ b/server-api/coverage/coverage-final.json @@ -0,0 +1,17 @@ +{"/home/joepock123/fac/student-project/week11-where-is-whippy/server-api/server.js": {"path":"/home/joepock123/fac/student-project/week11-where-is-whippy/server-api/server.js","statementMap":{"0":{"start":{"line":1,"column":16},"end":{"line":1,"column":34}},"1":{"start":{"line":2,"column":13},"end":{"line":2,"column":28}},"2":{"start":{"line":5,"column":33},"end":{"line":5,"column":74}},"3":{"start":{"line":6,"column":31},"end":{"line":6,"column":70}},"4":{"start":{"line":7,"column":28},"end":{"line":7,"column":65}},"5":{"start":{"line":8,"column":16},"end":{"line":8,"column":47}},"6":{"start":{"line":9,"column":18},"end":{"line":9,"column":51}},"7":{"start":{"line":12,"column":20},"end":{"line":12,"column":55}},"8":{"start":{"line":13,"column":15},"end":{"line":13,"column":45}},"9":{"start":{"line":14,"column":13},"end":{"line":14,"column":41}},"10":{"start":{"line":16,"column":15},"end":{"line":16,"column":24}},"11":{"start":{"line":17,"column":0},"end":{"line":17,"column":27}},"12":{"start":{"line":18,"column":0},"end":{"line":18,"column":19}},"13":{"start":{"line":21,"column":20},"end":{"line":26,"column":1}},"14":{"start":{"line":29,"column":0},"end":{"line":29,"column":30}},"15":{"start":{"line":35,"column":0},"end":{"line":35,"column":49}},"16":{"start":{"line":36,"column":0},"end":{"line":36,"column":79}},"17":{"start":{"line":37,"column":0},"end":{"line":37,"column":60}},"18":{"start":{"line":38,"column":0},"end":{"line":38,"column":43}},"19":{"start":{"line":39,"column":0},"end":{"line":39,"column":73}},"20":{"start":{"line":40,"column":0},"end":{"line":40,"column":54}},"21":{"start":{"line":41,"column":0},"end":{"line":41,"column":66}},"22":{"start":{"line":44,"column":0},"end":{"line":44,"column":59}},"23":{"start":{"line":45,"column":0},"end":{"line":45,"column":57}},"24":{"start":{"line":46,"column":0},"end":{"line":50,"column":2}},"25":{"start":{"line":52,"column":0},"end":{"line":52,"column":53}},"26":{"start":{"line":53,"column":0},"end":{"line":53,"column":51}},"27":{"start":{"line":54,"column":0},"end":{"line":58,"column":2}},"28":{"start":{"line":59,"column":0},"end":{"line":63,"column":2}},"29":{"start":{"line":71,"column":0},"end":{"line":71,"column":72}},"30":{"start":{"line":73,"column":0},"end":{"line":73,"column":24}},"31":{"start":{"line":75,"column":0},"end":{"line":75,"column":24}}},"fnMap":{},"branchMap":{"0":{"loc":{"start":{"line":23,"column":4},"end":{"line":25,"column":31}},"type":"cond-expr","locations":[{"start":{"line":24,"column":8},"end":{"line":24,"column":55}},{"start":{"line":25,"column":8},"end":{"line":25,"column":31}}],"line":23}},"s":{"0":4,"1":4,"2":4,"3":4,"4":4,"5":4,"6":4,"7":4,"8":4,"9":4,"10":4,"11":4,"12":4,"13":4,"14":4,"15":4,"16":4,"17":4,"18":4,"19":4,"20":4,"21":4,"22":4,"23":4,"24":4,"25":4,"26":4,"27":4,"28":4,"29":4,"30":4,"31":4},"f":{},"b":{"0":[0,4]},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"d0ae3930caa5fdd964f3f0151cd004425151f831"} +,"/home/joepock123/fac/student-project/week11-where-is-whippy/server-api/db/build.js": {"path":"/home/joepock123/fac/student-project/week11-where-is-whippy/server-api/db/build.js","statementMap":{"0":{"start":{"line":1,"column":13},"end":{"line":1,"column":28}},"1":{"start":{"line":2,"column":11},"end":{"line":2,"column":24}},"2":{"start":{"line":3,"column":11},"end":{"line":3,"column":34}},"3":{"start":{"line":5,"column":16},"end":{"line":5,"column":74}},"4":{"start":{"line":8,"column":2},"end":{"line":8,"column":26}},"5":{"start":{"line":13,"column":0},"end":{"line":17,"column":1}},"6":{"start":{"line":14,"column":2},"end":{"line":14,"column":91}},"7":{"start":{"line":15,"column":2},"end":{"line":15,"column":31}},"8":{"start":{"line":16,"column":2},"end":{"line":16,"column":9}},"9":{"start":{"line":19,"column":0},"end":{"line":19,"column":22}}},"fnMap":{"0":{"name":"build","decl":{"start":{"line":7,"column":9},"end":{"line":7,"column":14}},"loc":{"start":{"line":7,"column":17},"end":{"line":9,"column":1}},"line":7}},"branchMap":{"0":{"loc":{"start":{"line":13,"column":0},"end":{"line":17,"column":1}},"type":"if","locations":[{"start":{"line":13,"column":0},"end":{"line":17,"column":1}},{"start":{"line":13,"column":0},"end":{"line":17,"column":1}}],"line":13}},"s":{"0":4,"1":4,"2":4,"3":4,"4":11,"5":4,"6":0,"7":0,"8":0,"9":4},"f":{"0":11},"b":{"0":[0,4]},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"06a3614db3ff61f038ca9875c39ee9a9fdffdd0f"} +,"/home/joepock123/fac/student-project/week11-where-is-whippy/server-api/db/connection.js": {"path":"/home/joepock123/fac/student-project/week11-where-is-whippy/server-api/db/connection.js","statementMap":{"0":{"start":{"line":1,"column":11},"end":{"line":1,"column":24}},"1":{"start":{"line":2,"column":16},"end":{"line":2,"column":33}},"2":{"start":{"line":3,"column":0},"end":{"line":3,"column":16}},"3":{"start":{"line":5,"column":11},"end":{"line":8,"column":2}},"4":{"start":{"line":10,"column":0},"end":{"line":10,"column":19}}},"fnMap":{},"branchMap":{},"s":{"0":4,"1":4,"2":4,"3":4,"4":4},"f":{},"b":{},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"689c68d2c0224a9d548d5762564fb80b3dd6c2f1"} +,"/home/joepock123/fac/student-project/week11-where-is-whippy/server-api/handlers/customer-location-h.js": {"path":"/home/joepock123/fac/student-project/week11-where-is-whippy/server-api/handlers/customer-location-h.js","statementMap":{"0":{"start":{"line":1,"column":14},"end":{"line":1,"column":53}},"1":{"start":{"line":6,"column":2},"end":{"line":11,"column":16}},"2":{"start":{"line":9,"column":6},"end":{"line":9,"column":28}},"3":{"start":{"line":15,"column":21},"end":{"line":15,"column":40}},"4":{"start":{"line":16,"column":14},"end":{"line":16,"column":31}},"5":{"start":{"line":17,"column":14},"end":{"line":17,"column":32}},"6":{"start":{"line":18,"column":15},"end":{"line":18,"column":35}},"7":{"start":{"line":20,"column":2},"end":{"line":26,"column":16}},"8":{"start":{"line":23,"column":6},"end":{"line":23,"column":28}},"9":{"start":{"line":24,"column":6},"end":{"line":24,"column":33}},"10":{"start":{"line":44,"column":0},"end":{"line":47,"column":1}}},"fnMap":{"0":{"name":"allCustomerLocations","decl":{"start":{"line":4,"column":9},"end":{"line":4,"column":29}},"loc":{"start":{"line":4,"column":46},"end":{"line":12,"column":1}},"line":4},"1":{"name":"(anonymous_1)","decl":{"start":{"line":8,"column":10},"end":{"line":8,"column":11}},"loc":{"start":{"line":8,"column":28},"end":{"line":10,"column":5}},"line":8},"2":{"name":"addNewCustomerLocation","decl":{"start":{"line":14,"column":9},"end":{"line":14,"column":31}},"loc":{"start":{"line":14,"column":48},"end":{"line":27,"column":1}},"line":14},"3":{"name":"(anonymous_3)","decl":{"start":{"line":22,"column":10},"end":{"line":22,"column":11}},"loc":{"start":{"line":22,"column":25},"end":{"line":25,"column":5}},"line":22}},"branchMap":{},"s":{"0":4,"1":1,"2":1,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":4},"f":{"0":1,"1":1,"2":0,"3":0},"b":{},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"18e374aa909ec906624ed5adf6f8ceb0bb29fd77"} +,"/home/joepock123/fac/student-project/week11-where-is-whippy/server-api/handlers/customers-h.js": {"path":"/home/joepock123/fac/student-project/week11-where-is-whippy/server-api/handlers/customers-h.js","statementMap":{"0":{"start":{"line":1,"column":12},"end":{"line":1,"column":35}},"1":{"start":{"line":2,"column":15},"end":{"line":2,"column":32}},"2":{"start":{"line":3,"column":15},"end":{"line":3,"column":32}},"3":{"start":{"line":5,"column":0},"end":{"line":5,"column":15}},"4":{"start":{"line":6,"column":15},"end":{"line":6,"column":37}},"5":{"start":{"line":8,"column":18},"end":{"line":8,"column":49}},"6":{"start":{"line":11,"column":2},"end":{"line":16,"column":16}},"7":{"start":{"line":14,"column":6},"end":{"line":14,"column":28}},"8":{"start":{"line":20,"column":22},"end":{"line":28,"column":3}},"9":{"start":{"line":30,"column":2},"end":{"line":42,"column":16}},"10":{"start":{"line":32,"column":20},"end":{"line":32,"column":56}},"11":{"start":{"line":34,"column":6},"end":{"line":34,"column":66}},"12":{"start":{"line":37,"column":20},"end":{"line":39,"column":8}},"13":{"start":{"line":40,"column":6},"end":{"line":40,"column":51}},"14":{"start":{"line":46,"column":16},"end":{"line":46,"column":30}},"15":{"start":{"line":47,"column":19},"end":{"line":47,"column":36}},"16":{"start":{"line":49,"column":2},"end":{"line":67,"column":16}},"17":{"start":{"line":52,"column":6},"end":{"line":65,"column":8}},"18":{"start":{"line":53,"column":8},"end":{"line":64,"column":9}},"19":{"start":{"line":54,"column":24},"end":{"line":56,"column":11}},"20":{"start":{"line":57,"column":10},"end":{"line":57,"column":28}},"21":{"start":{"line":58,"column":10},"end":{"line":58,"column":21}},"22":{"start":{"line":60,"column":24},"end":{"line":62,"column":12}},"23":{"start":{"line":63,"column":10},"end":{"line":63,"column":55}},"24":{"start":{"line":71,"column":21},"end":{"line":71,"column":34}},"25":{"start":{"line":72,"column":2},"end":{"line":77,"column":16}},"26":{"start":{"line":75,"column":6},"end":{"line":75,"column":32}},"27":{"start":{"line":80,"column":0},"end":{"line":85,"column":1}}},"fnMap":{"0":{"name":"allCustomers","decl":{"start":{"line":10,"column":9},"end":{"line":10,"column":21}},"loc":{"start":{"line":10,"column":38},"end":{"line":17,"column":1}},"line":10},"1":{"name":"(anonymous_1)","decl":{"start":{"line":13,"column":10},"end":{"line":13,"column":11}},"loc":{"start":{"line":13,"column":28},"end":{"line":15,"column":5}},"line":13},"2":{"name":"createCustomer","decl":{"start":{"line":19,"column":9},"end":{"line":19,"column":23}},"loc":{"start":{"line":19,"column":40},"end":{"line":43,"column":1}},"line":19},"3":{"name":"(anonymous_3)","decl":{"start":{"line":32,"column":10},"end":{"line":32,"column":11}},"loc":{"start":{"line":32,"column":20},"end":{"line":32,"column":56}},"line":32},"4":{"name":"(anonymous_4)","decl":{"start":{"line":33,"column":10},"end":{"line":33,"column":11}},"loc":{"start":{"line":34,"column":6},"end":{"line":34,"column":66}},"line":34},"5":{"name":"(anonymous_5)","decl":{"start":{"line":36,"column":10},"end":{"line":36,"column":11}},"loc":{"start":{"line":36,"column":24},"end":{"line":41,"column":5}},"line":36},"6":{"name":"loginCustomer","decl":{"start":{"line":45,"column":9},"end":{"line":45,"column":22}},"loc":{"start":{"line":45,"column":39},"end":{"line":68,"column":1}},"line":45},"7":{"name":"(anonymous_7)","decl":{"start":{"line":51,"column":10},"end":{"line":51,"column":11}},"loc":{"start":{"line":51,"column":24},"end":{"line":66,"column":5}},"line":51},"8":{"name":"(anonymous_8)","decl":{"start":{"line":52,"column":55},"end":{"line":52,"column":56}},"loc":{"start":{"line":52,"column":66},"end":{"line":65,"column":7}},"line":52},"9":{"name":"getSpecificCustomer","decl":{"start":{"line":70,"column":9},"end":{"line":70,"column":28}},"loc":{"start":{"line":70,"column":45},"end":{"line":78,"column":1}},"line":70},"10":{"name":"(anonymous_10)","decl":{"start":{"line":74,"column":10},"end":{"line":74,"column":11}},"loc":{"start":{"line":74,"column":32},"end":{"line":76,"column":5}},"line":74}},"branchMap":{"0":{"loc":{"start":{"line":53,"column":8},"end":{"line":64,"column":9}},"type":"if","locations":[{"start":{"line":53,"column":8},"end":{"line":64,"column":9}},{"start":{"line":53,"column":8},"end":{"line":64,"column":9}}],"line":53}},"s":{"0":4,"1":4,"2":4,"3":4,"4":4,"5":4,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":4},"f":{"0":0,"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0},"b":{"0":[0,0]},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"972aa8bda3beacedcc7ee197e798d13f82957a00"} +,"/home/joepock123/fac/student-project/week11-where-is-whippy/server-api/handlers/vendor-location-h.js": {"path":"/home/joepock123/fac/student-project/week11-where-is-whippy/server-api/handlers/vendor-location-h.js","statementMap":{"0":{"start":{"line":1,"column":14},"end":{"line":1,"column":51}},"1":{"start":{"line":4,"column":2},"end":{"line":9,"column":16}},"2":{"start":{"line":7,"column":6},"end":{"line":7,"column":28}},"3":{"start":{"line":13,"column":19},"end":{"line":13,"column":36}},"4":{"start":{"line":14,"column":14},"end":{"line":14,"column":31}},"5":{"start":{"line":15,"column":14},"end":{"line":15,"column":32}},"6":{"start":{"line":17,"column":2},"end":{"line":22,"column":16}},"7":{"start":{"line":20,"column":6},"end":{"line":20,"column":33}},"8":{"start":{"line":25,"column":0},"end":{"line":25,"column":61}}},"fnMap":{"0":{"name":"allVendorLocations","decl":{"start":{"line":3,"column":9},"end":{"line":3,"column":27}},"loc":{"start":{"line":3,"column":44},"end":{"line":10,"column":1}},"line":3},"1":{"name":"(anonymous_1)","decl":{"start":{"line":6,"column":10},"end":{"line":6,"column":11}},"loc":{"start":{"line":6,"column":28},"end":{"line":8,"column":5}},"line":6},"2":{"name":"addNewVendorLocation","decl":{"start":{"line":12,"column":9},"end":{"line":12,"column":29}},"loc":{"start":{"line":12,"column":46},"end":{"line":23,"column":1}},"line":12},"3":{"name":"(anonymous_3)","decl":{"start":{"line":19,"column":10},"end":{"line":19,"column":11}},"loc":{"start":{"line":19,"column":25},"end":{"line":21,"column":5}},"line":19}},"branchMap":{},"s":{"0":4,"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":4},"f":{"0":0,"1":0,"2":0,"3":0},"b":{},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"491521fc795d6238464d56da7a03a98c6ad28669"} +,"/home/joepock123/fac/student-project/week11-where-is-whippy/server-api/handlers/vendor-routes-h.js": {"path":"/home/joepock123/fac/student-project/week11-where-is-whippy/server-api/handlers/vendor-routes-h.js","statementMap":{"0":{"start":{"line":1,"column":14},"end":{"line":1,"column":49}},"1":{"start":{"line":4,"column":2},"end":{"line":23,"column":4}},"2":{"start":{"line":5,"column":4},"end":{"line":22,"column":5}},"3":{"start":{"line":6,"column":6},"end":{"line":6,"column":71}},"4":{"start":{"line":8,"column":25},"end":{"line":10,"column":8}},"5":{"start":{"line":9,"column":8},"end":{"line":9,"column":44}},"6":{"start":{"line":16,"column":6},"end":{"line":21,"column":20}},"7":{"start":{"line":18,"column":32},"end":{"line":18,"column":78}},"8":{"start":{"line":18,"column":63},"end":{"line":18,"column":77}},"9":{"start":{"line":19,"column":10},"end":{"line":19,"column":47}},"10":{"start":{"line":27,"column":20},"end":{"line":27,"column":35}},"11":{"start":{"line":29,"column":2},"end":{"line":34,"column":16}},"12":{"start":{"line":32,"column":6},"end":{"line":32,"column":24}},"13":{"start":{"line":38,"column":20},"end":{"line":38,"column":35}},"14":{"start":{"line":39,"column":2},"end":{"line":42,"column":16}},"15":{"start":{"line":41,"column":22},"end":{"line":41,"column":41}},"16":{"start":{"line":45,"column":0},"end":{"line":45,"column":58}}},"fnMap":{"0":{"name":"createNewRoute","decl":{"start":{"line":3,"column":9},"end":{"line":3,"column":23}},"loc":{"start":{"line":3,"column":40},"end":{"line":24,"column":1}},"line":3},"1":{"name":"(anonymous_1)","decl":{"start":{"line":4,"column":60},"end":{"line":4,"column":61}},"loc":{"start":{"line":4,"column":73},"end":{"line":23,"column":3}},"line":4},"2":{"name":"(anonymous_2)","decl":{"start":{"line":8,"column":38},"end":{"line":8,"column":39}},"loc":{"start":{"line":8,"column":47},"end":{"line":10,"column":7}},"line":8},"3":{"name":"(anonymous_3)","decl":{"start":{"line":17,"column":14},"end":{"line":17,"column":15}},"loc":{"start":{"line":17,"column":34},"end":{"line":20,"column":9}},"line":17},"4":{"name":"(anonymous_4)","decl":{"start":{"line":18,"column":51},"end":{"line":18,"column":52}},"loc":{"start":{"line":18,"column":63},"end":{"line":18,"column":77}},"line":18},"5":{"name":"getRoute","decl":{"start":{"line":26,"column":9},"end":{"line":26,"column":17}},"loc":{"start":{"line":26,"column":34},"end":{"line":35,"column":1}},"line":26},"6":{"name":"(anonymous_6)","decl":{"start":{"line":31,"column":10},"end":{"line":31,"column":11}},"loc":{"start":{"line":31,"column":24},"end":{"line":33,"column":5}},"line":31},"7":{"name":"deleteRoute","decl":{"start":{"line":37,"column":9},"end":{"line":37,"column":20}},"loc":{"start":{"line":37,"column":37},"end":{"line":43,"column":1}},"line":37},"8":{"name":"(anonymous_8)","decl":{"start":{"line":41,"column":10},"end":{"line":41,"column":11}},"loc":{"start":{"line":41,"column":22},"end":{"line":41,"column":41}},"line":41}},"branchMap":{"0":{"loc":{"start":{"line":5,"column":4},"end":{"line":22,"column":5}},"type":"if","locations":[{"start":{"line":5,"column":4},"end":{"line":22,"column":5}},{"start":{"line":5,"column":4},"end":{"line":22,"column":5}}],"line":5}},"s":{"0":4,"1":1,"2":1,"3":0,"4":1,"5":3,"6":1,"7":1,"8":3,"9":1,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":4},"f":{"0":1,"1":1,"2":3,"3":1,"4":3,"5":0,"6":0,"7":0,"8":0},"b":{"0":[0,1]},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"d3149a78fa8793427a1cec19f22126405aebcf2c"} +,"/home/joepock123/fac/student-project/week11-where-is-whippy/server-api/handlers/vendors-h.js": {"path":"/home/joepock123/fac/student-project/week11-where-is-whippy/server-api/handlers/vendors-h.js","statementMap":{"0":{"start":{"line":1,"column":12},"end":{"line":1,"column":35}},"1":{"start":{"line":2,"column":15},"end":{"line":2,"column":32}},"2":{"start":{"line":3,"column":15},"end":{"line":3,"column":32}},"3":{"start":{"line":5,"column":0},"end":{"line":5,"column":15}},"4":{"start":{"line":6,"column":15},"end":{"line":6,"column":37}},"5":{"start":{"line":8,"column":16},"end":{"line":8,"column":45}},"6":{"start":{"line":11,"column":2},"end":{"line":16,"column":16}},"7":{"start":{"line":14,"column":6},"end":{"line":14,"column":26}},"8":{"start":{"line":20,"column":19},"end":{"line":20,"column":32}},"9":{"start":{"line":21,"column":2},"end":{"line":24,"column":16}},"10":{"start":{"line":23,"column":22},"end":{"line":23,"column":38}},"11":{"start":{"line":28,"column":20},"end":{"line":36,"column":3}},"12":{"start":{"line":38,"column":2},"end":{"line":48,"column":16}},"13":{"start":{"line":40,"column":20},"end":{"line":40,"column":56}},"14":{"start":{"line":41,"column":20},"end":{"line":41,"column":74}},"15":{"start":{"line":43,"column":20},"end":{"line":45,"column":8}},"16":{"start":{"line":46,"column":6},"end":{"line":46,"column":51}},"17":{"start":{"line":52,"column":16},"end":{"line":52,"column":30}},"18":{"start":{"line":53,"column":19},"end":{"line":53,"column":36}},"19":{"start":{"line":55,"column":2},"end":{"line":71,"column":16}},"20":{"start":{"line":58,"column":6},"end":{"line":69,"column":8}},"21":{"start":{"line":59,"column":8},"end":{"line":68,"column":9}},"22":{"start":{"line":60,"column":24},"end":{"line":60,"column":49}},"23":{"start":{"line":61,"column":10},"end":{"line":61,"column":28}},"24":{"start":{"line":62,"column":10},"end":{"line":62,"column":21}},"25":{"start":{"line":64,"column":24},"end":{"line":66,"column":12}},"26":{"start":{"line":67,"column":10},"end":{"line":67,"column":55}},"27":{"start":{"line":74,"column":0},"end":{"line":74,"column":77}}},"fnMap":{"0":{"name":"allVendors","decl":{"start":{"line":10,"column":9},"end":{"line":10,"column":19}},"loc":{"start":{"line":10,"column":36},"end":{"line":17,"column":1}},"line":10},"1":{"name":"(anonymous_1)","decl":{"start":{"line":13,"column":10},"end":{"line":13,"column":11}},"loc":{"start":{"line":13,"column":26},"end":{"line":15,"column":5}},"line":13},"2":{"name":"getSpecificVendor","decl":{"start":{"line":19,"column":9},"end":{"line":19,"column":26}},"loc":{"start":{"line":19,"column":43},"end":{"line":25,"column":1}},"line":19},"3":{"name":"(anonymous_3)","decl":{"start":{"line":23,"column":10},"end":{"line":23,"column":11}},"loc":{"start":{"line":23,"column":22},"end":{"line":23,"column":38}},"line":23},"4":{"name":"createVendor","decl":{"start":{"line":27,"column":9},"end":{"line":27,"column":21}},"loc":{"start":{"line":27,"column":38},"end":{"line":49,"column":1}},"line":27},"5":{"name":"(anonymous_5)","decl":{"start":{"line":40,"column":10},"end":{"line":40,"column":11}},"loc":{"start":{"line":40,"column":20},"end":{"line":40,"column":56}},"line":40},"6":{"name":"(anonymous_6)","decl":{"start":{"line":41,"column":10},"end":{"line":41,"column":11}},"loc":{"start":{"line":41,"column":20},"end":{"line":41,"column":74}},"line":41},"7":{"name":"(anonymous_7)","decl":{"start":{"line":42,"column":10},"end":{"line":42,"column":11}},"loc":{"start":{"line":42,"column":25},"end":{"line":47,"column":5}},"line":42},"8":{"name":"loginVendor","decl":{"start":{"line":51,"column":9},"end":{"line":51,"column":20}},"loc":{"start":{"line":51,"column":37},"end":{"line":72,"column":1}},"line":51},"9":{"name":"(anonymous_9)","decl":{"start":{"line":57,"column":10},"end":{"line":57,"column":11}},"loc":{"start":{"line":57,"column":22},"end":{"line":70,"column":5}},"line":57},"10":{"name":"(anonymous_10)","decl":{"start":{"line":58,"column":53},"end":{"line":58,"column":54}},"loc":{"start":{"line":58,"column":64},"end":{"line":69,"column":7}},"line":58}},"branchMap":{"0":{"loc":{"start":{"line":59,"column":8},"end":{"line":68,"column":9}},"type":"if","locations":[{"start":{"line":59,"column":8},"end":{"line":68,"column":9}},{"start":{"line":59,"column":8},"end":{"line":68,"column":9}}],"line":59}},"s":{"0":4,"1":4,"2":4,"3":4,"4":4,"5":4,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":4},"f":{"0":0,"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0},"b":{"0":[0,0]},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"41c9b3c260b4b29fe895ceb945f00b7ac7e61c01"} +,"/home/joepock123/fac/student-project/week11-where-is-whippy/server-api/middleware/auth.js": {"path":"/home/joepock123/fac/student-project/week11-where-is-whippy/server-api/middleware/auth.js","statementMap":{"0":{"start":{"line":1,"column":12},"end":{"line":1,"column":35}},"1":{"start":{"line":2,"column":22},"end":{"line":2,"column":53}},"2":{"start":{"line":3,"column":20},"end":{"line":3,"column":49}},"3":{"start":{"line":5,"column":0},"end":{"line":5,"column":26}},"4":{"start":{"line":7,"column":15},"end":{"line":7,"column":37}},"5":{"start":{"line":10,"column":21},"end":{"line":10,"column":46}},"6":{"start":{"line":11,"column":2},"end":{"line":15,"column":3}},"7":{"start":{"line":12,"column":18},"end":{"line":12,"column":60}},"8":{"start":{"line":13,"column":4},"end":{"line":13,"column":22}},"9":{"start":{"line":14,"column":4},"end":{"line":14,"column":15}},"10":{"start":{"line":16,"column":16},"end":{"line":16,"column":49}},"11":{"start":{"line":17,"column":2},"end":{"line":31,"column":3}},"12":{"start":{"line":18,"column":17},"end":{"line":18,"column":42}},"13":{"start":{"line":19,"column":4},"end":{"line":19,"column":21}},"14":{"start":{"line":20,"column":4},"end":{"line":26,"column":18}},"15":{"start":{"line":23,"column":8},"end":{"line":23,"column":23}},"16":{"start":{"line":24,"column":8},"end":{"line":24,"column":14}},"17":{"start":{"line":28,"column":18},"end":{"line":28,"column":43}},"18":{"start":{"line":29,"column":4},"end":{"line":29,"column":22}},"19":{"start":{"line":30,"column":4},"end":{"line":30,"column":15}},"20":{"start":{"line":35,"column":21},"end":{"line":35,"column":46}},"21":{"start":{"line":36,"column":2},"end":{"line":36,"column":41}},"22":{"start":{"line":37,"column":2},"end":{"line":41,"column":3}},"23":{"start":{"line":38,"column":18},"end":{"line":38,"column":60}},"24":{"start":{"line":39,"column":4},"end":{"line":39,"column":22}},"25":{"start":{"line":40,"column":4},"end":{"line":40,"column":15}},"26":{"start":{"line":42,"column":16},"end":{"line":42,"column":49}},"27":{"start":{"line":43,"column":2},"end":{"line":57,"column":3}},"28":{"start":{"line":44,"column":17},"end":{"line":44,"column":42}},"29":{"start":{"line":45,"column":4},"end":{"line":45,"column":30}},"30":{"start":{"line":46,"column":4},"end":{"line":52,"column":18}},"31":{"start":{"line":49,"column":8},"end":{"line":49,"column":23}},"32":{"start":{"line":50,"column":8},"end":{"line":50,"column":14}},"33":{"start":{"line":54,"column":18},"end":{"line":54,"column":43}},"34":{"start":{"line":55,"column":4},"end":{"line":55,"column":22}},"35":{"start":{"line":56,"column":4},"end":{"line":56,"column":15}},"36":{"start":{"line":60,"column":0},"end":{"line":60,"column":49}}},"fnMap":{"0":{"name":"verifyCustomer","decl":{"start":{"line":9,"column":9},"end":{"line":9,"column":23}},"loc":{"start":{"line":9,"column":40},"end":{"line":32,"column":1}},"line":9},"1":{"name":"(anonymous_1)","decl":{"start":{"line":22,"column":12},"end":{"line":22,"column":13}},"loc":{"start":{"line":22,"column":22},"end":{"line":25,"column":7}},"line":22},"2":{"name":"verifyVendor","decl":{"start":{"line":34,"column":9},"end":{"line":34,"column":21}},"loc":{"start":{"line":34,"column":38},"end":{"line":58,"column":1}},"line":34},"3":{"name":"(anonymous_3)","decl":{"start":{"line":48,"column":12},"end":{"line":48,"column":13}},"loc":{"start":{"line":48,"column":22},"end":{"line":51,"column":7}},"line":48}},"branchMap":{"0":{"loc":{"start":{"line":11,"column":2},"end":{"line":15,"column":3}},"type":"if","locations":[{"start":{"line":11,"column":2},"end":{"line":15,"column":3}},{"start":{"line":11,"column":2},"end":{"line":15,"column":3}}],"line":11},"1":{"loc":{"start":{"line":37,"column":2},"end":{"line":41,"column":3}},"type":"if","locations":[{"start":{"line":37,"column":2},"end":{"line":41,"column":3}},{"start":{"line":37,"column":2},"end":{"line":41,"column":3}}],"line":37}},"s":{"0":4,"1":4,"2":4,"3":4,"4":4,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":4},"f":{"0":0,"1":0,"2":0,"3":0},"b":{"0":[0,0],"1":[0,0]},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"467b1c9597b5e15e284c6bbc0e506035a49581a8"} +,"/home/joepock123/fac/student-project/week11-where-is-whippy/server-api/middleware/handleError.js": {"path":"/home/joepock123/fac/student-project/week11-where-is-whippy/server-api/middleware/handleError.js","statementMap":{"0":{"start":{"line":1,"column":25},"end":{"line":1,"column":40}},"1":{"start":{"line":5,"column":2},"end":{"line":5,"column":22}},"2":{"start":{"line":6,"column":17},"end":{"line":6,"column":36}},"3":{"start":{"line":7,"column":2},"end":{"line":7,"column":20}},"4":{"start":{"line":8,"column":18},"end":{"line":8,"column":38}},"5":{"start":{"line":9,"column":2},"end":{"line":17,"column":3}},"6":{"start":{"line":10,"column":4},"end":{"line":10,"column":32}},"7":{"start":{"line":12,"column":23},"end":{"line":12,"column":73}},"8":{"start":{"line":12,"column":61},"end":{"line":12,"column":72}},"9":{"start":{"line":13,"column":4},"end":{"line":16,"column":6}},"10":{"start":{"line":20,"column":0},"end":{"line":20,"column":28}}},"fnMap":{"0":{"name":"handleError","decl":{"start":{"line":4,"column":9},"end":{"line":4,"column":20}},"loc":{"start":{"line":4,"column":44},"end":{"line":18,"column":1}},"line":4},"1":{"name":"(anonymous_1)","decl":{"start":{"line":12,"column":51},"end":{"line":12,"column":52}},"loc":{"start":{"line":12,"column":61},"end":{"line":12,"column":72}},"line":12}},"branchMap":{"0":{"loc":{"start":{"line":6,"column":17},"end":{"line":6,"column":36}},"type":"binary-expr","locations":[{"start":{"line":6,"column":17},"end":{"line":6,"column":29}},{"start":{"line":6,"column":33},"end":{"line":6,"column":36}}],"line":6},"1":{"loc":{"start":{"line":9,"column":2},"end":{"line":17,"column":3}},"type":"if","locations":[{"start":{"line":9,"column":2},"end":{"line":17,"column":3}},{"start":{"line":9,"column":2},"end":{"line":17,"column":3}}],"line":9}},"s":{"0":4,"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":4},"f":{"0":0,"1":0},"b":{"0":[0,0],"1":[0,0]},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"ed93248ada80003cb498ee7d541aa688747f8b80"} +,"/home/joepock123/fac/student-project/week11-where-is-whippy/server-api/middleware/logger.js": {"path":"/home/joepock123/fac/student-project/week11-where-is-whippy/server-api/middleware/logger.js","statementMap":{"0":{"start":{"line":2,"column":15},"end":{"line":2,"column":46}},"1":{"start":{"line":3,"column":2},"end":{"line":3,"column":49}},"2":{"start":{"line":4,"column":2},"end":{"line":4,"column":8}},"3":{"start":{"line":7,"column":0},"end":{"line":7,"column":23}}},"fnMap":{"0":{"name":"logger","decl":{"start":{"line":1,"column":9},"end":{"line":1,"column":15}},"loc":{"start":{"line":1,"column":32},"end":{"line":5,"column":1}},"line":1}},"branchMap":{},"s":{"0":2,"1":2,"2":2,"3":4},"f":{"0":2},"b":{},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"a6c728efeeb8a17aa73069ad311a4aa5d4287214"} +,"/home/joepock123/fac/student-project/week11-where-is-whippy/server-api/model/customer-location-m.js": {"path":"/home/joepock123/fac/student-project/week11-where-is-whippy/server-api/model/customer-location-m.js","statementMap":{"0":{"start":{"line":1,"column":11},"end":{"line":1,"column":38}},"1":{"start":{"line":4,"column":2},"end":{"line":6,"column":36}},"2":{"start":{"line":6,"column":23},"end":{"line":6,"column":35}},"3":{"start":{"line":10,"column":2},"end":{"line":13,"column":3}},"4":{"start":{"line":16,"column":0},"end":{"line":16,"column":68}}},"fnMap":{"0":{"name":"getAllCustomerLocations","decl":{"start":{"line":3,"column":9},"end":{"line":3,"column":32}},"loc":{"start":{"line":3,"column":35},"end":{"line":7,"column":1}},"line":3},"1":{"name":"(anonymous_1)","decl":{"start":{"line":6,"column":10},"end":{"line":6,"column":11}},"loc":{"start":{"line":6,"column":23},"end":{"line":6,"column":35}},"line":6},"2":{"name":"addNewCustomerLocation","decl":{"start":{"line":9,"column":9},"end":{"line":9,"column":31}},"loc":{"start":{"line":9,"column":78},"end":{"line":14,"column":1}},"line":9}},"branchMap":{},"s":{"0":4,"1":4,"2":4,"3":1,"4":4},"f":{"0":4,"1":4,"2":1},"b":{},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"373da34763c91f5b2c60468afcdb602d8f05a8cd"} +,"/home/joepock123/fac/student-project/week11-where-is-whippy/server-api/model/customers-m.js": {"path":"/home/joepock123/fac/student-project/week11-where-is-whippy/server-api/model/customers-m.js","statementMap":{"0":{"start":{"line":1,"column":11},"end":{"line":1,"column":38}},"1":{"start":{"line":4,"column":2},"end":{"line":4,"column":77}},"2":{"start":{"line":4,"column":64},"end":{"line":4,"column":76}},"3":{"start":{"line":8,"column":2},"end":{"line":8,"column":44}},"4":{"start":{"line":9,"column":2},"end":{"line":12,"column":28}},"5":{"start":{"line":11,"column":20},"end":{"line":11,"column":32}},"6":{"start":{"line":12,"column":22},"end":{"line":12,"column":27}},"7":{"start":{"line":16,"column":2},"end":{"line":18,"column":33}},"8":{"start":{"line":18,"column":20},"end":{"line":18,"column":32}},"9":{"start":{"line":22,"column":2},"end":{"line":33,"column":3}},"10":{"start":{"line":36,"column":0},"end":{"line":41,"column":1}}},"fnMap":{"0":{"name":"getAllCustomers","decl":{"start":{"line":3,"column":9},"end":{"line":3,"column":24}},"loc":{"start":{"line":3,"column":27},"end":{"line":5,"column":1}},"line":3},"1":{"name":"(anonymous_1)","decl":{"start":{"line":4,"column":51},"end":{"line":4,"column":52}},"loc":{"start":{"line":4,"column":64},"end":{"line":4,"column":76}},"line":4},"2":{"name":"getCustomer","decl":{"start":{"line":7,"column":9},"end":{"line":7,"column":20}},"loc":{"start":{"line":7,"column":28},"end":{"line":13,"column":1}},"line":7},"3":{"name":"(anonymous_3)","decl":{"start":{"line":11,"column":10},"end":{"line":11,"column":11}},"loc":{"start":{"line":11,"column":20},"end":{"line":11,"column":32}},"line":11},"4":{"name":"(anonymous_4)","decl":{"start":{"line":12,"column":11},"end":{"line":12,"column":12}},"loc":{"start":{"line":12,"column":22},"end":{"line":12,"column":27}},"line":12},"5":{"name":"getSpecificCustomer","decl":{"start":{"line":15,"column":9},"end":{"line":15,"column":28}},"loc":{"start":{"line":15,"column":33},"end":{"line":19,"column":1}},"line":15},"6":{"name":"(anonymous_6)","decl":{"start":{"line":18,"column":10},"end":{"line":18,"column":11}},"loc":{"start":{"line":18,"column":20},"end":{"line":18,"column":32}},"line":18},"7":{"name":"createCustomer","decl":{"start":{"line":21,"column":9},"end":{"line":21,"column":23}},"loc":{"start":{"line":21,"column":37},"end":{"line":34,"column":1}},"line":21}},"branchMap":{},"s":{"0":4,"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":4},"f":{"0":0,"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0},"b":{},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"1579e04a205b9b96618aec5ba18accb782ac3a27"} +,"/home/joepock123/fac/student-project/week11-where-is-whippy/server-api/model/vendor-location-m.js": {"path":"/home/joepock123/fac/student-project/week11-where-is-whippy/server-api/model/vendor-location-m.js","statementMap":{"0":{"start":{"line":1,"column":11},"end":{"line":1,"column":38}},"1":{"start":{"line":4,"column":2},"end":{"line":6,"column":34}},"2":{"start":{"line":6,"column":22},"end":{"line":6,"column":33}},"3":{"start":{"line":10,"column":2},"end":{"line":13,"column":3}},"4":{"start":{"line":16,"column":0},"end":{"line":16,"column":64}}},"fnMap":{"0":{"name":"getAllVendorLocations","decl":{"start":{"line":3,"column":9},"end":{"line":3,"column":30}},"loc":{"start":{"line":3,"column":33},"end":{"line":7,"column":1}},"line":3},"1":{"name":"(anonymous_1)","decl":{"start":{"line":6,"column":10},"end":{"line":6,"column":11}},"loc":{"start":{"line":6,"column":22},"end":{"line":6,"column":33}},"line":6},"2":{"name":"addNewVendorLocation","decl":{"start":{"line":9,"column":9},"end":{"line":9,"column":29}},"loc":{"start":{"line":9,"column":61},"end":{"line":14,"column":1}},"line":9}},"branchMap":{},"s":{"0":4,"1":0,"2":0,"3":0,"4":4},"f":{"0":0,"1":0,"2":0},"b":{},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"6450ce1352d1fcd51810d5630dd001f25ad7030b"} +,"/home/joepock123/fac/student-project/week11-where-is-whippy/server-api/model/vendor-routes-m.js": {"path":"/home/joepock123/fac/student-project/week11-where-is-whippy/server-api/model/vendor-routes-m.js","statementMap":{"0":{"start":{"line":1,"column":11},"end":{"line":1,"column":38}},"1":{"start":{"line":4,"column":2},"end":{"line":14,"column":3}},"2":{"start":{"line":18,"column":2},"end":{"line":23,"column":36}},"3":{"start":{"line":23,"column":23},"end":{"line":23,"column":35}},"4":{"start":{"line":27,"column":2},"end":{"line":29,"column":4}},"5":{"start":{"line":32,"column":0},"end":{"line":32,"column":75}}},"fnMap":{"0":{"name":"createNewRouteStop","decl":{"start":{"line":3,"column":9},"end":{"line":3,"column":27}},"loc":{"start":{"line":3,"column":39},"end":{"line":15,"column":1}},"line":3},"1":{"name":"getAllStopsInOneRoute","decl":{"start":{"line":17,"column":9},"end":{"line":17,"column":30}},"loc":{"start":{"line":17,"column":37},"end":{"line":24,"column":1}},"line":17},"2":{"name":"(anonymous_2)","decl":{"start":{"line":23,"column":10},"end":{"line":23,"column":11}},"loc":{"start":{"line":23,"column":23},"end":{"line":23,"column":35}},"line":23},"3":{"name":"deleteRoute","decl":{"start":{"line":26,"column":9},"end":{"line":26,"column":20}},"loc":{"start":{"line":26,"column":27},"end":{"line":30,"column":1}},"line":26}},"branchMap":{},"s":{"0":4,"1":4,"2":1,"3":1,"4":0,"5":4},"f":{"0":4,"1":1,"2":1,"3":0},"b":{},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"23e5ac00817a242413d8ef8b769ce638f7156edb"} +,"/home/joepock123/fac/student-project/week11-where-is-whippy/server-api/model/vendors-m.js": {"path":"/home/joepock123/fac/student-project/week11-where-is-whippy/server-api/model/vendors-m.js","statementMap":{"0":{"start":{"line":1,"column":11},"end":{"line":1,"column":38}},"1":{"start":{"line":4,"column":2},"end":{"line":4,"column":76}},"2":{"start":{"line":4,"column":62},"end":{"line":4,"column":74}},"3":{"start":{"line":8,"column":2},"end":{"line":10,"column":34}},"4":{"start":{"line":10,"column":20},"end":{"line":10,"column":32}},"5":{"start":{"line":14,"column":2},"end":{"line":16,"column":34}},"6":{"start":{"line":16,"column":20},"end":{"line":16,"column":32}},"7":{"start":{"line":20,"column":2},"end":{"line":31,"column":4}},"8":{"start":{"line":34,"column":0},"end":{"line":39,"column":2}}},"fnMap":{"0":{"name":"getAllVendors","decl":{"start":{"line":3,"column":9},"end":{"line":3,"column":22}},"loc":{"start":{"line":3,"column":25},"end":{"line":5,"column":1}},"line":3},"1":{"name":"(anonymous_1)","decl":{"start":{"line":4,"column":49},"end":{"line":4,"column":50}},"loc":{"start":{"line":4,"column":62},"end":{"line":4,"column":74}},"line":4},"2":{"name":"getVendorLogin","decl":{"start":{"line":7,"column":9},"end":{"line":7,"column":23}},"loc":{"start":{"line":7,"column":31},"end":{"line":11,"column":1}},"line":7},"3":{"name":"(anonymous_3)","decl":{"start":{"line":10,"column":10},"end":{"line":10,"column":11}},"loc":{"start":{"line":10,"column":20},"end":{"line":10,"column":32}},"line":10},"4":{"name":"getSpecificVendor","decl":{"start":{"line":13,"column":9},"end":{"line":13,"column":26}},"loc":{"start":{"line":13,"column":37},"end":{"line":17,"column":1}},"line":13},"5":{"name":"(anonymous_5)","decl":{"start":{"line":16,"column":10},"end":{"line":16,"column":11}},"loc":{"start":{"line":16,"column":20},"end":{"line":16,"column":32}},"line":16},"6":{"name":"createVendor","decl":{"start":{"line":19,"column":9},"end":{"line":19,"column":21}},"loc":{"start":{"line":19,"column":30},"end":{"line":32,"column":1}},"line":19}},"branchMap":{},"s":{"0":4,"1":0,"2":0,"3":1,"4":1,"5":0,"6":0,"7":1,"8":4},"f":{"0":0,"1":0,"2":1,"3":1,"4":0,"5":0,"6":1},"b":{},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"c9d7a713aab79ddf0010a4daed8b273c5f1d5d7e"} +} diff --git a/server-api/coverage/lcov-report/base.css b/server-api/coverage/lcov-report/base.css new file mode 100644 index 0000000..f418035 --- /dev/null +++ b/server-api/coverage/lcov-report/base.css @@ -0,0 +1,224 @@ +body, html { + margin:0; padding: 0; + height: 100%; +} +body { + font-family: Helvetica Neue, Helvetica, Arial; + font-size: 14px; + color:#333; +} +.small { font-size: 12px; } +*, *:after, *:before { + -webkit-box-sizing:border-box; + -moz-box-sizing:border-box; + box-sizing:border-box; + } +h1 { font-size: 20px; margin: 0;} +h2 { font-size: 14px; } +pre { + font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace; + margin: 0; + padding: 0; + -moz-tab-size: 2; + -o-tab-size: 2; + tab-size: 2; +} +a { color:#0074D9; text-decoration:none; } +a:hover { text-decoration:underline; } +.strong { font-weight: bold; } +.space-top1 { padding: 10px 0 0 0; } +.pad2y { padding: 20px 0; } +.pad1y { padding: 10px 0; } +.pad2x { padding: 0 20px; } +.pad2 { padding: 20px; } +.pad1 { padding: 10px; } +.space-left2 { padding-left:55px; } +.space-right2 { padding-right:20px; } +.center { text-align:center; } +.clearfix { display:block; } +.clearfix:after { + content:''; + display:block; + height:0; + clear:both; + visibility:hidden; + } +.fl { float: left; } +@media only screen and (max-width:640px) { + .col3 { width:100%; max-width:100%; } + .hide-mobile { display:none!important; } +} + +.quiet { + color: #7f7f7f; + color: rgba(0,0,0,0.5); +} +.quiet a { opacity: 0.7; } + +.fraction { + font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; + font-size: 10px; + color: #555; + background: #E8E8E8; + padding: 4px 5px; + border-radius: 3px; + vertical-align: middle; +} + +div.path a:link, div.path a:visited { color: #333; } +table.coverage { + border-collapse: collapse; + margin: 10px 0 0 0; + padding: 0; +} + +table.coverage td { + margin: 0; + padding: 0; + vertical-align: top; +} +table.coverage td.line-count { + text-align: right; + padding: 0 5px 0 20px; +} +table.coverage td.line-coverage { + text-align: right; + padding-right: 10px; + min-width:20px; +} + +table.coverage td span.cline-any { + display: inline-block; + padding: 0 5px; + width: 100%; +} +.missing-if-branch { + display: inline-block; + margin-right: 5px; + border-radius: 3px; + position: relative; + padding: 0 4px; + background: #333; + color: yellow; +} + +.skip-if-branch { + display: none; + margin-right: 10px; + position: relative; + padding: 0 4px; + background: #ccc; + color: white; +} +.missing-if-branch .typ, .skip-if-branch .typ { + color: inherit !important; +} +.coverage-summary { + border-collapse: collapse; + width: 100%; +} +.coverage-summary tr { border-bottom: 1px solid #bbb; } +.keyline-all { border: 1px solid #ddd; } +.coverage-summary td, .coverage-summary th { padding: 10px; } +.coverage-summary tbody { border: 1px solid #bbb; } +.coverage-summary td { border-right: 1px solid #bbb; } +.coverage-summary td:last-child { border-right: none; } +.coverage-summary th { + text-align: left; + font-weight: normal; + white-space: nowrap; +} +.coverage-summary th.file { border-right: none !important; } +.coverage-summary th.pct { } +.coverage-summary th.pic, +.coverage-summary th.abs, +.coverage-summary td.pct, +.coverage-summary td.abs { text-align: right; } +.coverage-summary td.file { white-space: nowrap; } +.coverage-summary td.pic { min-width: 120px !important; } +.coverage-summary tfoot td { } + +.coverage-summary .sorter { + height: 10px; + width: 7px; + display: inline-block; + margin-left: 0.5em; + background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent; +} +.coverage-summary .sorted .sorter { + background-position: 0 -20px; +} +.coverage-summary .sorted-desc .sorter { + background-position: 0 -10px; +} +.status-line { height: 10px; } +/* yellow */ +.cbranch-no { background: yellow !important; color: #111; } +/* dark red */ +.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 } +.low .chart { border:1px solid #C21F39 } +.highlighted, +.highlighted .cstat-no, .highlighted .fstat-no, .highlighted .cbranch-no{ + background: #C21F39 !important; +} +/* medium red */ +.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE } +/* light red */ +.low, .cline-no { background:#FCE1E5 } +/* light green */ +.high, .cline-yes { background:rgb(230,245,208) } +/* medium green */ +.cstat-yes { background:rgb(161,215,106) } +/* dark green */ +.status-line.high, .high .cover-fill { background:rgb(77,146,33) } +.high .chart { border:1px solid rgb(77,146,33) } +/* dark yellow (gold) */ +.status-line.medium, .medium .cover-fill { background: #f9cd0b; } +.medium .chart { border:1px solid #f9cd0b; } +/* light yellow */ +.medium { background: #fff4c2; } + +.cstat-skip { background: #ddd; color: #111; } +.fstat-skip { background: #ddd; color: #111 !important; } +.cbranch-skip { background: #ddd !important; color: #111; } + +span.cline-neutral { background: #eaeaea; } + +.coverage-summary td.empty { + opacity: .5; + padding-top: 4px; + padding-bottom: 4px; + line-height: 1; + color: #888; +} + +.cover-fill, .cover-empty { + display:inline-block; + height: 12px; +} +.chart { + line-height: 0; +} +.cover-empty { + background: white; +} +.cover-full { + border-right: none !important; +} +pre.prettyprint { + border: none !important; + padding: 0 !important; + margin: 0 !important; +} +.com { color: #999 !important; } +.ignore-none { color: #999; font-weight: normal; } + +.wrapper { + min-height: 100%; + height: auto !important; + height: 100%; + margin: 0 auto -48px; +} +.footer, .push { + height: 48px; +} diff --git a/server-api/coverage/lcov-report/block-navigation.js b/server-api/coverage/lcov-report/block-navigation.js new file mode 100644 index 0000000..c7ff5a5 --- /dev/null +++ b/server-api/coverage/lcov-report/block-navigation.js @@ -0,0 +1,79 @@ +/* eslint-disable */ +var jumpToCode = (function init() { + // Classes of code we would like to highlight in the file view + var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no']; + + // Elements to highlight in the file listing view + var fileListingElements = ['td.pct.low']; + + // We don't want to select elements that are direct descendants of another match + var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > ` + + // Selecter that finds elements on the page to which we can jump + var selector = + fileListingElements.join(', ') + + ', ' + + notSelector + + missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b` + + // The NodeList of matching elements + var missingCoverageElements = document.querySelectorAll(selector); + + var currentIndex; + + function toggleClass(index) { + missingCoverageElements + .item(currentIndex) + .classList.remove('highlighted'); + missingCoverageElements.item(index).classList.add('highlighted'); + } + + function makeCurrent(index) { + toggleClass(index); + currentIndex = index; + missingCoverageElements.item(index).scrollIntoView({ + behavior: 'smooth', + block: 'center', + inline: 'center' + }); + } + + function goToPrevious() { + var nextIndex = 0; + if (typeof currentIndex !== 'number' || currentIndex === 0) { + nextIndex = missingCoverageElements.length - 1; + } else if (missingCoverageElements.length > 1) { + nextIndex = currentIndex - 1; + } + + makeCurrent(nextIndex); + } + + function goToNext() { + var nextIndex = 0; + + if ( + typeof currentIndex === 'number' && + currentIndex < missingCoverageElements.length - 1 + ) { + nextIndex = currentIndex + 1; + } + + makeCurrent(nextIndex); + } + + return function jump(event) { + switch (event.which) { + case 78: // n + case 74: // j + goToNext(); + break; + case 66: // b + case 75: // k + case 80: // p + goToPrevious(); + break; + } + }; +})(); +window.addEventListener('keydown', jumpToCode); diff --git a/server-api/coverage/lcov-report/favicon.png b/server-api/coverage/lcov-report/favicon.png new file mode 100644 index 0000000..6691817 Binary files /dev/null and b/server-api/coverage/lcov-report/favicon.png differ diff --git a/server-api/coverage/lcov-report/index.html b/server-api/coverage/lcov-report/index.html new file mode 100644 index 0000000..2f2411b --- /dev/null +++ b/server-api/coverage/lcov-report/index.html @@ -0,0 +1,171 @@ + + + + + + Code coverage report for All files + + + + + + + + + +
+
+

All files

+
+ +
+ 46.05% + Statements + 105/228 +
+ + +
+ 16.67% + Branches + 3/18 +
+ + +
+ 25% + Functions + 18/72 +
+ + +
+ 46.43% + Lines + 104/224 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
server-api +
+
100%32/3250%1/2100%0/0100%32/32
server-api/db +
+
80%12/1550%1/2100%1/180%12/15
server-api/handlers +
+
32.26%30/9316.67%1/617.95%7/3931.52%29/92
server-api/middleware +
+
23.08%12/520%0/814.29%1/723.53%12/51
server-api/model +
+
52.78%19/36100%0/036%9/2555.88%19/34
+
+
+
+ + + + + + + + + \ No newline at end of file diff --git a/server-api/coverage/lcov-report/prettify.css b/server-api/coverage/lcov-report/prettify.css new file mode 100644 index 0000000..b317a7c --- /dev/null +++ b/server-api/coverage/lcov-report/prettify.css @@ -0,0 +1 @@ +.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} diff --git a/server-api/coverage/lcov-report/prettify.js b/server-api/coverage/lcov-report/prettify.js new file mode 100644 index 0000000..b322523 --- /dev/null +++ b/server-api/coverage/lcov-report/prettify.js @@ -0,0 +1,2 @@ +/* eslint-disable */ +window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;arat[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); diff --git a/server-api/coverage/lcov-report/server-api/db/build.js.html b/server-api/coverage/lcov-report/server-api/db/build.js.html new file mode 100644 index 0000000..d2c4eca --- /dev/null +++ b/server-api/coverage/lcov-report/server-api/db/build.js.html @@ -0,0 +1,137 @@ + + + + + + Code coverage report for server-api/db/build.js + + + + + + + + + +
+
+

All files / server-api/db build.js

+
+ +
+ 70% + Statements + 7/10 +
+ + +
+ 50% + Branches + 1/2 +
+ + +
+ 100% + Functions + 1/1 +
+ + +
+ 70% + Lines + 7/10 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +204x +4x +4x +  +4x +  +  +11x +  +  +  +  +4x +  +  +  +  +  +4x + 
const path = require("path")
+const fs = require("fs")
+const db = require("./connection")
+ 
+const initSql = fs.readFileSync(path.join(__dirname, "init.sql"), "utf-8")
+ 
+function build() {
+  return db.query(initSql)
+}
+ 
+// if (require.main === module) build(); // Calls build function only if this file is invoked from command line 
+// If want to invoke from another file use require.main !== module
+Iif (require.main === module) {
+  console.log(`db reinitializing from command line. Entry point: ${require.main.filename}`)
+  console.log(`Please wait...`)
+  build()
+}
+ 
+module.exports = build 
+ 
+ +
+
+ + + + + + + + + \ No newline at end of file diff --git a/server-api/coverage/lcov-report/server-api/db/connection.js.html b/server-api/coverage/lcov-report/server-api/db/connection.js.html new file mode 100644 index 0000000..41f5e45 --- /dev/null +++ b/server-api/coverage/lcov-report/server-api/db/connection.js.html @@ -0,0 +1,110 @@ + + + + + + Code coverage report for server-api/db/connection.js + + + + + + + + + +
+
+

All files / server-api/db connection.js

+
+ +
+ 100% + Statements + 5/5 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 100% + Functions + 0/0 +
+ + +
+ 100% + Lines + 5/5 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +114x +4x +4x +  +4x +  +  +  +  +4x + 
const pg = require("pg")
+const dontenv = require("dotenv")
+dontenv.config()
+ 
+const db = new pg.Pool({
+  // Not 100% sure what this is doing
+  connectionString: process.env.DATABASE_URL,
+})
+ 
+module.exports = db
+ 
+ +
+
+ + + + + + + + + \ No newline at end of file diff --git a/server-api/coverage/lcov-report/server-api/db/index.html b/server-api/coverage/lcov-report/server-api/db/index.html new file mode 100644 index 0000000..a191ebc --- /dev/null +++ b/server-api/coverage/lcov-report/server-api/db/index.html @@ -0,0 +1,126 @@ + + + + + + Code coverage report for server-api/db + + + + + + + + + +
+
+

All files server-api/db

+
+ +
+ 80% + Statements + 12/15 +
+ + +
+ 50% + Branches + 1/2 +
+ + +
+ 100% + Functions + 1/1 +
+ + +
+ 80% + Lines + 12/15 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
build.js +
+
70%7/1050%1/2100%1/170%7/10
connection.js +
+
100%5/5100%0/0100%0/0100%5/5
+
+
+
+ + + + + + + + + \ No newline at end of file diff --git a/server-api/coverage/lcov-report/server-api/handlers/customer-location-h.js.html b/server-api/coverage/lcov-report/server-api/handlers/customer-location-h.js.html new file mode 100644 index 0000000..93eb296 --- /dev/null +++ b/server-api/coverage/lcov-report/server-api/handlers/customer-location-h.js.html @@ -0,0 +1,221 @@ + + + + + + Code coverage report for server-api/handlers/customer-location-h.js + + + + + + + + + +
+
+

All files / server-api/handlers customer-location-h.js

+
+ +
+ 36.36% + Statements + 4/11 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 50% + Functions + 2/4 +
+ + +
+ 36.36% + Lines + 4/11 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +484x +  +  +  +  +1x +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +4x +  +  +  + 
const model = require("../model/customer-location-m")
+// const geo = navigator.geolocation maybe need to add window.navigator.geolocation?
+ 
+function allCustomerLocations(req, res, next) {
+  // console.log("In function")
+  model
+    .getAllCustomerLocations()
+    .then((allLocations) => {
+      res.send(allLocations)
+    })
+    .catch(next)
+}
+ 
+function addNewCustomerLocation(req, res, next) {
+  const customerId = req.body.customerId
+  const lat = req.body.latitude
+  const lng = req.body.longitude
+  const temp = req.body.temperature
+ 
+  model
+    .addNewCustomerLocation(customerId, lat, lng, temp)
+    .then((RETURNING) => {
+      console.log(RETURNING)
+      res.send(RETURNING.rows[0])
+    })
+    .catch(next)
+}
+ 
+// function addNewCustomerLocation(customer, req, res, next) {
+//   // Has the customer already entered a request in the last half an hour?
+//   let result = customerLocationModel.getAllCustomerLocations(
+//     " WHERE time >= NOW() - INTERVAL '30 minutes'"
+//   )
+//   if (result) console.log("You have already made an entry")
+//   else {
+//     const customerId = customer || 5 // This value is taken from the request body or url using req.params
+//     const position = geo.getCurrentPosition // Getting coordinates will be done on the frontend
+//     const lat = position.coords.latitude
+//     const lng = position.coords.lng
+//     customerLocationModel.addCustomerLocation(customerId, lat, lng)
+//   }
+// }
+ 
+module.exports = {
+  addNewCustomerLocation,
+  allCustomerLocations,
+}
+ 
+ +
+
+ + + + + + + + + \ No newline at end of file diff --git a/server-api/coverage/lcov-report/server-api/handlers/customers-h.js.html b/server-api/coverage/lcov-report/server-api/handlers/customers-h.js.html new file mode 100644 index 0000000..120e931 --- /dev/null +++ b/server-api/coverage/lcov-report/server-api/handlers/customers-h.js.html @@ -0,0 +1,335 @@ + + + + + + Code coverage report for server-api/handlers/customers-h.js + + + + + + + + + +
+
+

All files / server-api/handlers customers-h.js

+
+ +
+ 25% + Statements + 7/28 +
+ + +
+ 0% + Branches + 0/2 +
+ + +
+ 0% + Functions + 0/11 +
+ + +
+ 25% + Lines + 7/28 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +864x +4x +4x +  +4x +4x +  +4x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +4x +  +  +  +  +  + 
const jwt = require("jsonwebtoken")
+const dotenv = require("dotenv")
+const bcrypt = require("bcrypt")
+ 
+dotenv.config()
+const SECRET = process.env.JWT_SECRET
+ 
+const customers = require("../model/customers-m")
+ 
+function allCustomers(req, res, next) {
+  customers
+    .getAllCustomers()
+    .then((allCustomers) => {
+      res.send(allCustomers)
+    })
+    .catch(next)
+}
+ 
+function createCustomer(req, res, next) {
+  const newCustomer = {
+    name: req.body.name,
+    email: req.body.email,
+    password: req.body.password,
+    username: req.body.username,
+    age: req.body.age,
+    gender: req.body.gender,
+    icecreamFlavour: req.body.icecreamFlavour,
+  }
+ 
+  bcrypt
+    .genSalt(10)
+    .then((salt) => bcrypt.hash(req.body.password, salt))
+    .then((hash) =>
+      customers.createCustomer({ ...newCustomer, password: hash })
+    )
+    .then((customer) => {
+      const token = jwt.sign({ customerId: customer.id }, SECRET, {
+        expiresIn: "1h",
+      })
+      res.status(201).send({ access_token: token })
+    })
+    .catch(next)
+}
+ 
+function loginCustomer(req, res, next) {
+  const email = req.body.email
+  const password = req.body.password
+ 
+  customers
+    .getCustomer(email)
+    .then((customer) => {
+      bcrypt.compare(password, customer.password).then((match) => {
+        if (!match) {
+          const error = new Error(
+            "Unauthorized: Sorry, no ice cream for you today"
+          )
+          error.status = 401
+          next(error)
+        } else {
+          const token = jwt.sign({ user: customer.id }, SECRET, {
+            expiresIn: "1h",
+          })
+          res.status(200).send({ access_token: token })
+        }
+      })
+    })
+    .catch(next)
+}
+ 
+function getSpecificCustomer(req, res, next) {
+  const customerID = req.params.id
+  customers
+    .getSpecificCustomer(customerID)
+    .then((specificCustomer) => {
+      res.send(specificCustomer)
+    })
+    .catch(next)
+}
+ 
+module.exports = {
+  allCustomers,
+  createCustomer,
+  loginCustomer,
+  getSpecificCustomer,
+}
+ 
+ +
+
+ + + + + + + + + \ No newline at end of file diff --git a/server-api/coverage/lcov-report/server-api/handlers/index.html b/server-api/coverage/lcov-report/server-api/handlers/index.html new file mode 100644 index 0000000..f5845f9 --- /dev/null +++ b/server-api/coverage/lcov-report/server-api/handlers/index.html @@ -0,0 +1,171 @@ + + + + + + Code coverage report for server-api/handlers + + + + + + + + + +
+
+

All files server-api/handlers

+
+ +
+ 32.26% + Statements + 30/93 +
+ + +
+ 16.67% + Branches + 1/6 +
+ + +
+ 17.95% + Functions + 7/39 +
+ + +
+ 31.52% + Lines + 29/92 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
customer-location-h.js +
+
36.36%4/11100%0/050%2/436.36%4/11
customers-h.js +
+
25%7/280%0/20%0/1125%7/28
vendor-location-h.js +
+
22.22%2/9100%0/00%0/422.22%2/9
vendor-routes-h.js +
+
58.82%10/1750%1/255.56%5/956.25%9/16
vendors-h.js +
+
25%7/280%0/20%0/1125%7/28
+
+
+
+ + + + + + + + + \ No newline at end of file diff --git a/server-api/coverage/lcov-report/server-api/handlers/vendor-location-h.js.html b/server-api/coverage/lcov-report/server-api/handlers/vendor-location-h.js.html new file mode 100644 index 0000000..43be262 --- /dev/null +++ b/server-api/coverage/lcov-report/server-api/handlers/vendor-location-h.js.html @@ -0,0 +1,155 @@ + + + + + + Code coverage report for server-api/handlers/vendor-location-h.js + + + + + + + + + +
+
+

All files / server-api/handlers vendor-location-h.js

+
+ +
+ 22.22% + Statements + 2/9 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 0% + Functions + 0/4 +
+ + +
+ 22.22% + Lines + 2/9 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +264x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +4x + 
const model = require("../model/vendor-location-m")
+ 
+function allVendorLocations(req, res, next) {
+  model
+    .getAllVendorLocations()
+    .then((allLocations) => {
+      res.send(allLocations)
+    })
+    .catch(next)
+}
+ 
+function addNewVendorLocation(req, res, next) {
+  const vendorId = req.body.vendorId
+  const lat = req.body.latitude
+  const lng = req.body.longitude
+ 
+  model
+    .addNewVendorLocation(vendorId, lat, lng)
+    .then((returning) => {
+      res.send(returning.rows[0])
+    })
+    .catch(next)
+}
+ 
+module.exports = { allVendorLocations, addNewVendorLocation }
+ 
+ +
+
+ + + + + + + + + \ No newline at end of file diff --git a/server-api/coverage/lcov-report/server-api/handlers/vendor-routes-h.js.html b/server-api/coverage/lcov-report/server-api/handlers/vendor-routes-h.js.html new file mode 100644 index 0000000..d7483b9 --- /dev/null +++ b/server-api/coverage/lcov-report/server-api/handlers/vendor-routes-h.js.html @@ -0,0 +1,215 @@ + + + + + + Code coverage report for server-api/handlers/vendor-routes-h.js + + + + + + + + + +
+
+

All files / server-api/handlers vendor-routes-h.js

+
+ +
+ 58.82% + Statements + 10/17 +
+ + +
+ 50% + Branches + 1/2 +
+ + +
+ 55.56% + Functions + 5/9 +
+ + +
+ 56.25% + Lines + 9/16 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +464x +  +  +1x +1x +  +  +1x +3x +  +  +  +  +  +  +1x +  +3x +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +4x + 
const model = require("../model/vendor-routes-m")
+ 
+function createNewRoute(req, res, next) {
+  return model.getAllStopsInOneRoute(req.body[0].name).then((results) => {
+    Iif (results.length !== 0) {
+      res.status(409).send("Name exists in db. Please use unique name")
+    } else {
+      let promiseArray = req.body.map((obj) => {
+        return model.createNewRouteStop(obj) // We need to return a promise for each db query!!
+      })
+ 
+      // How to use Promise.all to wait for multiple promises to resolve
+      // 1) Create an array of promises as a variable
+      // 2) use a Promise.all to wait until all of the promises have resolved
+      // 3) Then you can chain on a .then()
+      Promise.all(promiseArray)
+        .then((arrOfDbResults) => {
+          let resultsArrForFe = arrOfDbResults.map((result) => result.rows[0])
+          res.status(201).send(resultsArrForFe)
+        })
+        .catch(next)
+    }
+  })
+}
+ 
+function getRoute(req, res, next) {
+  const routeName = req.params.name
+  //name MUST be sent with %20 on FE
+  model
+    .getAllStopsInOneRoute(routeName)
+    .then((allStops) => {
+      res.send(allStops)
+    })
+    .catch(next)
+}
+ 
+function deleteRoute(req, res, next) {
+  const routeName = req.params.name
+  model
+    .deleteRoute(routeName)
+    .then((result) => res.sendStatus(204))
+    .catch(next)
+}
+ 
+module.exports = { createNewRoute, getRoute, deleteRoute }
+ 
+ +
+
+ + + + + + + + + \ No newline at end of file diff --git a/server-api/coverage/lcov-report/server-api/handlers/vendors-h.js.html b/server-api/coverage/lcov-report/server-api/handlers/vendors-h.js.html new file mode 100644 index 0000000..5e9acb1 --- /dev/null +++ b/server-api/coverage/lcov-report/server-api/handlers/vendors-h.js.html @@ -0,0 +1,302 @@ + + + + + + Code coverage report for server-api/handlers/vendors-h.js + + + + + + + + + +
+
+

All files / server-api/handlers vendors-h.js

+
+ +
+ 25% + Statements + 7/28 +
+ + +
+ 0% + Branches + 0/2 +
+ + +
+ 0% + Functions + 0/11 +
+ + +
+ 25% + Lines + 7/28 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +754x +4x +4x +  +4x +4x +  +4x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +4x + 
const jwt = require("jsonwebtoken")
+const dotenv = require("dotenv")
+const bcrypt = require("bcrypt")
+ 
+dotenv.config()
+const SECRET = process.env.JWT_SECRET
+ 
+const vendors = require("../model/vendors-m")
+ 
+function allVendors(req, res, next) {
+  vendors
+    .getAllVendors()
+    .then((allVendors) => {
+      res.send(allVendors)
+    })
+    .catch(next)
+}
+ 
+function getSpecificVendor(req, res, next) {
+  const vendorId = req.params.id
+  vendors
+    .getSpecificVendor(vendorId)
+    .then((vendor) => res.send(vendor))
+    .catch(next)
+}
+ 
+function createVendor(req, res, next) {
+  const newVendor = {
+    name: req.body.name,
+    email: req.body.email,
+    password: req.body.password,
+    mobile: req.body.mobile,
+    companyName: req.body.companyName,
+    alcohol: req.body.alcohol,
+    vegan: req.body.vegan,
+  }
+ 
+  bcrypt
+    .genSalt(10)
+    .then((salt) => bcrypt.hash(req.body.password, salt))
+    .then((hash) => vendors.createVendor({ ...newVendor, password: hash }))
+    .then((newVendor) => {
+      const token = jwt.sign({ vendor: newVendor.id }, SECRET, {
+        expiresIn: "60m",
+      })
+      res.status(201).send({ access_token: token })
+    })
+    .catch(next)
+}
+ 
+function loginVendor(req, res, next) {
+  const email = req.body.email
+  const password = req.body.password
+ 
+  vendors
+    .getVendorLogin(email) // Need to handle error if no user exists because empty arr is passed into next .then()
+    .then((vendor) => {
+      bcrypt.compare(password, vendor.password).then((match) => {
+        if (!match) {
+          const error = new Error("Unauthorized")
+          error.status = 401
+          next(error)
+        } else {
+          const token = jwt.sign({ user: vendor.id }, SECRET, {
+            expiresIn: "1h",
+          })
+          res.status(200).send({ access_token: token })
+        }
+      })
+    })
+    .catch(next)
+}
+ 
+module.exports = { allVendors, getSpecificVendor, createVendor, loginVendor }
+ 
+ +
+
+ + + + + + + + + \ No newline at end of file diff --git a/server-api/coverage/lcov-report/server-api/index.html b/server-api/coverage/lcov-report/server-api/index.html new file mode 100644 index 0000000..0f8e20b --- /dev/null +++ b/server-api/coverage/lcov-report/server-api/index.html @@ -0,0 +1,111 @@ + + + + + + Code coverage report for server-api + + + + + + + + + +
+
+

All files server-api

+
+ +
+ 100% + Statements + 32/32 +
+ + +
+ 50% + Branches + 1/2 +
+ + +
+ 100% + Functions + 0/0 +
+ + +
+ 100% + Lines + 32/32 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
server.js +
+
100%32/3250%1/2100%0/0100%32/32
+
+
+
+ + + + + + + + + \ No newline at end of file diff --git a/server-api/coverage/lcov-report/server-api/middleware/auth.js.html b/server-api/coverage/lcov-report/server-api/middleware/auth.js.html new file mode 100644 index 0000000..b55f619 --- /dev/null +++ b/server-api/coverage/lcov-report/server-api/middleware/auth.js.html @@ -0,0 +1,260 @@ + + + + + + Code coverage report for server-api/middleware/auth.js + + + + + + + + + +
+
+

All files / server-api/middleware auth.js

+
+ +
+ 16.22% + Statements + 6/37 +
+ + +
+ 0% + Branches + 0/4 +
+ + +
+ 0% + Functions + 0/4 +
+ + +
+ 16.22% + Lines + 6/37 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +614x +4x +4x +  +4x +  +4x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +4x + 
const jwt = require("jsonwebtoken")
+const customerModel = require("../model/customers-m")
+const vendorModel = require("../model/vendors-m")
+ 
+require("dotenv").config()
+ 
+const SECRET = process.env.JWT_SECRET
+ 
+function verifyCustomer(req, res, next) {
+  const authHeader = req.headers.authorization
+  if (!authHeader) {
+    const error = new Error("Authorization header required") //look into this
+    error.status = 400
+    next(error)
+  }
+  const token = authHeader.replace("Bearer ", "")
+  try {
+    const data = jwt.verify(token, SECRET)
+    console.log(data)
+    customerModel
+      .getSpecificCustomer(data.user)
+      .then((user) => {
+        req.user = user
+        next()
+      })
+      .catch(next)
+  } catch (_err) {
+    const error = new Error("Unauthorized")
+    error.status = 401
+    next(error)
+  }
+}
+ 
+function verifyVendor(req, res, next) {
+  const authHeader = req.headers.authorization
+  console.log("autheheader" + authHeader)
+  if (!authHeader) {
+    const error = new Error("Authorization header required") //look into this
+    error.status = 400
+    next(error)
+  }
+  const token = authHeader.replace("Bearer ", "")
+  try {
+    const data = jwt.verify(token, SECRET)
+    console.log("data" + data)
+    vendorModel
+      .getSpecificVendor(data.user)
+      .then((user) => {
+        req.user = user
+        next()
+      })
+      .catch(next)
+  } catch (_) {
+    const error = new Error("Unauthorized")
+    error.status = 401
+    next(error)
+  }
+}
+ 
+module.exports = { verifyCustomer, verifyVendor }
+ 
+ +
+
+ + + + + + + + + \ No newline at end of file diff --git a/server-api/coverage/lcov-report/server-api/middleware/handleError.js.html b/server-api/coverage/lcov-report/server-api/middleware/handleError.js.html new file mode 100644 index 0000000..eaf217e --- /dev/null +++ b/server-api/coverage/lcov-report/server-api/middleware/handleError.js.html @@ -0,0 +1,140 @@ + + + + + + Code coverage report for server-api/middleware/handleError.js + + + + + + + + + +
+
+

All files / server-api/middleware handleError.js

+
+ +
+ 18.18% + Statements + 2/11 +
+ + +
+ 0% + Branches + 0/4 +
+ + +
+ 0% + Functions + 0/2 +
+ + +
+ 20% + Lines + 2/10 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +214x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +4x + 
const { STATUS_CODES } = require("http")
+ 
+// eslint-disable-next-line no-unused-vars
+function handleError(error, req, res, next) {
+  console.error(error)
+  const status = error.status || 500
+  res.status(status)
+  const message = STATUS_CODES[status]
+  if (process.env.NODE_ENV === "production") {
+    res.send({ error: message })
+  } else {
+    const stackArray = error.stack.split("\n").map((line) => line.trim())
+    res.send({
+      error: message,
+      stack: stackArray,
+    })
+  }
+}
+ 
+module.exports = handleError
+ 
+ +
+
+ + + + + + + + + \ No newline at end of file diff --git a/server-api/coverage/lcov-report/server-api/middleware/index.html b/server-api/coverage/lcov-report/server-api/middleware/index.html new file mode 100644 index 0000000..c555529 --- /dev/null +++ b/server-api/coverage/lcov-report/server-api/middleware/index.html @@ -0,0 +1,141 @@ + + + + + + Code coverage report for server-api/middleware + + + + + + + + + +
+
+

All files server-api/middleware

+
+ +
+ 23.08% + Statements + 12/52 +
+ + +
+ 0% + Branches + 0/8 +
+ + +
+ 14.29% + Functions + 1/7 +
+ + +
+ 23.53% + Lines + 12/51 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
auth.js +
+
16.22%6/370%0/40%0/416.22%6/37
handleError.js +
+
18.18%2/110%0/40%0/220%2/10
logger.js +
+
100%4/4100%0/0100%1/1100%4/4
+
+
+
+ + + + + + + + + \ No newline at end of file diff --git a/server-api/coverage/lcov-report/server-api/middleware/logger.js.html b/server-api/coverage/lcov-report/server-api/middleware/logger.js.html new file mode 100644 index 0000000..8f0d102 --- /dev/null +++ b/server-api/coverage/lcov-report/server-api/middleware/logger.js.html @@ -0,0 +1,101 @@ + + + + + + Code coverage report for server-api/middleware/logger.js + + + + + + + + + +
+
+

All files / server-api/middleware logger.js

+
+ +
+ 100% + Statements + 4/4 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 100% + Functions + 1/1 +
+ + +
+ 100% + Lines + 4/4 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+
+
+

+
1 +2 +3 +4 +5 +6 +7 +8  +2x +2x +2x +  +  +4x + 
function logger(req, res, next) {
+  const time = new Date().toLocaleTimeString()
+  console.log(`${time} ${req.method} ${req.url}`)
+  next()
+}
+ 
+module.exports = logger
+ 
+ +
+
+ + + + + + + + + \ No newline at end of file diff --git a/server-api/coverage/lcov-report/server-api/model/customer-location-m.js.html b/server-api/coverage/lcov-report/server-api/model/customer-location-m.js.html new file mode 100644 index 0000000..57789b7 --- /dev/null +++ b/server-api/coverage/lcov-report/server-api/model/customer-location-m.js.html @@ -0,0 +1,128 @@ + + + + + + Code coverage report for server-api/model/customer-location-m.js + + + + + + + + + +
+
+

All files / server-api/model customer-location-m.js

+
+ +
+ 100% + Statements + 5/5 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 100% + Functions + 3/3 +
+ + +
+ 100% + Lines + 5/5 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +174x +  +  +4x +  +4x +  +  +  +1x +  +  +  +  +  +4x + 
const db = require("../db/connection")
+ 
+function getAllCustomerLocations() {
+  return db
+    .query(`SELECT * FROM customer_location;`)
+    .then((results) => results.rows)
+}
+ 
+function addNewCustomerLocation(customerId, latitude, longitude, temperature) {
+  return db.query(
+    `INSERT INTO customer_location (customer_id, latitude, longitude, temperature) VALUES ($1, $2, $3, $4) RETURNING customer_id, latitude, longitude, temperature;`,
+    [customerId, latitude, longitude, temperature]
+  )
+}
+ 
+module.exports = { getAllCustomerLocations, addNewCustomerLocation }
+ 
+ +
+
+ + + + + + + + + \ No newline at end of file diff --git a/server-api/coverage/lcov-report/server-api/model/customers-m.js.html b/server-api/coverage/lcov-report/server-api/model/customers-m.js.html new file mode 100644 index 0000000..addbd69 --- /dev/null +++ b/server-api/coverage/lcov-report/server-api/model/customers-m.js.html @@ -0,0 +1,203 @@ + + + + + + Code coverage report for server-api/model/customers-m.js + + + + + + + + + +
+
+

All files / server-api/model customers-m.js

+
+ +
+ 18.18% + Statements + 2/11 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 0% + Functions + 0/8 +
+ + +
+ 20% + Lines + 2/10 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +424x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +4x +  +  +  +  +  + 
const db = require("../db/connection")
+ 
+function getAllCustomers() {
+  return db.query(`SELECT * FROM customers;`).then((results) => results.rows)
+}
+ 
+function getCustomer(email) {
+  console.log("getCustomer -> email", email)
+  return db
+    .query(`SELECT * FROM customers WHERE email=($1)`, [email])
+    .then((user) => user.rows[0])
+    .catch((error) => error)
+}
+ 
+function getSpecificCustomer(id) {
+  return db
+    .query(`SELECT * FROM customers WHERE id=($1)`, [id])
+    .then((user) => user.rows[0])
+}
+ 
+function createCustomer(newCustomer) {
+  return db.query(
+    `INSERT INTO customers(name, email, password, username, age, gender, icecream_flavour) VALUES ($1,$2,$3,$4,$5,$6,$7) RETURNING id, name, password;`,
+    [
+      newCustomer.name,
+      newCustomer.email,
+      newCustomer.password,
+      newCustomer.username,
+      newCustomer.age,
+      newCustomer.gender,
+      newCustomer.icecreamFlavour,
+    ]
+  )
+}
+ 
+module.exports = {
+  getAllCustomers,
+  getCustomer,
+  getSpecificCustomer,
+  createCustomer,
+}
+ 
+ +
+
+ + + + + + + + + \ No newline at end of file diff --git a/server-api/coverage/lcov-report/server-api/model/index.html b/server-api/coverage/lcov-report/server-api/model/index.html new file mode 100644 index 0000000..4382696 --- /dev/null +++ b/server-api/coverage/lcov-report/server-api/model/index.html @@ -0,0 +1,171 @@ + + + + + + Code coverage report for server-api/model + + + + + + + + + +
+
+

All files server-api/model

+
+ +
+ 52.78% + Statements + 19/36 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 36% + Functions + 9/25 +
+ + +
+ 55.88% + Lines + 19/34 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
customer-location-m.js +
+
100%5/5100%0/0100%3/3100%5/5
customers-m.js +
+
18.18%2/11100%0/00%0/820%2/10
vendor-location-m.js +
+
40%2/5100%0/00%0/340%2/5
vendor-routes-m.js +
+
83.33%5/6100%0/075%3/483.33%5/6
vendors-m.js +
+
55.56%5/9100%0/042.86%3/762.5%5/8
+
+
+
+ + + + + + + + + \ No newline at end of file diff --git a/server-api/coverage/lcov-report/server-api/model/vendor-location-m.js.html b/server-api/coverage/lcov-report/server-api/model/vendor-location-m.js.html new file mode 100644 index 0000000..7c074ba --- /dev/null +++ b/server-api/coverage/lcov-report/server-api/model/vendor-location-m.js.html @@ -0,0 +1,128 @@ + + + + + + Code coverage report for server-api/model/vendor-location-m.js + + + + + + + + + +
+
+

All files / server-api/model vendor-location-m.js

+
+ +
+ 40% + Statements + 2/5 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 0% + Functions + 0/3 +
+ + +
+ 40% + Lines + 2/5 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +174x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +4x + 
const db = require("../db/connection")
+ 
+function getAllVendorLocations() {
+  return db
+    .query(`SELECT * FROM vendor_location;`)
+    .then((result) => result.rows)
+}
+ 
+function addNewVendorLocation(vendorId, latitude, longitude) {
+  return db.query(
+    `INSERT INTO vendor_location (vendor_id, latitude, longitude) VALUES ($1, $2, $3) RETURNING vendor_id, latitude, longitude, time;`,
+    [vendorId, latitude, longitude]
+  )
+}
+ 
+module.exports = { getAllVendorLocations, addNewVendorLocation }
+ 
+ +
+
+ + + + + + + + + \ No newline at end of file diff --git a/server-api/coverage/lcov-report/server-api/model/vendor-routes-m.js.html b/server-api/coverage/lcov-report/server-api/model/vendor-routes-m.js.html new file mode 100644 index 0000000..e351e5e --- /dev/null +++ b/server-api/coverage/lcov-report/server-api/model/vendor-routes-m.js.html @@ -0,0 +1,176 @@ + + + + + + Code coverage report for server-api/model/vendor-routes-m.js + + + + + + + + + +
+
+

All files / server-api/model vendor-routes-m.js

+
+ +
+ 83.33% + Statements + 5/6 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 75% + Functions + 3/4 +
+ + +
+ 83.33% + Lines + 5/6 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +334x +  +  +4x +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +  +  +  +  +1x +  +  +  +  +  +  +  +  +4x + 
const db = require("../db/connection")
+ 
+function createNewRouteStop(routeStop) {
+  return db.query(
+    `INSERT INTO vendor_routes (vendor_id, name, stop_number, time_from, time_to, address) VALUES ($1, $2, $3, $4, $5, $6) RETURNING id, vendor_id, name, stop_number, time_from, time_to, address`,
+    [
+      routeStop.vendorId,
+      routeStop.name,
+      routeStop.stopNumber,
+      routeStop.timeFrom,
+      routeStop.timeTo,
+      routeStop.address,
+    ]
+  )
+}
+ 
+function getAllStopsInOneRoute(name) {
+  return db
+    .query(
+      `SELECT stop_number, time_from, time_to, address FROM vendor_routes WHERE lower(name)=lower($1)`,
+      [name]
+    )
+    .then((results) => results.rows)
+}
+ 
+function deleteRoute(name) {
+  return db.query(`DELETE FROM vendor_routes WHERE lower(name)=lower($1)`, [
+    name,
+  ])
+}
+ 
+module.exports = { createNewRouteStop, getAllStopsInOneRoute, deleteRoute }
+ 
+ +
+
+ + + + + + + + + \ No newline at end of file diff --git a/server-api/coverage/lcov-report/server-api/model/vendors-m.js.html b/server-api/coverage/lcov-report/server-api/model/vendors-m.js.html new file mode 100644 index 0000000..7e4504d --- /dev/null +++ b/server-api/coverage/lcov-report/server-api/model/vendors-m.js.html @@ -0,0 +1,197 @@ + + + + + + Code coverage report for server-api/model/vendors-m.js + + + + + + + + + +
+
+

All files / server-api/model vendors-m.js

+
+ +
+ 55.56% + Statements + 5/9 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 42.86% + Functions + 3/7 +
+ + +
+ 62.5% + Lines + 5/8 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +404x +  +  +  +  +  +  +1x +  +1x +  +  +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +4x +  +  +  +  +  + 
const db = require("../db/connection");
+ 
+function getAllVendors() {
+  return db.query(`SELECT * FROM vendors;`).then((results) => results.rows);
+}
+ 
+function getVendorLogin(email) {
+  return db
+    .query(`SELECT * FROM vendors WHERE email=($1)`, [email])
+    .then((user) => user.rows[0]);
+}
+ 
+function getSpecificVendor(vendorId) {
+  return db
+    .query("SELECT * FROM vendors WHERE id=($1)", [vendorId])
+    .then((user) => user.rows[0]);
+}
+ 
+function createVendor(vendor) {
+  return db.query(
+    `INSERT INTO vendors(name, email, password, mobile, company_name, alcohol, vegan_option) VALUES ($1,$2,$3,$4,$5,$6,$7) RETURNING id, name, password;`,
+    [
+      vendor.name,
+      vendor.email,
+      vendor.password,
+      vendor.mobile,
+      vendor.companyName,
+      vendor.alcohol,
+      vendor.vegan,
+    ]
+  );
+}
+ 
+module.exports = {
+  getAllVendors,
+  getVendorLogin,
+  getSpecificVendor,
+  createVendor,
+};
+ 
+ +
+
+ + + + + + + + + \ No newline at end of file diff --git a/server-api/coverage/lcov-report/server-api/server.js.html b/server-api/coverage/lcov-report/server-api/server.js.html new file mode 100644 index 0000000..9a480dd --- /dev/null +++ b/server-api/coverage/lcov-report/server-api/server.js.html @@ -0,0 +1,305 @@ + + + + + + Code coverage report for server-api/server.js + + + + + + + + + +
+
+

All files / server-api server.js

+
+ +
+ 100% + Statements + 32/32 +
+ + +
+ 50% + Branches + 1/2 +
+ + +
+ 100% + Functions + 0/0 +
+ + +
+ 100% + Lines + 32/32 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +764x +4x +  +  +4x +4x +4x +4x +4x +  +  +4x +4x +4x +  +4x +4x +4x +  +  +4x +  +  +  +  +  +  +  +4x +  +  +  +  +  +4x +4x +4x +4x +4x +4x +4x +  +  +4x +4x +4x +  +  +  +  +  +4x +4x +4x +  +  +  +  +4x +  +  +  +  +  +  +  +  +  +  +  +4x +  +4x +  +4x + 
const express = require("express");
+const cors = require("cors");
+ 
+// Handler modules
+const customerLocationsHandler = require("./handlers/customer-location-h");
+const vendorLocationsHandler = require("./handlers/vendor-location-h");
+const vendorRoutesHandler = require("./handlers/vendor-routes-h");
+const vendors = require("./handlers/vendors-h");
+const customers = require("./handlers/customers-h");
+ 
+// Middleware
+const handleError = require("./middleware/handleError");
+const logger = require("./middleware/logger");
+const auth = require("./middleware/auth");
+ 
+const server = express();
+server.use(express.json());
+server.use(logger);
+ 
+// Only allowing cross origin request from a specific url.
+const corsOptions = {
+  origin:
+    process.env.NODE_ENV == "production"
+      ? "https://competent-feynman-176d4a.netlify.app/"
+      : "http://localhost:3000",
+};
+ 
+// Request Handling
+server.use(cors(corsOptions));
+ 
+//GET
+ 
+// REST API
+// GETauth. verifyCustomer,
+server.get("/customers", customers.allCustomers); // WORKING
+server.get("/customers/coords", customerLocationsHandler.allCustomerLocations); // WORKING
+server.get("/customers/:id", customers.getSpecificCustomer); // WORKING
+server.get("/vendors", vendors.allVendors); // WORKING
+server.get("/vendors/coords", vendorLocationsHandler.allVendorLocations); // WORKING
+server.get("/vendors/:id", vendors.getSpecificVendor); // WORKING
+server.get("/vendors/routes/:name", vendorRoutesHandler.getRoute); // WORKING
+ 
+// POST
+server.post("/customers/signup", customers.createCustomer); // WORKING
+server.post("/customers/login", customers.loginCustomer); // WORKING
+server.post(
+  "/customers/coords/",
+  // auth.verifyCustomer,
+  customerLocationsHandler.addNewCustomerLocation
+); // WORKING
+ 
+server.post("/vendors/signup", vendors.createVendor); // WORKING
+server.post("/vendors/login", vendors.loginVendor); // WORKING
+server.post(
+  "/vendors/coords/",
+  // auth.verifyVendor,
+  vendorLocationsHandler.addNewVendorLocation
+); // WORKING
+server.post(
+  "/vendors/routes/",
+  // auth.verifyVendor,
+  vendorRoutesHandler.createNewRoute
+); // WORKING
+ 
+// PUT
+// server.put('/vendor endpoint', callback) // For vendors to update info
+ 
+// DELETE
+// server.delete('/vendor endpoint', callback) // For vendors to delete account
+// server.delete('/customer endpoint', callback) // For customer to delete account
+server.delete("/vendors/routes/:name", vendorRoutesHandler.deleteRoute);
+ 
+server.use(handleError);
+ 
+module.exports = server;
+ 
+ +
+
+ + + + + + + + + \ No newline at end of file diff --git a/server-api/coverage/lcov-report/sort-arrow-sprite.png b/server-api/coverage/lcov-report/sort-arrow-sprite.png new file mode 100644 index 0000000..03f704a Binary files /dev/null and b/server-api/coverage/lcov-report/sort-arrow-sprite.png differ diff --git a/server-api/coverage/lcov-report/sorter.js b/server-api/coverage/lcov-report/sorter.js new file mode 100644 index 0000000..16de10c --- /dev/null +++ b/server-api/coverage/lcov-report/sorter.js @@ -0,0 +1,170 @@ +/* eslint-disable */ +var addSorting = (function() { + 'use strict'; + var cols, + currentSort = { + index: 0, + desc: false + }; + + // returns the summary table element + function getTable() { + return document.querySelector('.coverage-summary'); + } + // returns the thead element of the summary table + function getTableHeader() { + return getTable().querySelector('thead tr'); + } + // returns the tbody element of the summary table + function getTableBody() { + return getTable().querySelector('tbody'); + } + // returns the th element for nth column + function getNthColumn(n) { + return getTableHeader().querySelectorAll('th')[n]; + } + + // loads all columns + function loadColumns() { + var colNodes = getTableHeader().querySelectorAll('th'), + colNode, + cols = [], + col, + i; + + for (i = 0; i < colNodes.length; i += 1) { + colNode = colNodes[i]; + col = { + key: colNode.getAttribute('data-col'), + sortable: !colNode.getAttribute('data-nosort'), + type: colNode.getAttribute('data-type') || 'string' + }; + cols.push(col); + if (col.sortable) { + col.defaultDescSort = col.type === 'number'; + colNode.innerHTML = + colNode.innerHTML + ''; + } + } + return cols; + } + // attaches a data attribute to every tr element with an object + // of data values keyed by column name + function loadRowData(tableRow) { + var tableCols = tableRow.querySelectorAll('td'), + colNode, + col, + data = {}, + i, + val; + for (i = 0; i < tableCols.length; i += 1) { + colNode = tableCols[i]; + col = cols[i]; + val = colNode.getAttribute('data-value'); + if (col.type === 'number') { + val = Number(val); + } + data[col.key] = val; + } + return data; + } + // loads all row data + function loadData() { + var rows = getTableBody().querySelectorAll('tr'), + i; + + for (i = 0; i < rows.length; i += 1) { + rows[i].data = loadRowData(rows[i]); + } + } + // sorts the table using the data for the ith column + function sortByIndex(index, desc) { + var key = cols[index].key, + sorter = function(a, b) { + a = a.data[key]; + b = b.data[key]; + return a < b ? -1 : a > b ? 1 : 0; + }, + finalSorter = sorter, + tableBody = document.querySelector('.coverage-summary tbody'), + rowNodes = tableBody.querySelectorAll('tr'), + rows = [], + i; + + if (desc) { + finalSorter = function(a, b) { + return -1 * sorter(a, b); + }; + } + + for (i = 0; i < rowNodes.length; i += 1) { + rows.push(rowNodes[i]); + tableBody.removeChild(rowNodes[i]); + } + + rows.sort(finalSorter); + + for (i = 0; i < rows.length; i += 1) { + tableBody.appendChild(rows[i]); + } + } + // removes sort indicators for current column being sorted + function removeSortIndicators() { + var col = getNthColumn(currentSort.index), + cls = col.className; + + cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); + col.className = cls; + } + // adds sort indicators for current column being sorted + function addSortIndicators() { + getNthColumn(currentSort.index).className += currentSort.desc + ? ' sorted-desc' + : ' sorted'; + } + // adds event listeners for all sorter widgets + function enableUI() { + var i, + el, + ithSorter = function ithSorter(i) { + var col = cols[i]; + + return function() { + var desc = col.defaultDescSort; + + if (currentSort.index === i) { + desc = !currentSort.desc; + } + sortByIndex(i, desc); + removeSortIndicators(); + currentSort.index = i; + currentSort.desc = desc; + addSortIndicators(); + }; + }; + for (i = 0; i < cols.length; i += 1) { + if (cols[i].sortable) { + // add the click event handler on the th so users + // dont have to click on those tiny arrows + el = getNthColumn(i).querySelector('.sorter').parentElement; + if (el.addEventListener) { + el.addEventListener('click', ithSorter(i)); + } else { + el.attachEvent('onclick', ithSorter(i)); + } + } + } + } + // adds sorting functionality to the UI + return function() { + if (!getTable()) { + return; + } + cols = loadColumns(); + loadData(); + addSortIndicators(); + enableUI(); + }; +})(); + +window.addEventListener('load', addSorting); diff --git a/server-api/coverage/lcov.info b/server-api/coverage/lcov.info new file mode 100644 index 0000000..0d50628 --- /dev/null +++ b/server-api/coverage/lcov.info @@ -0,0 +1,530 @@ +TN: +SF:server.js +FNF:0 +FNH:0 +DA:1,4 +DA:2,4 +DA:5,4 +DA:6,4 +DA:7,4 +DA:8,4 +DA:9,4 +DA:12,4 +DA:13,4 +DA:14,4 +DA:16,4 +DA:17,4 +DA:18,4 +DA:21,4 +DA:29,4 +DA:35,4 +DA:36,4 +DA:37,4 +DA:38,4 +DA:39,4 +DA:40,4 +DA:41,4 +DA:44,4 +DA:45,4 +DA:46,4 +DA:52,4 +DA:53,4 +DA:54,4 +DA:59,4 +DA:71,4 +DA:73,4 +DA:75,4 +LF:32 +LH:32 +BRDA:23,0,0,0 +BRDA:23,0,1,4 +BRF:2 +BRH:1 +end_of_record +TN: +SF:db/build.js +FN:7,build +FNF:1 +FNH:1 +FNDA:11,build +DA:1,4 +DA:2,4 +DA:3,4 +DA:5,4 +DA:8,11 +DA:13,4 +DA:14,0 +DA:15,0 +DA:16,0 +DA:19,4 +LF:10 +LH:7 +BRDA:13,0,0,0 +BRDA:13,0,1,4 +BRF:2 +BRH:1 +end_of_record +TN: +SF:db/connection.js +FNF:0 +FNH:0 +DA:1,4 +DA:2,4 +DA:3,4 +DA:5,4 +DA:10,4 +LF:5 +LH:5 +BRF:0 +BRH:0 +end_of_record +TN: +SF:handlers/customer-location-h.js +FN:4,allCustomerLocations +FN:8,(anonymous_1) +FN:14,addNewCustomerLocation +FN:22,(anonymous_3) +FNF:4 +FNH:2 +FNDA:1,allCustomerLocations +FNDA:1,(anonymous_1) +FNDA:0,addNewCustomerLocation +FNDA:0,(anonymous_3) +DA:1,4 +DA:6,1 +DA:9,1 +DA:15,0 +DA:16,0 +DA:17,0 +DA:18,0 +DA:20,0 +DA:23,0 +DA:24,0 +DA:44,4 +LF:11 +LH:4 +BRF:0 +BRH:0 +end_of_record +TN: +SF:handlers/customers-h.js +FN:10,allCustomers +FN:13,(anonymous_1) +FN:19,createCustomer +FN:32,(anonymous_3) +FN:33,(anonymous_4) +FN:36,(anonymous_5) +FN:45,loginCustomer +FN:51,(anonymous_7) +FN:52,(anonymous_8) +FN:70,getSpecificCustomer +FN:74,(anonymous_10) +FNF:11 +FNH:0 +FNDA:0,allCustomers +FNDA:0,(anonymous_1) +FNDA:0,createCustomer +FNDA:0,(anonymous_3) +FNDA:0,(anonymous_4) +FNDA:0,(anonymous_5) +FNDA:0,loginCustomer +FNDA:0,(anonymous_7) +FNDA:0,(anonymous_8) +FNDA:0,getSpecificCustomer +FNDA:0,(anonymous_10) +DA:1,4 +DA:2,4 +DA:3,4 +DA:5,4 +DA:6,4 +DA:8,4 +DA:11,0 +DA:14,0 +DA:20,0 +DA:30,0 +DA:32,0 +DA:34,0 +DA:37,0 +DA:40,0 +DA:46,0 +DA:47,0 +DA:49,0 +DA:52,0 +DA:53,0 +DA:54,0 +DA:57,0 +DA:58,0 +DA:60,0 +DA:63,0 +DA:71,0 +DA:72,0 +DA:75,0 +DA:80,4 +LF:28 +LH:7 +BRDA:53,0,0,0 +BRDA:53,0,1,0 +BRF:2 +BRH:0 +end_of_record +TN: +SF:handlers/vendor-location-h.js +FN:3,allVendorLocations +FN:6,(anonymous_1) +FN:12,addNewVendorLocation +FN:19,(anonymous_3) +FNF:4 +FNH:0 +FNDA:0,allVendorLocations +FNDA:0,(anonymous_1) +FNDA:0,addNewVendorLocation +FNDA:0,(anonymous_3) +DA:1,4 +DA:4,0 +DA:7,0 +DA:13,0 +DA:14,0 +DA:15,0 +DA:17,0 +DA:20,0 +DA:25,4 +LF:9 +LH:2 +BRF:0 +BRH:0 +end_of_record +TN: +SF:handlers/vendor-routes-h.js +FN:3,createNewRoute +FN:4,(anonymous_1) +FN:8,(anonymous_2) +FN:17,(anonymous_3) +FN:18,(anonymous_4) +FN:26,getRoute +FN:31,(anonymous_6) +FN:37,deleteRoute +FN:41,(anonymous_8) +FNF:9 +FNH:5 +FNDA:1,createNewRoute +FNDA:1,(anonymous_1) +FNDA:3,(anonymous_2) +FNDA:1,(anonymous_3) +FNDA:3,(anonymous_4) +FNDA:0,getRoute +FNDA:0,(anonymous_6) +FNDA:0,deleteRoute +FNDA:0,(anonymous_8) +DA:1,4 +DA:4,1 +DA:5,1 +DA:6,0 +DA:8,1 +DA:9,3 +DA:16,1 +DA:18,3 +DA:19,1 +DA:27,0 +DA:29,0 +DA:32,0 +DA:38,0 +DA:39,0 +DA:41,0 +DA:45,4 +LF:16 +LH:9 +BRDA:5,0,0,0 +BRDA:5,0,1,1 +BRF:2 +BRH:1 +end_of_record +TN: +SF:handlers/vendors-h.js +FN:10,allVendors +FN:13,(anonymous_1) +FN:19,getSpecificVendor +FN:23,(anonymous_3) +FN:27,createVendor +FN:40,(anonymous_5) +FN:41,(anonymous_6) +FN:42,(anonymous_7) +FN:51,loginVendor +FN:57,(anonymous_9) +FN:58,(anonymous_10) +FNF:11 +FNH:0 +FNDA:0,allVendors +FNDA:0,(anonymous_1) +FNDA:0,getSpecificVendor +FNDA:0,(anonymous_3) +FNDA:0,createVendor +FNDA:0,(anonymous_5) +FNDA:0,(anonymous_6) +FNDA:0,(anonymous_7) +FNDA:0,loginVendor +FNDA:0,(anonymous_9) +FNDA:0,(anonymous_10) +DA:1,4 +DA:2,4 +DA:3,4 +DA:5,4 +DA:6,4 +DA:8,4 +DA:11,0 +DA:14,0 +DA:20,0 +DA:21,0 +DA:23,0 +DA:28,0 +DA:38,0 +DA:40,0 +DA:41,0 +DA:43,0 +DA:46,0 +DA:52,0 +DA:53,0 +DA:55,0 +DA:58,0 +DA:59,0 +DA:60,0 +DA:61,0 +DA:62,0 +DA:64,0 +DA:67,0 +DA:74,4 +LF:28 +LH:7 +BRDA:59,0,0,0 +BRDA:59,0,1,0 +BRF:2 +BRH:0 +end_of_record +TN: +SF:middleware/auth.js +FN:9,verifyCustomer +FN:22,(anonymous_1) +FN:34,verifyVendor +FN:48,(anonymous_3) +FNF:4 +FNH:0 +FNDA:0,verifyCustomer +FNDA:0,(anonymous_1) +FNDA:0,verifyVendor +FNDA:0,(anonymous_3) +DA:1,4 +DA:2,4 +DA:3,4 +DA:5,4 +DA:7,4 +DA:10,0 +DA:11,0 +DA:12,0 +DA:13,0 +DA:14,0 +DA:16,0 +DA:17,0 +DA:18,0 +DA:19,0 +DA:20,0 +DA:23,0 +DA:24,0 +DA:28,0 +DA:29,0 +DA:30,0 +DA:35,0 +DA:36,0 +DA:37,0 +DA:38,0 +DA:39,0 +DA:40,0 +DA:42,0 +DA:43,0 +DA:44,0 +DA:45,0 +DA:46,0 +DA:49,0 +DA:50,0 +DA:54,0 +DA:55,0 +DA:56,0 +DA:60,4 +LF:37 +LH:6 +BRDA:11,0,0,0 +BRDA:11,0,1,0 +BRDA:37,1,0,0 +BRDA:37,1,1,0 +BRF:4 +BRH:0 +end_of_record +TN: +SF:middleware/handleError.js +FN:4,handleError +FN:12,(anonymous_1) +FNF:2 +FNH:0 +FNDA:0,handleError +FNDA:0,(anonymous_1) +DA:1,4 +DA:5,0 +DA:6,0 +DA:7,0 +DA:8,0 +DA:9,0 +DA:10,0 +DA:12,0 +DA:13,0 +DA:20,4 +LF:10 +LH:2 +BRDA:6,0,0,0 +BRDA:6,0,1,0 +BRDA:9,1,0,0 +BRDA:9,1,1,0 +BRF:4 +BRH:0 +end_of_record +TN: +SF:middleware/logger.js +FN:1,logger +FNF:1 +FNH:1 +FNDA:2,logger +DA:2,2 +DA:3,2 +DA:4,2 +DA:7,4 +LF:4 +LH:4 +BRF:0 +BRH:0 +end_of_record +TN: +SF:model/customer-location-m.js +FN:3,getAllCustomerLocations +FN:6,(anonymous_1) +FN:9,addNewCustomerLocation +FNF:3 +FNH:3 +FNDA:4,getAllCustomerLocations +FNDA:4,(anonymous_1) +FNDA:1,addNewCustomerLocation +DA:1,4 +DA:4,4 +DA:6,4 +DA:10,1 +DA:16,4 +LF:5 +LH:5 +BRF:0 +BRH:0 +end_of_record +TN: +SF:model/customers-m.js +FN:3,getAllCustomers +FN:4,(anonymous_1) +FN:7,getCustomer +FN:11,(anonymous_3) +FN:12,(anonymous_4) +FN:15,getSpecificCustomer +FN:18,(anonymous_6) +FN:21,createCustomer +FNF:8 +FNH:0 +FNDA:0,getAllCustomers +FNDA:0,(anonymous_1) +FNDA:0,getCustomer +FNDA:0,(anonymous_3) +FNDA:0,(anonymous_4) +FNDA:0,getSpecificCustomer +FNDA:0,(anonymous_6) +FNDA:0,createCustomer +DA:1,4 +DA:4,0 +DA:8,0 +DA:9,0 +DA:11,0 +DA:12,0 +DA:16,0 +DA:18,0 +DA:22,0 +DA:36,4 +LF:10 +LH:2 +BRF:0 +BRH:0 +end_of_record +TN: +SF:model/vendor-location-m.js +FN:3,getAllVendorLocations +FN:6,(anonymous_1) +FN:9,addNewVendorLocation +FNF:3 +FNH:0 +FNDA:0,getAllVendorLocations +FNDA:0,(anonymous_1) +FNDA:0,addNewVendorLocation +DA:1,4 +DA:4,0 +DA:6,0 +DA:10,0 +DA:16,4 +LF:5 +LH:2 +BRF:0 +BRH:0 +end_of_record +TN: +SF:model/vendor-routes-m.js +FN:3,createNewRouteStop +FN:17,getAllStopsInOneRoute +FN:23,(anonymous_2) +FN:26,deleteRoute +FNF:4 +FNH:3 +FNDA:4,createNewRouteStop +FNDA:1,getAllStopsInOneRoute +FNDA:1,(anonymous_2) +FNDA:0,deleteRoute +DA:1,4 +DA:4,4 +DA:18,1 +DA:23,1 +DA:27,0 +DA:32,4 +LF:6 +LH:5 +BRF:0 +BRH:0 +end_of_record +TN: +SF:model/vendors-m.js +FN:3,getAllVendors +FN:4,(anonymous_1) +FN:7,getVendorLogin +FN:10,(anonymous_3) +FN:13,getSpecificVendor +FN:16,(anonymous_5) +FN:19,createVendor +FNF:7 +FNH:3 +FNDA:0,getAllVendors +FNDA:0,(anonymous_1) +FNDA:1,getVendorLogin +FNDA:1,(anonymous_3) +FNDA:0,getSpecificVendor +FNDA:0,(anonymous_5) +FNDA:1,createVendor +DA:1,4 +DA:4,0 +DA:8,1 +DA:10,1 +DA:14,0 +DA:16,0 +DA:20,1 +DA:34,4 +LF:8 +LH:5 +BRF:0 +BRH:0 +end_of_record diff --git a/server-api/handlers/customer-location-h.js b/server-api/handlers/customer-location-h.js index 8b3a5a3..747e079 100644 --- a/server-api/handlers/customer-location-h.js +++ b/server-api/handlers/customer-location-h.js @@ -1,47 +1,30 @@ -const model = require("../model/customer-location-m") +const model = require("../model/customer-location-m"); // const geo = navigator.geolocation maybe need to add window.navigator.geolocation? function allCustomerLocations(req, res, next) { - // console.log("In function") model .getAllCustomerLocations() .then((allLocations) => { - res.send(allLocations) + res.send(allLocations); }) - .catch(next) + .catch(next); } function addNewCustomerLocation(req, res, next) { - const customerId = req.body.customerId - const lat = req.body.latitude - const lng = req.body.longitude - const temp = req.body.temperature + const customerId = req.body.customerId; + const lat = req.body.latitude; + const lng = req.body.longitude; + const temp = req.body.temperature; model .addNewCustomerLocation(customerId, lat, lng, temp) .then((RETURNING) => { - console.log(RETURNING) - res.send(RETURNING.rows[0]) + res.send(RETURNING.rows[0]); }) - .catch(next) + .catch(next); } -// function addNewCustomerLocation(customer, req, res, next) { -// // Has the customer already entered a request in the last half an hour? -// let result = customerLocationModel.getAllCustomerLocations( -// " WHERE time >= NOW() - INTERVAL '30 minutes'" -// ) -// if (result) console.log("You have already made an entry") -// else { -// const customerId = customer || 5 // This value is taken from the request body or url using req.params -// const position = geo.getCurrentPosition // Getting coordinates will be done on the frontend -// const lat = position.coords.latitude -// const lng = position.coords.lng -// customerLocationModel.addCustomerLocation(customerId, lat, lng) -// } -// } - module.exports = { addNewCustomerLocation, allCustomerLocations, -} +}; diff --git a/server-api/middleware/auth.js b/server-api/middleware/auth.js index 58c1571..23c9150 100644 --- a/server-api/middleware/auth.js +++ b/server-api/middleware/auth.js @@ -1,60 +1,57 @@ -const jwt = require("jsonwebtoken") -const customerModel = require("../model/customers-m") -const vendorModel = require("../model/vendors-m") +const jwt = require("jsonwebtoken"); +const customerModel = require("../model/customers-m"); +const vendorModel = require("../model/vendors-m"); -require("dotenv").config() +require("dotenv").config(); -const SECRET = process.env.JWT_SECRET +const SECRET = process.env.JWT_SECRET; function verifyCustomer(req, res, next) { - const authHeader = req.headers.authorization + const authHeader = req.headers.authorization; if (!authHeader) { - const error = new Error("Authorization header required") //look into this - error.status = 400 - next(error) + const error = new Error("Authorization header required"); //look into this + error.status = 400; + next(error); } - const token = authHeader.replace("Bearer ", "") + const token = authHeader.replace("Bearer ", ""); try { - const data = jwt.verify(token, SECRET) - console.log(data) + const data = jwt.verify(token, SECRET); customerModel .getSpecificCustomer(data.user) .then((user) => { - req.user = user - next() + req.user = user; + next(); }) - .catch(next) + .catch(next); } catch (_err) { - const error = new Error("Unauthorized") - error.status = 401 - next(error) + const error = new Error("Unauthorized"); + error.status = 401; + next(error); } } function verifyVendor(req, res, next) { - const authHeader = req.headers.authorization - console.log("autheheader" + authHeader) + const authHeader = req.headers.authorization; if (!authHeader) { - const error = new Error("Authorization header required") //look into this - error.status = 400 - next(error) + const error = new Error("Authorization header required"); //look into this + error.status = 400; + next(error); } - const token = authHeader.replace("Bearer ", "") + const token = authHeader.replace("Bearer ", ""); try { - const data = jwt.verify(token, SECRET) - console.log("data" + data) + const data = jwt.verify(token, SECRET); vendorModel .getSpecificVendor(data.user) .then((user) => { - req.user = user - next() + req.user = user; + next(); }) - .catch(next) + .catch(next); } catch (_) { - const error = new Error("Unauthorized") - error.status = 401 - next(error) + const error = new Error("Unauthorized"); + error.status = 401; + next(error); } } -module.exports = { verifyCustomer, verifyVendor } +module.exports = { verifyCustomer, verifyVendor }; diff --git a/server-api/model/customers-m.js b/server-api/model/customers-m.js index 57f358f..55ee0bf 100644 --- a/server-api/model/customers-m.js +++ b/server-api/model/customers-m.js @@ -1,21 +1,20 @@ -const db = require("../db/connection") +const db = require("../db/connection"); function getAllCustomers() { - return db.query(`SELECT * FROM customers;`).then((results) => results.rows) + return db.query(`SELECT * FROM customers;`).then((results) => results.rows); } function getCustomer(email) { - console.log("getCustomer -> email", email) return db .query(`SELECT * FROM customers WHERE email=($1)`, [email]) .then((user) => user.rows[0]) - .catch((error) => error) + .catch((error) => error); } function getSpecificCustomer(id) { return db .query(`SELECT * FROM customers WHERE id=($1)`, [id]) - .then((user) => user.rows[0]) + .then((user) => user.rows[0]); } function createCustomer(newCustomer) { @@ -30,7 +29,7 @@ function createCustomer(newCustomer) { newCustomer.gender, newCustomer.icecreamFlavour, ] - ) + ); } module.exports = { @@ -38,4 +37,4 @@ module.exports = { getCustomer, getSpecificCustomer, createCustomer, -} +}; diff --git a/server-api/model/vendors-m.js b/server-api/model/vendors-m.js index bdddac9..249d078 100644 --- a/server-api/model/vendors-m.js +++ b/server-api/model/vendors-m.js @@ -17,7 +17,6 @@ function getSpecificVendor(vendorId) { } function createVendor(vendor) { - console.log("createVendor -> vendor", vendor); return db.query( `INSERT INTO vendors(name, email, password, mobile, company_name, alcohol, vegan_option) VALUES ($1,$2,$3,$4,$5,$6,$7) RETURNING id, name, password;`, [ diff --git a/server-api/package.json b/server-api/package.json index 00b70d4..062183b 100644 --- a/server-api/package.json +++ b/server-api/package.json @@ -4,8 +4,9 @@ "private": true, "scripts": { "start": "nodemon index.js", - "test": "jest PGDATABASE=student_project_test_db tests/*.test.js", + "test": "jest --coverage PGDATABASE=student_project_test_db tests/*.test.js", "test-watch": "jest --watch PGDATABASE=student_project_test_db tests/*.test.js", + "test-cov": "jest --coverage PGDATABASE=student_project_test_db tests/*.test.js", "initdb": "node db/build.js" }, "dependencies": {