Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 84 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,84 @@
# Reto Completado
# Prueba de acceso a core-code.io v20.06.11

Welcome to Core Code entry challenge.

Please follow the instructions and submit them before 2020/06/24.

## Instructions

### 1. Haz un fork de este repositorio

Una vez creado el fork, clonarás el proyecto en tu máquina y crearás un file: `./src/client.ts` que haga lo siguiente:

### 2. Send a POST request to `http://95.217.235.69/` with the following data:

```
contactInfo: {
fullName: "",
emailAddress: "",
},
github: {
profileURL: "",
username: "",
},
credentials: {
password: "Cambia esta contraseña a una que sólo tú sepas",
},
personalInfo: {
questions: [
{
question: "If I was a Sr. Programmer, I would like to build:",
answer: "Respuesta: ...",
},
{
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: ...",
},
{
question: "code is poetry, because:",
answer: "Respuesta: ...",
},
],
},
```

### 2. Verify that your information was saved successfully

Send a GET request to the URL `http://95.217.235.69/:emailAddress` with the following headers:

```
{
"Content-Type": "application/json",
"x-password": "tu contraseña especificada en el paso anterior"
}
```

The URL param `emailAddress` should be the email address you specified in the previous POST request.

### 3. Ya casi

You should get a response with a valid `claveDeAcceso`.

### 4. Crea un pull-request de tu fork al repo original

Tu branch deberá llamarse: `<github-username>/entry-challenge`, y el pull-request deberá asignarse hacia `master` del repo original.

### 5. Envía la contraseña y la solución

Send an email to `gus@core-code.io`, cc'd to `sc@core-code.io`, with the following information:

Asunto: `emailAddress@claveDeAcceso`

El cuerpo del mensaje debe contener un link al pull-request.

### 6. Espera los comentarios

y resuélvelos hasta que tu PR sea aprobado.

### 5. Espera la invitación de Github a tu correo registrado (Si no la recibes, es porque no te hemos aceptado)

Agregaremos tu usuario de Github a la organización de [corecodeio](https://github.com/corecodeio).
También te agendaremos una reunión de bienvenida para el día 29 de junio.

### Estás muy cerca de comenzar tu carrera de Software con Core Code.
1 change: 1 addition & 0 deletions password.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
YwQuIzgsSTyDURgXq9Ot
Comment thread
saullopezc marked this conversation as resolved.
Outdated
Comment thread
saullopezc marked this conversation as resolved.
Outdated
89 changes: 34 additions & 55 deletions src/client.ts
Original file line number Diff line number Diff line change
@@ -1,62 +1,41 @@
const axios = require('axios');

const data = {
"contactInfo": {
"fullName": "Saul Lopez",
"emailAddress": "saullopezc@gmail.com"
},
"github": {
"profileURL": "https://github.com/saullopezc",
"username": "saullopezc"
},
"credentials": {
"password": "YwQuIzgsSTyDURgXq9Ot"
},
"personalInfo": {
"questions": [
{
"question": "If I was a Sr. Programmer, I would like to build:",
"answer": "Paquetes o librerias "
},
{
"question": "Por favor indica el URL que me lleva a la línea de código de la definición de React.useEffect",
"answer": "https://es.reactjs.org/docs/hooks-reference.html#useeffect"
},
{
"question": "code is poetry, because:",
"answer": "Por la expresion y la belleza del codigo"
}
]
}
};
import axios from 'axios';
import data from './data';
import getPassword from './function/pass'

export const createProfile = async () => {
try {
const res = await axios.post('http://95.217.235.69/', data);
console.log(`Status: ${res.status}`);
console.log('Body: ', res.data);
listProfile();
} catch (err) {
console.error(err);
}

axios.post('http://95.217.235.69/', data).then(
res => {
console.log(`Status: ${res.status}`);
console.log('Body: ', res.data);
listProfile();
}
)
.catch((err) => {
console.error('error ' + err);
});
};

export const listProfile = () => {
Comment thread
areyes107 marked this conversation as resolved.
Outdated


console.log(getPassword());
const URL = "http://95.217.235.69/saullopezc@gmail.com"
/*var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("x-password", "YwQuIzgsSTyDURgXq9Ot");
console.log(myHeaders);*/
axios.get(URL, {
headers: {"x-password": "YwQuIzgsSTyDURgXq9Ot", "Content-Type": "application/json" }})
.then(response => {
// If request is good...
console.log(response.data);

})
.catch((error) => {
console.log('error ' + error);
});

};
axios.get(URL,
{ headers: { "x-password": getPassword(), "Content-Type": "application/json" } }
)
.then(res => {
console.log(res.data);

})
.catch((error) => {
console.log('error ' + error);
});

};

const ejecutar_cliente = () => {
console.log(createProfile());
};

ejecutar_cliente();
Comment thread
saullopezc marked this conversation as resolved.
Outdated
33 changes: 33 additions & 0 deletions src/data/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import getPassword from './../function/pass';

const data = {
"contactInfo": {
"fullName": "Saul Lopez",
"emailAddress": "saullopezc@gmail.com"
},
"github": {
"profileURL": "https://github.com/saullopezc",
"username": "saullopezc"
},
"credentials": {
"password": getPassword()
},
"personalInfo": {
"questions": [
{
"question": "If I was a Sr. Programmer, I would like to build:",
"answer": "Paquetes o librerias "
},
{
"question": "Por favor indica el URL que me lleva a la línea de código de la definición de React.useEffect",
"answer": "https://es.reactjs.org/docs/hooks-reference.html#useeffect"
},
{
"question": "code is poetry, because:",
"answer": "Por la expresion y la belleza del codigo"
Comment thread
saullopezc marked this conversation as resolved.
Outdated
}
]
}
};

export default data;
12 changes: 12 additions & 0 deletions src/function/pass.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import LeerArchivo from './readfile';

const path = "password.txt"

const getPassword = () => {
return LeerArchivo(path);
}

export default getPassword;



16 changes: 16 additions & 0 deletions src/function/readfile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import fs from 'fs';

const LeerArchivo = path => {

const data = ""
fs.readFile(path, 'utf-8', (err, data) => {
if (err) {
console.log("error " + err);
};

});

return data;
};

export default LeerArchivo;
8 changes: 0 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import express from "express";
import fs from "fs";
import schema from "./schema.json";
import server from "./server";
import {listProfile ,createProfile} from "./client";


export const router = express.Router({
strict: true,
Expand Down Expand Up @@ -92,9 +90,3 @@ server.post("/", async (req: Request, res: Response) => {
server.listen("80", () => {
console.log("listening");
});

const ejecutar_cliente = () => {
console.log(createProfile());
};

ejecutar_cliente();