mirror of https://github.com/vapor/docs.git
Compare commits
6 Commits
d6c27c4b71
...
a4ab0801a3
| Author | SHA1 | Date |
|---|---|---|
|
|
a4ab0801a3 | |
|
|
a2977762e1 | |
|
|
68f2a91630 | |
|
|
12b0114882 | |
|
|
4f2b29f8ab | |
|
|
0d4c553d15 |
|
|
@ -0,0 +1,51 @@
|
|||
## What is Zeabur
|
||||
|
||||
[Zeabur](https://zeabur.com) is a platform that helps you deploy your service with one click, No matter what programming language or framework you use.
|
||||
|
||||
## Signing Up
|
||||
|
||||
You need a Zeabur account. If you don't have one, please use the following link to create:
|
||||
</br>
|
||||
https://zeabur.com/zh-TW/login
|
||||
|
||||
Zeabur uses "Login with GitHub" and needs access to your GitHub repos. You could change its access to your different projects and organizations later.
|
||||
|
||||
## Upload Your Project to GitHub
|
||||
|
||||
Before you deploy your Vapor project, you need to upload it to GitHub. Zeabur connects to your GitHub account, and you can select your public or private repo to deploy on Zeabur's Dashboard.
|
||||
|
||||
### Remove Docker File
|
||||
|
||||
The project created by the Vapor command has Dockerfile and docker-compose.yml by default. To avoid being recognized as the Docker Container by Zeabur, you need to delete these two files:
|
||||
|
||||
```bash
|
||||
rm Dockerfile docker-compose.yml
|
||||
```
|
||||
|
||||
### Sync Your Files
|
||||
|
||||
Make sure that all your changes have been synchronized to GitHub:
|
||||
|
||||
```bash
|
||||
git add .
|
||||
git commit -m "your commit message"
|
||||
git push
|
||||
```
|
||||
|
||||
## Deployment
|
||||
|
||||
Go to [Zeabur Console](https://dash.zeabur.com) and create a new project.
|
||||
|
||||
Then, click the `Deploy New Service` button and select deploy from GitHub.
|
||||
|
||||
After you select the repository and branch, Zeabur will automatically start building your service.
|
||||
|
||||
Zeabur will automatically detect that your service is built by Vapor, so you don't need to do any additional configuration. Your deployment will be completed in a few minutes.
|
||||
|
||||
## Next
|
||||
|
||||
After the deployment is completed, you may need to configure the domain for your Vapor website.
|
||||
|
||||
Open the "Domain" tab of the service page, and then click "Generate Domain" or "Custom Domain".
|
||||
|
||||
For more information on how to bind a domain to your service, please refer to Zeabur's Docs on [Domain Binding](https://zeabur.com/docs/deploy/domain-binding).
|
||||
|
|
@ -74,7 +74,6 @@ Debajo hay un listado con los tipos de datos soportados.
|
|||
|`.uint{8,16,32,64}`|`UInt{8,16,32,64}`|
|
||||
|`.bool`|`Bool`|
|
||||
|`.datetime`|`Date` (recomendado)|
|
||||
|`.time`|`Date` (omitiendo día, mes y año)|
|
||||
|`.date`|`Date` (omitiendo hora y minutos del día)|
|
||||
|`.float`|`Float`|
|
||||
|`.double`|`Double`|
|
||||
|
|
|
|||
|
|
@ -74,7 +74,6 @@ Supported field data types are listed below.
|
|||
|`.uint{8,16,32,64}`|`UInt{8,16,32,64}`|
|
||||
|`.bool`|`Bool`|
|
||||
|`.datetime`|`Date` (recommended)|
|
||||
|`.time`|`Date` (omitting day, month, and year)|
|
||||
|`.date`|`Date` (omitting time of day)|
|
||||
|`.float`|`Float`|
|
||||
|`.double`|`Double`|
|
||||
|
|
|
|||
|
|
@ -74,7 +74,6 @@ Ondersteunde velddatatypes staan hieronder vermeld.
|
|||
|`.uint{8,16,32,64}`|`UInt{8,16,32,64}`|
|
||||
|`.bool`|`Bool`|
|
||||
|`.datetime`|`Date` (aanbevolen)|
|
||||
|`.time`|`Date` (zonder dag, maand en jaar)|
|
||||
|`.date`|`Date` (het tijdstip weglaten)|
|
||||
|`.float`|`Float`|
|
||||
|`.double`|`Double`|
|
||||
|
|
|
|||
|
|
@ -74,7 +74,6 @@ database.schema("planets").delete()
|
|||
|`.uint{8,16,32,64}`|`UInt{8,16,32,64}`|
|
||||
|`.bool`|`Bool`|
|
||||
|`.datetime`|`Date` (recommended)|
|
||||
|`.time`|`Date` (omitting day, month, and year)|
|
||||
|`.date`|`Date` (omitting time of day)|
|
||||
|`.float`|`Float`|
|
||||
|`.double`|`Double`|
|
||||
|
|
@ -404,4 +403,4 @@ try await db.schema("planets", space: "mirror_universe")
|
|||
.id()
|
||||
// ...
|
||||
.create()
|
||||
```
|
||||
```
|
||||
|
|
|
|||
|
|
@ -105,16 +105,12 @@ struct UserAuthenticator: AsyncBasicAuthenticator {
|
|||
}
|
||||
```
|
||||
|
||||
If you add this authenticator to your app, and test the route defined above, you should see the name `"Vapor"` returned for a successful login. If the credentials are not correct, you should see a `401 Unauthorized` error.
|
||||
|
||||
|
||||
|
||||
Este protocolo requiere que implementes `authenticate(basic:for:)`, que se llamará cuando una solicitud entrante contenga la cabecera `Authorization: Basic...`. Se pasa al método una estructura `BasicAuthorization` que contiene el nombre de usuario y la contraseña.
|
||||
|
||||
En este autenticador de prueba, el nombre de usuario y la contraseña se prueban con valores codificados. En un autenticador real, puedes compararlo con una base de datos o una API externa. Es por eso que el método `authenticate` te permite devolver un futuro.
|
||||
|
||||
!!! tip "Consejo"
|
||||
Las contraseñas nunca deben almacenarse en una base de datos como texto sin formato. Utiliza siempre un hash de contraseña para comparar.
|
||||
Las contraseñas nunca deben almacenarse en una base de datos como texto plano. Utiliza siempre un hash de contraseña para comparar.
|
||||
|
||||
Si los parámetros de autenticación son correctos, en este caso coinciden con los valores codificados, se inicia sesión un `User` llamado Vapor. Si los parámetros de autenticación no coinciden, no se inicia sesión de usuario, lo que significa que la autenticación falló.
|
||||
|
||||
|
|
@ -757,16 +753,12 @@ Estos middlewares hacen lo siguiente:
|
|||
|
||||
### Protegiendo Rutas
|
||||
|
||||
When protecting routes for an API, you traditionally return an HTTP response with a status code such as **401 Unauthorized** if the request is not authenticated. However, this isn't a very good user experience for someone using a browser. Vapor provides a `RedirectMiddleware` for any `Authenticatable` type to use in this scenario:
|
||||
|
||||
Al proteger rutas en una API, tradicionalmente se devuelve una respuesta HTTP con un código de estado como **401 Unauthorized** si la solicitud no está autenticada. Sin embargo, esta no es una muy buena experiencia de usuario para alguien que usa un navegador. Vapor proporciona un `RedirectMiddleware` para cualquier tipo `Authenticatable` para usar en este escenario:
|
||||
|
||||
```swift
|
||||
let protectedRoutes = app.grouped(User.redirectMiddleware(path: "/login?loginRequired=true"))
|
||||
```
|
||||
|
||||
The `RedirectMiddleware` object also supports passing a closure that returns the redirect path as a `String` during creation for advanced url handling. For instance, including the path redirected from as query parameter to the redirect target for state management.
|
||||
|
||||
El objeto `RedirectMiddleware` también admite pasar un closure que devuelve la ruta de redireccionamiento como un `String` durante la creación para un manejo avanzado de URL. Por ejemplo, incluye la ruta redirigida como parámetro de consulta al destino de redirección para la gestión del estado.
|
||||
|
||||
```swift
|
||||
|
|
|
|||
Loading…
Reference in New Issue