clean up Features, GoogleAuth, & Deploy docs (#820)

* add railway deployment

* clean up Features and GoogleAuth docs

* Update web/docs/language/features.md

Co-authored-by: Martin Šošić <Martinsos@users.noreply.github.com>
Co-authored-by: Martin Sosic <sosic.martin@gmail.com>
This commit is contained in:
vincanger 2022-11-26 18:02:09 +01:00 committed by GitHub
parent c168df875b
commit 140cbcd018
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 13 deletions

View File

@ -15,7 +15,7 @@ In the future, the plan is to have Wasp take care of it completely: you would de
If you want to deploy your App completely **free** of charge, continue reading below for guides on using Fly.io as your backend (server) provider and Netlify for your frontend (client). If you want to deploy your App completely **free** of charge, continue reading below for guides on using Fly.io as your backend (server) provider and Netlify for your frontend (client).
If you prefer to host client and server on **one platform**, and don't mind paying for extra features and easier scalability, we suggest following the guide on using [Railway as your provider](#deploying-to-railway-freemium-all-in-one-solution). If you prefer to host client and server on **one platform**, and don't mind paying a very small fee for extra features, we suggest following the guide on using [Railway as your provider](#deploying-to-railway-freemium-all-in-one-solution).
## Generating deployable code ## Generating deployable code
@ -280,7 +280,7 @@ NOTE: Make sure you set this URL as the `WASP_WEB_CLIENT_URL` environment variab
## Deploying to Railway ("freemium", all-in-one solution) ## Deploying to Railway ("freemium", all-in-one solution)
Railway makes it easy to deploy your entire app -- database, server, and client -- on one platform. You can use the platform for free for a limited time (~21 days) per month. Railway makes it easy to deploy your entire app -- database, server, and client -- on one platform. You can use the platform for free for a limited time (~21 days) per month. Upgrading to the `Developer` plan will only cost you a few dollays per month per service.
:::danger 🛑 :::danger 🛑
Due to Railway's current proxy configuration, Google Auth will not currently work. If you're using Google Auth in your Wasp App, you can still deploy your back-end to Railway, but we suggest you [deploy your front-end to Netlify](#deploying-to-netlify) Due to Railway's current proxy configuration, Google Auth will not currently work. If you're using Google Auth in your Wasp App, you can still deploy your back-end to Railway, but we suggest you [deploy your front-end to Netlify](#deploying-to-netlify)

View File

@ -7,7 +7,7 @@ title: Features
There can be only one declaration of `app` type per Wasp project. There can be only one declaration of `app` type per Wasp project.
It serves as a starting point and defines global properties of your app. It serves as a starting point and defines global properties of your app.
```css ```c
app todoApp { app todoApp {
title: "ToDo App", title: "ToDo App",
head: [ // optional head: [ // optional
@ -48,7 +48,7 @@ Check [`app.dependencies`](/docs/language/features#dependencies) for more detail
`page` declaration is the top-level layout abstraction. Your app can have multiple pages. `page` declaration is the top-level layout abstraction. Your app can have multiple pages.
```css ```c
page MainPage { page MainPage {
component: import Main from "@ext/pages/Main", component: import Main from "@ext/pages/Main",
authRequired: false // optional authRequired: false // optional
@ -612,7 +612,7 @@ Keep in mind that pg-boss jobs run alongside your other server-side code, so the
To declare a `job` in Wasp, simply add a declaration with a reference to an `async` function, like the following: To declare a `job` in Wasp, simply add a declaration with a reference to an `async` function, like the following:
```css title="main.wasp" ```c title="main.wasp"
job mySpecialJob { job mySpecialJob {
executor: PgBoss, executor: PgBoss,
perform: { perform: {
@ -639,7 +639,7 @@ And that is it! Your job will be executed by the job executor (pg-boss, in this
If you have work that needs to be done on some recurring basis, you can add a `schedule` to your job declaration: If you have work that needs to be done on some recurring basis, you can add a `schedule` to your job declaration:
```css {6-9} title="main.wasp" ```c {6-9} title="main.wasp"
job mySpecialJob { job mySpecialJob {
executor: PgBoss, executor: PgBoss,
perform: { perform: {
@ -657,7 +657,7 @@ In this example, you do _not_ need to invoke anything in JavaScript. You can ima
### Fully specified example ### Fully specified example
Both `perform` and `schedule` accept `executorOptions`, which we pass directly to the named job executor when you submit jobs. In this example, the scheduled job will have a `retryLimit` set to 0, as `schedule` overrides any similar property from `perform`. Lastly, we add an entity to pass in via the context argument to `perform.fn`. Both `perform` and `schedule` accept `executorOptions`, which we pass directly to the named job executor when you submit jobs. In this example, the scheduled job will have a `retryLimit` set to 0, as `schedule` overrides any similar property from `perform`. Lastly, we add an entity to pass in via the context argument to `perform.fn`.
```css ```c
job mySpecialJob { job mySpecialJob {
executor: PgBoss, executor: PgBoss,
entities: [Task], entities: [Task],
@ -789,10 +789,10 @@ In the future, we will add support for picking any version you like, but we have
Wasp provides authentication and authorization support out-of-the-box. Enabling it for your app is optional and can be done by configuring `auth` field of the `app` declaration: Wasp provides authentication and authorization support out-of-the-box. Enabling it for your app is optional and can be done by configuring `auth` field of the `app` declaration:
```css ```c
app MyApp { app MyApp {
title: "My app", title: "My app",
// ... //...
auth: { auth: {
userEntity: User, userEntity: User,
methods: { methods: {
@ -1072,9 +1072,24 @@ import AuthError from '@wasp/core/AuthError.js'
### Google ### Google
`google` authentication makes it possible to use Google's OAuth 2.0 service to sign Google users into your app. To enable it, add `google: {}` to your `auth.methods` dictionary to use it with default settings. If you require custom configuration setup or user entity field assignment, you can override the defaults. `google` authentication makes it possible to use Google's OAuth 2.0 service to sign Google users into your app. To enable it, add `google: {}` to your `auth.methods` dictionary to use it with default settings:
```js
//...
auth: {
userEntity: User,
externalAuthEntity: SocialLogin,
methods: {
google: {}
},
//...
}
```
This method requires also requires that `externalAuthEntity` be specified in `auth` as [described here](features#externalauthentity).
If you require custom configuration setup or user entity field assignment, you can [override the defaults](#overrides).
This method requires that `externalAuthEntity` specified in `auth` [described here](features#externalauthentity).
#### Default settings #### Default settings
- Configuration: - Configuration:
- By default, Wasp expects you to set two environment variables in order to use Google authentication: - By default, Wasp expects you to set two environment variables in order to use Google authentication:
@ -1083,8 +1098,12 @@ This method requires that `externalAuthEntity` specified in `auth` [described he
- These can be obtained in your Google Cloud Console project dashboard. See [here](/docs/integrations/google#google-auth) for more. - These can be obtained in your Google Cloud Console project dashboard. See [here](/docs/integrations/google#google-auth) for more.
- Sign in: - Sign in:
- When a user signs in for the first time, Wasp will create a new User account and link it to their Google account for future logins. The `username` will default to a random dictionary phrase that does not exist in the database, like "nice-blue-horse-27160". - When a user signs in for the first time, Wasp will create a new User account and link it to their Google account for future logins. The `username` will default to a random dictionary phrase that does not exist in the database, like "nice-blue-horse-27160".
- Aside: If you would like to allow the user to select their own username, or some other sign up flow, you could add a boolean property to your User entity which indicates if the account setup is complete. You can then redirect them in your `onAuthSucceededRedirectTo` handler. :::note Changing Random Username
- Here is a link to the default implementations: https://github.com/wasp-lang/wasp/blob/main/waspc/data/Generator/templates/server/src/routes/auth/passport/google/googleDefaults.js These can be overriden as explained below. If you would like to allow the user to select their own username, or some other sign up flow, you could add a boolean property to your User entity which indicates if the account setup is complete. You can then check this user's property on the client with the [`useAuth()`](#useauth) hook and redirect them when appropriate -- e.g. check on homepage if `user.isAuthSetup === false`, redirect them to `EditUserDetailsPage`.
Alternatively, you could add a `displayName` property to your User entity and assign it using the details of their Google account, as described in **Overrides** below
:::
- Here is a link to the default implementations: https://github.com/wasp-lang/wasp/blob/release/waspc/data/Generator/templates/server/src/routes/auth/passport/google/googleDefaults.js . These can be overriden as explained below.
#### Overrides #### Overrides
If you require modifications to the above, you can add one or more of the following to your `auth.methods.google` dictionary: If you require modifications to the above, you can add one or more of the following to your `auth.methods.google` dictionary: