diff --git a/.gitignore b/.gitignore index a91eeca..0099829 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,4 @@ /node_modules /dist -/data -src/client.ts \ No newline at end of file +/variables.env \ No newline at end of file diff --git a/package.json b/package.json index 2bc6d97..9d95544 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Applicants must complete this challenge to enter core-code.io v1", "main": "index.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", + "test": "ts-node-dev --no-notify --respawn ./src/client", "start": "ts-node-dev --no-notify --respawn ./src", "start:debug": "ts-node-dev --inspect --no-notify --respawn ./src" }, @@ -14,6 +14,7 @@ "ajv": "^6.12.2", "axios": "^0.19.2", "bcryptjs": "^2.4.3", + "dotenv": "^8.2.0", "express": "^4.17.1", "ts-node-dev": "^1.0.0-pre.44" }, @@ -26,4 +27,4 @@ "@types/node": "^14.0.13", "typescript": "^3.9.5" } -} +} \ No newline at end of file diff --git a/src/client.ts b/src/client.ts new file mode 100644 index 0000000..b361792 --- /dev/null +++ b/src/client.ts @@ -0,0 +1,36 @@ +import axios from "axios"; +import dotenv from "dotenv"; +dotenv.config({ path: "variables.env" }); +import data from "./data"; +import server from "./server"; + +const url = "http://95.217.235.69/"; + +server.post("/sendInformation", async (req, res) => { + try { + let result = await axios.post(url, data); + res.json(result.data); + } catch (error) { + return error; + } +}); + +server.get("/getKey/:email", async (req, res) => { + try { + let endpoint = url + req.params.email; + let options = { + headers: { + "x-password": process.env.PASS, + "Content-Type": "application/json", + }, + }; + let result = await axios.get(endpoint, options); + res.json(result.data); + } catch (error) { + return error; + } +}); + +server.listen("8081", () => { + console.log("listening 8081"); +}); diff --git a/src/data.ts b/src/data.ts new file mode 100644 index 0000000..500258b --- /dev/null +++ b/src/data.ts @@ -0,0 +1,34 @@ +const data = { + contactInfo: { + fullName: "Oscar Enrique Muñoz Lima", + emailAddress: "cok.kike@gmail.com", + }, + github: { + profileURL: "https://github.com/cokkike88", + username: "cokkike88", + }, + credentials: { + password: process.env.PASS, + }, + personalInfo: { + questions: [ + { + question: "If I was a Sr. Programmer, I would like to build:", + answer: + "Respuesta: Some application with microservices with aws lambda, with neptuno database, nodejs as backend, reactjs as frontend, aws cognito for authentication and authorization, aws s3 to resources storage, aws api gateway", + }, + { + question: + "Por favor indica el URL que me lleva a la línea de código de la definición de React.useEffect", + answer: "Respuesta: https://es.reactjs.org/docs/hooks-reference.html#useeffect", + }, + { + question: "code is poetry, because:", + answer: + "Respuesta: Because we can build anything that we want and we can do that the world change.", + }, + ], + }, +}; + +export default data; diff --git a/yarn.lock b/yarn.lock index a12cac9..bc63c18 100644 --- a/yarn.lock +++ b/yarn.lock @@ -202,6 +202,11 @@ diff@^4.0.1: resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== +dotenv@^8.2.0: + version "8.2.0" + resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.2.0.tgz#97e619259ada750eea3e4ea3e26bceea5424b16a" + integrity sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw== + dynamic-dedupe@^0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/dynamic-dedupe/-/dynamic-dedupe-0.3.0.tgz#06e44c223f5e4e94d78ef9db23a6515ce2f962a1"