chore(i18n,curriculum): processed translations (#44193)

This commit is contained in:
camperbot
2021-11-17 06:20:53 -08:00
committed by GitHub
parent 8812e6b3ac
commit 9f9fb63caa
47 changed files with 417 additions and 413 deletions

View File

@ -1,6 +1,6 @@
---
id: 589690e6f9fc0f352b528e6e
title: Clean Up Your Project with Modules
title: Limpia tu proyecto con módulos
challengeType: 2
forumTopicId: 301549
dashedName: clean-up-your-project-with-modules
@ -8,9 +8,9 @@ dashedName: clean-up-your-project-with-modules
# --description--
Right now, everything you have is in your `server.js` file. This can lead to hard to manage code that isn't very expandable. Create 2 new files: `routes.js` and `auth.js`
Ahora mismo, todo lo que tienes está en tu archivo `server.js`. Esto puede dar lugar a un código difícil de gestionar y poco ampliable. Crea 2 nuevos archivos: `routes.js` y `auth.js`
Both should start with the following code:
Ambos deben comenzar con el siguiente código:
```js
module.exports = function (app, myDataBase) {
@ -18,19 +18,19 @@ module.exports = function (app, myDataBase) {
}
```
Now, in the top of your server file, require these files like so: `const routes = require('./routes.js');` Right after you establish a successful connection with the database, instantiate each of them like so: `routes(app, myDataBase)`
Ahora, en la parte superior de tu archivo de servidor, requiere estos archivos así: `const routes = require('./routes.js');` Justo después de establecer una conexión exitosa con la base de datos, instancia cada uno de ellos así: `routes(app, myDataBase)`
Finally, take all of the routes in your server and paste them into your new files, and remove them from your server file. Also take the `ensureAuthenticated` function, since it was specifically created for routing. Now, you will have to correctly add the dependencies in which are used, such as `const passport = require('passport');`, at the very top, above the export line in your `routes.js` file.
Finalmente, toma todas las rutas de tu servidor y pégalas en tus nuevos archivos, y elimínalas de tu archivo del servidor. También toma la función `ensureAuthenticated` ya que fue específicamente creada para enrutamiento. Ahora, tendrás que agregar correctamente las dependencias en las que se utilizan, como `const passport = require('passport');`, en la parte superior, encima de la línea de exportación en tu archivo `routes.js`.
Keep adding them until no more errors exist, and your server file no longer has any routing (**except for the route in the catch block**)!
Sigue agregándolos hasta que no existan más errores, y tu archivo de servidor ya no tenga ninguna ruta ¡(**excepto la ruta en el bloque catch**)!
Now do the same thing in your auth.js file with all of the things related to authentication such as the serialization and the setting up of the local strategy and erase them from your server file. Be sure to add the dependencies in and call `auth(app, myDataBase)` in the server in the same spot.
Ahora haz lo mismo en tu archivo auth.js con todas las cosas relacionadas con la autenticación como la serialización y la configuración de la estrategia local y bórralas de tu archivo del servidor. Asegúrate de agregar las dependencias y llamar a `auth(app, myDataBase)` en el servidor en el mismo lugar.
Submit your page when you think you've got it right. If you're running into errors, you can check out an example of the completed project [here](https://gist.github.com/camperbot/2d06ac5c7d850d8cf073d2c2c794cc92).
Envía tu página cuando creas que lo has hecho bien. Si te encuentras con errores, puedes revisar un ejemplo del proyecto completado [aquí](https://gist.github.com/camperbot/2d06ac5c7d850d8cf073d2c2c794cc92).
# --hints--
Modules should be present.
Los módulos deben estar presentes.
```js
(getUserInput) =>

View File

@ -1,6 +1,6 @@
---
id: 589fc831f9fc0f352b528e75
title: Communicate by Emitting
title: Comunicarse por emisión
challengeType: 2
forumTopicId: 301550
dashedName: communicate-by-emitting
@ -8,27 +8,27 @@ dashedName: communicate-by-emitting
# --description--
<dfn>Emit</dfn> is the most common way of communicating you will use. When you emit something from the server to 'io', you send an event's name and data to all the connected sockets. A good example of this concept would be emitting the current count of connected users each time a new user connects!
<dfn>Emit</dfn> es la forma más común de comunicación que utilizarás. Cuando se emite algo desde el servidor a 'io', se envía el nombre y los datos de un evento a todos los sockets conectados. ¡Un buen ejemplo de este concepto sería emitir el recuento actual de usuarios conectados cada vez que se conecte un nuevo usuario!
Start by adding a variable to keep track of the users, just before where you are currently listening for connections.
Comienza añadiendo una variable para llevar la cuenta de los usuarios, justo antes de donde estás escuchando las conexiones.
```js
let currentUsers = 0;
```
Now, when someone connects, you should increment the count before emitting the count. So, you will want to add the incrementer within the connection listener.
Ahora, cuando alguien se conecte, deberás incrementar la cuenta antes de emitirla. Por lo tanto, querrá añadir el incrementador dentro del oyente de la conexión.
```js
++currentUsers;
```
Finally, after incrementing the count, you should emit the event (still within the connection listener). The event should be named 'user count', and the data should just be the `currentUsers`.
Por último, después de incrementar el recuento, debes emitir el evento (todavía dentro del oyente de la conexión). El evento debe llamarse 'user count', y los datos deben ser simplemente los `currentUsers`.
```js
io.emit('user count', currentUsers);
```
Now, you can implement a way for your client to listen for this event! Similar to listening for a connection on the server, you will use the `on` keyword.
Ahora, ¡puedes implementar una manera para que tu cliente escuche este evento! De forma similar a la escucha de una conexión en el servidor, utilizarás la palabra clave `on`.
```js
socket.on('user count', function(data) {
@ -36,13 +36,13 @@ socket.on('user count', function(data) {
});
```
Now, try loading up your app, authenticate, and you should see in your client console '1' representing the current user count! Try loading more clients up, and authenticating to see the number go up.
Ahora, ¡intenta cargar tu aplicación, autentifica, y debes ver en tu consola "1" que representa el recuento de usuarios actual! Trata de cargar más clientes y de autentificar para ver cómo sube el número.
Submit your page when you think you've got it right. If you're running into errors, you can check out the project completed up to this point [here](https://gist.github.com/camperbot/28ef7f1078f56eb48c7b1aeea35ba1f5).
Envía tu página cuando creas que lo has hecho bien. Si te encuentras con errores, puedes revisar el proyecto completado hasta este punto [aquí](https://gist.github.com/camperbot/28ef7f1078f56eb48c7b1aeea35ba1f5).
# --hints--
currentUsers should be defined.
currentUsers deben ser definidos.
```js
(getUserInput) =>
@ -60,7 +60,7 @@ currentUsers should be defined.
);
```
Server should emit the current user count at each new connection.
El servidor debe emitir el recuento actual de usuarios en cada nueva conexión.
```js
(getUserInput) =>
@ -78,7 +78,7 @@ Server should emit the current user count at each new connection.
);
```
Your client should be listening for 'user count' event.
Tu cliente debe estar escuchando el evento 'user count'.
```js
(getUserInput) =>

View File

@ -1,6 +1,6 @@
---
id: 5895f70df9fc0f352b528e6a
title: Create New Middleware
title: Crea nuevo Middleware
challengeType: 2
forumTopicId: 301551
dashedName: create-new-middleware
@ -8,9 +8,9 @@ dashedName: create-new-middleware
# --description--
As is, any user can just go to `/profile` whether they have authenticated or not, by typing in the url. We want to prevent this, by checking if the user is authenticated first before rendering the profile page. This is the perfect example of when to create a middleware.
Tal como está, cualquier usuario puede ir a `/profile` si se ha autentificado o no, escribiendo la url. Queremos evitar esto, comprobando si el usuario está autentificado primero antes de mostrar la página de perfil. Este es el ejemplo perfecto de cuándo crear un middleware.
The challenge here is creating the middleware function `ensureAuthenticated(req, res, next)`, which will check if a user is authenticated by calling passport's `isAuthenticated` method on the `request` which, in turn, checks if `req.user` is defined. If it is, then `next()` should be called, otherwise, we can just respond to the request with a redirect to our homepage to login. An implementation of this middleware is:
El desafío aquí es crear la función middleware `ensureAuthenticated(req, res, next)`, el cual comprobará si un usuario está autentificado llamando al método `isAuthenticated` del pasaporte en la `request` que, a su vez, comprueba si `req.user` está definido. Si lo es, entonces se debe llamar a `next()`, de lo contrario, podemos simplemente responder a la solicitud con una redirección a nuestra página de inicio para iniciar sesión. Una implementación de este middleware es:
```js
function ensureAuthenticated(req, res, next) {
@ -21,7 +21,7 @@ function ensureAuthenticated(req, res, next) {
};
```
Now add *ensureAuthenticated* as a middleware to the request for the profile page before the argument to the get request containing the function that renders the page.
Ahora añade *ensureAuthenticated* como middleware a la petición de la página de perfil antes del argumento de la petición get que contiene la función que renderiza la página.
```js
app
@ -31,11 +31,11 @@ app
});
```
Submit your page when you think you've got it right. If you're running into errors, you can check out the project completed up to this point [here](https://gist.github.com/camperbot/ae49b8778cab87e93284a91343da0959).
Envía tu página cuando creas que lo has hecho bien. Si te encuentras con errores, puedes revisar el proyecto completado hasta este punto [aquí](https://gist.github.com/camperbot/ae49b8778cab87e93284a91343da0959).
# --hints--
Middleware ensureAuthenticated should be implemented and on our /profile route.
El Middleware ensureAuthenticated debe ser implementado y en nuestra ruta /profile.
```js
(getUserInput) =>
@ -58,7 +58,7 @@ Middleware ensureAuthenticated should be implemented and on our /profile route.
);
```
A Get request to /profile should correctly redirect to / since we are not authenticated.
Una petición Get a /profile debe redirigir correctamente a / ya que no estamos autentificados.
```js
(getUserInput) =>