diff --git a/docs/01-get-started/01-creating-endpoints.md b/docs/01-get-started/01-creating-endpoints.md index 4dc7828d..ebb75fd6 100644 --- a/docs/01-get-started/01-creating-endpoints.md +++ b/docs/01-get-started/01-creating-endpoints.md @@ -38,8 +38,8 @@ development: Next, we add the Dartantic AI package as a dependency to our server. This package provides a convenient interface for working with different AI providers, including Google's Gemini API. ```bash -$ cd magic_recipe_server -$ dart pub add dartantic_ai +cd magic_recipe_server +dart pub add dartantic_ai ``` ## Create a new endpoint @@ -100,8 +100,8 @@ For methods to be recognized by Serverpod, they need to return a typed `Future` Now, you need to generate the code for your new endpoint. You do this by running `serverpod generate` in the server directory of your project: ```bash -$ cd magic_recipe_server -$ serverpod generate +cd magic_recipe_server +serverpod generate ``` `serverpod generate` will create bindings for the endpoint and register them in the server's `generated/protocol.dart` file. It will also generate the required client code so that you can call your new `generateRecipe` method from your app. @@ -221,16 +221,16 @@ Before you start your server, ensure no other Serverpod server is running. Also, Let's try our new recipe app! First, start the server: ```bash -$ cd magic_recipe_server -$ docker compose up -d -$ dart bin/main.dart --apply-migrations +cd magic_recipe_server +docker compose up -d +dart bin/main.dart --apply-migrations ``` Now, you can start the Flutter app: ```bash -$ cd magic_recipe_flutter -$ flutter run -d chrome +cd magic_recipe_flutter +flutter run -d chrome ``` This will start the Flutter app in your browser: diff --git a/docs/01-get-started/02-models-and-data.md b/docs/01-get-started/02-models-and-data.md index 482e7ea7..a050cd54 100644 --- a/docs/01-get-started/02-models-and-data.md +++ b/docs/01-get-started/02-models-and-data.md @@ -34,8 +34,8 @@ You can use most primitive Dart types here or any other models you have specifie To generate the code for the model, run the `serverpod generate` command in your server directory: ```bash -$ cd magic_recipe_server -$ serverpod generate +cd magic_recipe_server +serverpod generate ``` This will generate the code for the model and create a new file called `recipe.dart` in the `lib/src/generated` directory. It will also update the client code in `magic_recipe/magic_recipe_client` so you can use it in your Flutter app. @@ -133,8 +133,8 @@ class RecipeEndpoint extends Endpoint { First, we need to update our generated client by running `serverpod generate`. ```bash -$ cd magic_recipe_server -$ serverpod generate +cd magic_recipe_server +serverpod generate ``` Now that we have created the `Recipe` model we can use it in the app. We will do this in the `_callGenerateRecipe` method of the `magic_recipe_flutter/lib/main.dart` file. Let's update our `RecipeWidget` so that it displays the author and year of the recipe in addition to the recipe itself. @@ -433,16 +433,16 @@ class ResultDisplay extends StatelessWidget { First, start the server: ```bash -$ cd magic_recipe_server -$ docker compose up -d -$ dart bin/main.dart +cd magic_recipe_server +docker compose up -d +dart bin/main.dart ``` Then, start the Flutter app: ```bash -$ cd magic_recipe_flutter -$ flutter run -d chrome +cd magic_recipe_flutter +flutter run -d chrome ``` This will start the Flutter app in your browser. It should look something like this: diff --git a/docs/01-get-started/03-working-with-the-database.md b/docs/01-get-started/03-working-with-the-database.md index 44a6048a..17909692 100644 --- a/docs/01-get-started/03-working-with-the-database.md +++ b/docs/01-get-started/03-working-with-the-database.md @@ -42,9 +42,9 @@ To create a migration, follow these two steps in order: 2. Run `serverpod create-migration` to create the necessary database migration. ```bash -$ cd magic_recipe_server -$ serverpod generate -$ serverpod create-migration +cd magic_recipe_server +serverpod generate +serverpod create-migration ``` Each time you run `serverpod create-migration`, a new migration file will be created in your _migrations_ folder. These step-by-step migrations provide a history of your database changes and allow you to roll back changes if needed. @@ -190,8 +190,8 @@ The `insertRow` method is used to insert a new row into the database. The `find` Like before, when you change something that has an effect on your client code, you need to run `serverpod generate`. We don't need to run `serverpod create-migrations` again because we already created a migration in the previous step and haven't done any changes that affect the database. ```bash -$ cd magic_recipe_server -$ serverpod generate +cd magic_recipe_server +serverpod generate ``` ## Call the endpoint from the app @@ -434,9 +434,9 @@ To run the application with database support, follow these steps in order: First, start the database and apply migrations: ```bash -$ cd magic_recipe_server -$ docker compose up -d # Start the database container -$ dart bin/main.dart --apply-migrations # Apply any pending migrations +cd magic_recipe_server +docker compose up -d # Start the database container +dart bin/main.dart --apply-migrations # Apply any pending migrations ``` :::tip @@ -446,8 +446,8 @@ The `--apply-migrations` flag is safe to use during development - if no migratio Next, launch the Flutter app: ```bash -$ cd magic_recipe_flutter -$ flutter run -d chrome +cd magic_recipe_flutter +flutter run -d chrome ``` ## Summary diff --git a/docs/06-concepts/06-database/01-connection.md b/docs/06-concepts/06-database/01-connection.md index 0c9ce97a..05bff19a 100644 --- a/docs/06-concepts/06-database/01-connection.md +++ b/docs/06-concepts/06-database/01-connection.md @@ -100,19 +100,19 @@ development: A newly created Serverpod project has a preconfigured Docker instance with a Postgres database set up. Run the following command from the root of the `server` package to start the database: ```bash -$ docker compose up --build --detach +docker compose up --build --detach ``` To stop the database run: ```bash -$ docker compose stop +docker compose stop ``` To remove the database and __delete__ all associated data, run: ```bash -$ docker compose down -v +docker compose down -v ``` ## Connecting to a custom Postgres instance diff --git a/docs/06-concepts/06-database/11-migrations.md b/docs/06-concepts/06-database/11-migrations.md index 80bc54c2..ad8f803b 100644 --- a/docs/06-concepts/06-database/11-migrations.md +++ b/docs/06-concepts/06-database/11-migrations.md @@ -28,7 +28,7 @@ If you want to transition a manually managed table to then be managed by Serverp To create a migration navigate to your project's `server` package directory and run the `create-migration` command. ```bash -$ serverpod create-migration +serverpod create-migration ``` The command reads the database schema from the last migration, then compares it to the database schema necessary to accommodate the projects, and any module dependencies, current database requirements. If differences are identified, a new migration is created in the `migrations` directory to roll the database forward. @@ -47,7 +47,7 @@ The migration command aborts and displays an error under two conditions: To override these safeguards and force the creation of a migration, use the `--force` flag. ```bash -$ serverpod create-migration --force +serverpod create-migration --force ``` ### Tag migration @@ -55,7 +55,7 @@ $ serverpod create-migration --force Tags can be useful to identify migrations that introduced specific changes to the project. Tags are appended to the migration name and can be added with the `--tag` option. ```bash -$ serverpod create-migration --tag "v1-0-0" +serverpod create-migration --tag "v1-0-0" ``` This would create a migration named `-v1-0-0`: @@ -97,13 +97,13 @@ For each migration, five files are created: Migrations are applied using the server runtime. To apply migrations, navigate to your project's `server` package directory, then start the server with the `--apply-migrations` flag. Migrations are applied as part of the startup sequence and the framework asserts that each migration is only applied once to the database. ```bash -$ dart run bin/main.dart --apply-migrations +dart run bin/main.dart --apply-migrations ``` Migrations can also be applied using the maintenance role. In maintenance, after migrations are applied, the server exits with an exit code indicating if migrations were successfully applied, zero for success or non-zero for failure. ```bash -$ dart run bin/main.dart --role maintenance --apply-migrations +dart run bin/main.dart --role maintenance --apply-migrations ``` This is useful if migrations are applied as part of an automated process. @@ -119,7 +119,7 @@ By default, the command connects to and pulls a live database schema from a runn To create a repair migration, navigate to your project's `server` package directory and run the `create-repair-migration` command. ```bash -$ serverpod create-repair-migration +serverpod create-repair-migration ``` This creates a repair migration in the `repair-migration` directory targeting the project's latest migration. @@ -137,7 +137,7 @@ Since each repair migration is created for a specific live database schema, Serv By default, the repair migration system connects to your `development` database using the information specified in your Serverpod config. To use a different database source, the `--mode` option is used. ```bash -$ serverpod create-repair-migration --mode production +serverpod create-repair-migration --mode production ``` The command connects and pulls the live database schema from a running server. @@ -147,7 +147,7 @@ The command connects and pulls the live database schema from a running server. Repair migrations can also target a specific migration version by specifying the migration name with the `--version` option. ```bash -$ serverpod create-repair-migration --version 20230821135718-v1-0-0 +serverpod create-repair-migration --version 20230821135718-v1-0-0 ``` This makes it possible to revert your database schema back to any older migration version. @@ -162,7 +162,7 @@ The repair migration command aborts and displays an error under two conditions: To override these safeguards and force the creation of a repair migration, use the `--force` flag. ```bash -$ serverpod create-repair-migration --force +serverpod create-repair-migration --force ``` ### Tag repair migration @@ -170,7 +170,7 @@ $ serverpod create-repair-migration --force Repair migrations can be tagged just like regular migrations. Tags are appended to the migration name and can be added with the `--tag` option. ```bash -$ serverpod create-repair-migration --tag "reset-migrations" +serverpod create-repair-migration --tag "reset-migrations" ``` This would create a repair migration named `-reset-migrations` in the `repair` directory: @@ -194,13 +194,13 @@ The `repair` directory only exists if a repair migration has been created and co The repair migration is applied using the server runtime. To apply a repair migration, start the server with the `--apply-repair-migration` flag. The repair migration is applied as part of the startup sequence and the framework asserts that each repair migration is only applied once to the database. ```bash -$ dart run bin/main.dart --apply-repair-migration +dart run bin/main.dart --apply-repair-migration ``` The repair migration can also be applied using the maintenance role. In maintenance, after migrations are applied, the server exits with an exit code indicating if migrations were successfully applied, zero for success or non-zero for failure. ```bash -$ dart run bin/main.dart --role maintenance --apply-repair-migration +dart run bin/main.dart --role maintenance --apply-repair-migration ``` If a repair migration is applied at the same time as migrations, the repair migration is applied first. @@ -214,11 +214,11 @@ Note that data is not rolled back, only the database schema. To roll back to a previous migration, first create a repair migration targeting the desired migration version: ```bash -$ serverpod create-repair-migration --version 20230821135718-v1-0-0 --tag "roll-back-to-v1-0-0" +serverpod create-repair-migration --version 20230821135718-v1-0-0 --tag "roll-back-to-v1-0-0" ``` Then apply the repair migration, any repair migration will only be applied once: ```bash -$ dart run bin/main.dart --apply-repair-migration +dart run bin/main.dart --apply-repair-migration ``` diff --git a/docs/06-concepts/10-modules.md b/docs/06-concepts/10-modules.md index 442b0747..1bd1f12f 100644 --- a/docs/06-concepts/10-modules.md +++ b/docs/06-concepts/10-modules.md @@ -32,15 +32,15 @@ modules: Then run `pub get` and `serverpod generate` from your server's directory (e.g., `mypod_server`) to add the module to your project's deserializer. ```bash -$ dart pub get -$ serverpod generate +dart pub get +serverpod generate ``` Finally, since modules might include modifications to the database schema, you should create a new database migration and apply it by running `serverpod create-migration` then `dart bin/main.dart --apply-migrations` from your server's directory. ```bash -$ serverpod create-migration -$ dart bin/main.dart --apply-migrations +serverpod create-migration +dart bin/main.dart --apply-migrations ``` ### Client setup @@ -79,13 +79,13 @@ fields: With the `serverpod create` command, it is possible to create new modules for code that is shared between projects or that you want to publish to pub.dev. To create a module instead of a server project, pass `module` to the `--template` flag. ```bash -$ serverpod create --template module my_module +serverpod create --template module my_module ``` The create command will create a server and a client Dart package. If you also want to add custom Flutter code, use `flutter create` to create a package. ```bash -$ flutter create --template package my_module_flutter +flutter create --template package my_module_flutter ``` In your Flutter package, you most likely want to import the client libraries created by `serverpod create`. diff --git a/docs/06-concepts/11-authentication/04-providers/03-google/01-setup.md b/docs/06-concepts/11-authentication/04-providers/03-google/01-setup.md index d5d72451..14f09004 100644 --- a/docs/06-concepts/11-authentication/04-providers/03-google/01-setup.md +++ b/docs/06-concepts/11-authentication/04-providers/03-google/01-setup.md @@ -190,7 +190,7 @@ If your `google-services.json` does not include a web OAuth client entry, you ma For a production app you need to get the SHA-1 key from your production keystore! This can be done by running this command: ([Read more](https://support.google.com/cloud/answer/6158849#installedapplications&android&zippy=%2Cnative-applications%2Candroid)). ```bash -$ keytool -list -v -keystore /path/to/keystore +keytool -list -v -keystore /path/to/keystore ``` ::: @@ -208,7 +208,7 @@ Navigate to _Clients_ and select the server credentials (the one configured as a Force flutter to run on a specific port by running. ```bash -$ flutter run -d chrome --web-port=49660 +flutter run -d chrome --web-port=49660 ``` ::: diff --git a/docs/06-concepts/11-authentication/11-legacy/01-setup.md b/docs/06-concepts/11-authentication/11-legacy/01-setup.md index 677ac269..c2769e98 100644 --- a/docs/06-concepts/11-authentication/11-legacy/01-setup.md +++ b/docs/06-concepts/11-authentication/11-legacy/01-setup.md @@ -15,7 +15,7 @@ Serverpod's auth module makes it easy to authenticate users through email or 3rd Add the module as a dependency to the server project's `pubspec.yaml`. ```sh -$ dart pub add serverpod_auth_server +dart pub add serverpod_auth_server ``` Add the authentication handler to the Serverpod instance. @@ -46,7 +46,7 @@ modules: While still in the server project, generate the client code and endpoint methods for the auth module by running the `serverpod generate` command line tool. ```bash -$ serverpod generate +serverpod generate ``` ### Initialize the auth database @@ -54,19 +54,19 @@ $ serverpod generate After adding the module to the server project, you need to initialize the database. First you have to create a new migration that includes the auth module tables. This is done by running the `serverpod create-migration` command line tool in the server project. ```bash -$ serverpod create-migration +serverpod create-migration ``` Start your database container from the server project. ```bash -$ docker compose up --build --detach +docker compose up --build --detach ``` Then apply the migration by starting the server with the `apply-migrations` flag. ```bash -$ dart run bin/main.dart --role maintenance --apply-migrations +dart run bin/main.dart --role maintenance --apply-migrations ``` The full migration instructions can be found in the [migration guide](../../database/migrations). diff --git a/docs/06-concepts/11-authentication/11-legacy/04-providers/02-google.md b/docs/06-concepts/11-authentication/11-legacy/04-providers/02-google.md index 7b52c420..8fe10f12 100644 --- a/docs/06-concepts/11-authentication/11-legacy/04-providers/02-google.md +++ b/docs/06-concepts/11-authentication/11-legacy/04-providers/02-google.md @@ -119,7 +119,7 @@ Put the file inside the `android/app/` directory and rename it to `google-servic For a production app you need to get the SHA-1 key from your production keystore! This can be done by running this command: ([Read more](https://support.google.com/cloud/answer/6158849#installedapplications&android&zippy=%2Cnative-applications%2Candroid)). ```bash -$ keytool -list -v -keystore /path/to/keystore +keytool -list -v -keystore /path/to/keystore ``` ::: @@ -136,7 +136,7 @@ Navigate to _Credentials_ under _APIs & Services_ and select the server credenti Force flutter to run on a specific port by running. ```bash -$ flutter run -d chrome --web-port=49660 +flutter run -d chrome --web-port=49660 ``` ::: diff --git a/docs/06-concepts/11-authentication/11-legacy/04-providers/05-firebase.md b/docs/06-concepts/11-authentication/11-legacy/04-providers/05-firebase.md index f5aab8fc..b1a4e0dc 100644 --- a/docs/06-concepts/11-authentication/11-legacy/04-providers/05-firebase.md +++ b/docs/06-concepts/11-authentication/11-legacy/04-providers/05-firebase.md @@ -31,8 +31,8 @@ To add authentication with Firebase, you must first install and initialize the F The short version: ```bash -$ flutter pub add firebase_core firebase_auth firebase_ui_auth -$ flutterfire configure +flutter pub add firebase_core firebase_auth firebase_ui_auth +flutterfire configure ``` In the Firebase console, configure the different social sign-ins you plan to use, under `Authentication > Sign-in method`. @@ -67,7 +67,7 @@ void main() async { Add the [serverpod_auth_firebase_flutter](https://pub.dev/packages/serverpod_auth_firebase_flutter) package. ```bash -$ flutter pub add serverpod_auth_firebase_flutter +flutter pub add serverpod_auth_firebase_flutter ``` The `SignInWithFirebaseButton` is a convenient button that triggers the sign-in flow and can be used like this: diff --git a/docs/06-concepts/12-file-uploads.md b/docs/06-concepts/12-file-uploads.md index 8c3b42a0..5b0fa10f 100644 --- a/docs/06-concepts/12-file-uploads.md +++ b/docs/06-concepts/12-file-uploads.md @@ -140,7 +140,7 @@ You may also want to add the bucket as a backend for your load balancer to give When you have set up your GCP bucket, you need to configure it in Serverpod. Add the GCP package to your `pubspec.yaml` file and import it in your `server.dart` file. ```bash -$ dart pub add serverpod_cloud_storage_gcp +dart pub add serverpod_cloud_storage_gcp ``` ```dart @@ -233,7 +233,7 @@ This section shows how to set up a storage using S3. Before you write your Dart When you are all set with the AWS setup, include the S3 package in your `pubspec.yaml` file and import it in your `server.dart` file. ```bash -$ dart pub add serverpod_cloud_storage_s3 +dart pub add serverpod_cloud_storage_s3 ``` ```dart @@ -271,7 +271,7 @@ Serverpod supports Cloudflare R2 as a cloud storage provider. R2 is S3-compatibl Add the R2 package to your `pubspec.yaml` file and import it in your `server.dart` file. ```bash -$ dart pub add serverpod_cloud_storage_r2 +dart pub add serverpod_cloud_storage_r2 ``` ```dart diff --git a/docs/06-concepts/14-scheduling/01-setup.md b/docs/06-concepts/14-scheduling/01-setup.md index cdad56cd..5b6847d8 100644 --- a/docs/06-concepts/14-scheduling/01-setup.md +++ b/docs/06-concepts/14-scheduling/01-setup.md @@ -31,7 +31,7 @@ It is not valid to override the `invoke` method of the `FutureCall` class. This Next, you need to generate the code for your future calls: ```bash -$ serverpod generate +serverpod generate ``` Calling `serverpod generate` will create a type-safe interface for invoking the future calls in the server's `generated/future_calls.dart` file. This interface can be accessed from the Serverpod object. diff --git a/docs/06-concepts/14-scheduling/02-recurring-task.md b/docs/06-concepts/14-scheduling/02-recurring-task.md index 0ae25963..ef4444bd 100644 --- a/docs/06-concepts/14-scheduling/02-recurring-task.md +++ b/docs/06-concepts/14-scheduling/02-recurring-task.md @@ -20,7 +20,7 @@ class ExampleFutureCall extends FutureCall { Next, generate the code for your future call: ```bash -$ serverpod generate +serverpod generate ``` :::info diff --git a/docs/06-concepts/20-shared-packages.md b/docs/06-concepts/20-shared-packages.md index fdd23d23..dd4c8e8c 100644 --- a/docs/06-concepts/20-shared-packages.md +++ b/docs/06-concepts/20-shared-packages.md @@ -75,7 +75,7 @@ Paths are relative to the server project directory. You can list multiple shared Run `serverpod generate` from your server directory. ```bash -$ serverpod generate +serverpod generate ``` This generates the Dart classes and protocol in the shared package's `lib/src/generated/` directory. After generation, a typical shared package looks like: diff --git a/docs/06-concepts/22-experimental.md b/docs/06-concepts/22-experimental.md index 075877af..6f87ca22 100644 --- a/docs/06-concepts/22-experimental.md +++ b/docs/06-concepts/22-experimental.md @@ -25,7 +25,7 @@ If possible, the experimental API will remain for some time as `@deprecated`, an Some of the experimental features are enabled by including the `--experimental-features` flag when running the serverpod command: ```bash -$ serverpod generate --experimental-features=all +serverpod generate --experimental-features=all ``` The current options you can pass are: diff --git a/docs/07-deployments/02-deploying-to-gce-terraform.md b/docs/07-deployments/02-deploying-to-gce-terraform.md index 3a2ac487..f55c21bd 100644 --- a/docs/07-deployments/02-deploying-to-gce-terraform.md +++ b/docs/07-deployments/02-deploying-to-gce-terraform.md @@ -126,7 +126,7 @@ Depending on your domain name registrar, the process for setting up your domain You can test that the domain points to the correct name servers by running `dig` on the command line. It will output the domain name servers. ```bash -$ dig +short NS examplepod.com +dig +short NS examplepod.com ``` Should yield an output similar to this: @@ -228,13 +228,13 @@ If you are deploying a staging server in addition to your production server, you Once you have configured Terraform and your Serverpod, you are ready to deploy your infrastructure. Make sure that you have `cd` into your `deploy/gcp/terraform_gce` directory. Now run: ```bash -$ terraform init +terraform init ``` This will download the Serverpod module and initialize your Terraform configuration. Now, deploy your infrastructure by running: ```bash -$ terraform apply +terraform apply ``` Terraform will ask you for the password to your production and staging database. You will find the passwords in your `config/passwords.yaml` file. If you are not deploying a staging server, you can leave the staging database password blank. diff --git a/docs/07-deployments/03-deploying-to-gcr-console.md b/docs/07-deployments/03-deploying-to-gcr-console.md index cdd5991d..b647215c 100644 --- a/docs/07-deployments/03-deploying-to-gcr-console.md +++ b/docs/07-deployments/03-deploying-to-gcr-console.md @@ -11,13 +11,13 @@ Before you begin, you will need to install and configure the Google Cloud CLI to - To [initialize](https://cloud.google.com/sdk/docs/initializing) the gcloud CLI, run the following command: ```bash -$ gcloud init +gcloud init ``` - To set the default project for your Cloud Run service: ```bash -$ gcloud config set project +gcloud config set project ``` ## Setup the database @@ -75,8 +75,8 @@ database: Your server is now ready to be deployed. When you created your project, Serverpod also created a script for deploying your server. Copy it to the root of your server directory and make it executable. Make sure you are in your server directory (e.g., `myproject_server`). Then run the following command: ```bash -$ cp deploy/gcp/console_gcr/cloud-run-deploy.sh . -$ chmod u+x cloud-run-deploy.sh +cp deploy/gcp/console_gcr/cloud-run-deploy.sh . +chmod u+x cloud-run-deploy.sh ``` Open up the script in your favorite editor. You will need to fill in your _database instance's connection name_ and the _email of your service account_. @@ -84,7 +84,7 @@ Open up the script in your favorite editor. You will need to fill in your _datab Now, deploy your server by running the following: ```bash -$ ./cloud-run-deploy.sh +./cloud-run-deploy.sh ``` The script runs two deployment commands, one for your API and one for the Insights API used by the Serverpod app. While running, it may ask you to enable the Cloud Run and SQL Admin services. Answer yes to all these questions. diff --git a/docs/07-deployments/04-deploying-to-aws.md b/docs/07-deployments/04-deploying-to-aws.md index af139474..713e4d4c 100644 --- a/docs/07-deployments/04-deploying-to-aws.md +++ b/docs/07-deployments/04-deploying-to-aws.md @@ -202,14 +202,14 @@ database: Your Serverpod should now be configured and ready to be deployed. Exciting times! Open up a terminal and `cd` into your server `aws/terraform` directory. First, you need to add an environment variable so that Terraform can correctly set the password for the Postgres database. You will find the production password for the database in your `config/passwords.yaml` file. ```bash -$ export TF_VAR_DATABASE_PASSWORD_PRODUCTION="" +export TF_VAR_DATABASE_PASSWORD_PRODUCTION="" ``` Next, we are ready to initialize Terraform and deploy our server. You will only need to run the `terraform init` command the first time you deploy the configuration. ```bash -$ terraform init -$ terraform apply +terraform init +terraform apply ``` Terraform will now run some checks and make a plan for the deployment. If everything looks good, it will ask you if you are ready to go ahead with the changes. Type `yes` and hit the return key. Applying the changes can take up to five minutes as AWS creates the different resources needed for your Serverpod. diff --git a/docs/07-deployments/05-general.md b/docs/07-deployments/05-general.md index 981bb8d9..fa1f3878 100644 --- a/docs/07-deployments/05-general.md +++ b/docs/07-deployments/05-general.md @@ -11,7 +11,7 @@ Serverpod will not run without a link to a Postgres database with the correct ta Serverpod has three main configuration files, depending on which mode the server is running; `development`, `staging`, or `production`. The files are located in the `config/` directory. By default, the server will start in development mode. To use another configuration file, use the `--mode` option when starting the server. If you are running multiple servers in a cluster, use the `--server-id` option to specify the id of each server. By default, the server will run as id `default`. For instance, to start the server in production mode with id `2`, run the following command: ```bash -$ dart bin/main.dart --mode production --server-id 2 +dart bin/main.dart --mode production --server-id 2 ``` :::info @@ -35,7 +35,7 @@ Serverpod can assume different roles depending on your configuration. If you run You can specify the role of your server when you launch it by setting the `--role` argument. ```bash -$ dart bin/main.dart --role serverless +dart bin/main.dart --role serverless ``` ## Docker container diff --git a/docs/08-upgrading/03-upgrade-to-pgvector.md b/docs/08-upgrading/03-upgrade-to-pgvector.md index 24896009..6f94d34c 100644 --- a/docs/08-upgrading/03-upgrade-to-pgvector.md +++ b/docs/08-upgrading/03-upgrade-to-pgvector.md @@ -64,8 +64,8 @@ fields: 4. Generate and apply a migration: ```bash -$ serverpod create-migration -$ dart run bin/main.dart --apply-migrations +serverpod create-migration +dart run bin/main.dart --apply-migrations ``` For more details on creating and applying migrations, see the [Migrations](../concepts/database/migrations) section. diff --git a/docs/08-upgrading/04-archive/03-upgrade-to-two.md b/docs/08-upgrading/04-archive/03-upgrade-to-two.md index 54e3b54d..5ef0d80a 100644 --- a/docs/08-upgrading/04-archive/03-upgrade-to-two.md +++ b/docs/08-upgrading/04-archive/03-upgrade-to-two.md @@ -284,7 +284,7 @@ To ensure new databases are created with the new representation, the latest migr A new empty migration can be created by running the following command in the terminal: ```bash -$ serverpod create-migration --force +serverpod create-migration --force ``` #### Migration of existing tables diff --git a/docs/09-tools/02-lsp.md b/docs/09-tools/02-lsp.md index 2374cf57..8da02d1b 100644 --- a/docs/09-tools/02-lsp.md +++ b/docs/09-tools/02-lsp.md @@ -5,7 +5,7 @@ The [Language Server Protocol (LSP)](https://microsoft.github.io/language-server To start the Serverpod LSP server, use the following command: ```bash -$ serverpod language-server +serverpod language-server ``` :::info diff --git a/docs/09-tools/03-run-scripts.md b/docs/09-tools/03-run-scripts.md index 699ed8ce..d040adcb 100644 --- a/docs/09-tools/03-run-scripts.md +++ b/docs/09-tools/03-run-scripts.md @@ -19,13 +19,13 @@ serverpod: To run a script: ```bash -$ serverpod run start +serverpod run start ``` To list all available scripts, use the `--list` flag or omit the script name: ```bash -$ serverpod run --list +serverpod run --list ``` Scripts run in a shell environment (`bash` on Linux/macOS, `cmd` on Windows), so you can use pipes, conditionals, and environment variables. The CLI forwards signals like `Ctrl+C` to the running script and propagates exit codes. diff --git a/docs/index.md b/docs/index.md index 7e4fd361..6273e475 100644 --- a/docs/index.md +++ b/docs/index.md @@ -54,3 +54,135 @@ Serverpod comes packed with powerful features - batteries included. - **Straightforward authentication:** Quickly integrate popular authentication providers like sign-in with Google, Apple, or Firebase. - **All essentials covered:** Built-in support for common tasks like handling file uploads, scheduling tasks, and caching data. - **Cloud ready:** Deploy to Serverpod Cloud with zero configuration (coming soon - **[join the waiting list](https://forms.gle/JgFCqW3NY6WdDfct5)**), use pre-configured Docker containers, or use Terraform scripts for deploying to AWS or Google Cloud. + +## Installation + +### Prerequisites + +Serverpod is tested on Mac, Windows, and Linux. Before you can install Serverpod, you need to have **[Flutter](https://flutter.dev/docs/get-started/install)** installed. + +:::info +Check your Flutter installation by running the following command in your terminal: + +```bash +flutter doctor +``` + +::: + +To make use of Serverpod's database connectivity, you need to have access to a PostgreSQL database. We recommend using Docker to run PostgreSQL locally. You can find instructions for installing Docker on the official **[Docker website](https://docs.docker.com/get-docker/)**. Each Serverpod project comes with its own `docker-compose.yaml`, so there is no need to install any custom containers. We will guide you through the process in the Getting Started section. + +:::info +Check your Docker installation by running the following command in your terminal: + +```bash +docker info +``` + +If you are using Docker Desktop and you get an error, make sure that Docker is running. You can check this by looking for the Docker icon in your system tray or taskbar. If it's not running, start Docker Desktop and try again. +::: + +### Install Serverpod + +Serverpod is installed using the Dart package manager. To install Serverpod, run the following command in your terminal: + +```bash +dart pub global activate serverpod_cli +``` + +This command will install the Serverpod command-line interface (CLI) globally on your machine. You can verify the installation by running: + +```bash +serverpod +``` + +If everything is correctly configured, the help for the `serverpod` command is now displayed. + +### Install the VS Code extension (recommended) + +The Serverpod VS Code extension makes it easy to work with your Serverpod projects. It provides real-time diagnostics and syntax highlighting for model files in your project. +![Serverpod extension](/img/syntax-highlighting.png) + +You can **[install the extension](https://marketplace.visualstudio.com/items?itemName=serverpod.serverpod)** from the VS Code Marketplace or search for _Serverpod_ from inside VS Code. + +### Install Serverpod Insights (recommended) + +**[Serverpod Insights](./09-tools/01-insights.md)** is a companion app bundled with Serverpod. It allows you to access your server's logs and health metrics. Insights is available for Mac and Windows, but we will be adding support for Linux in the future. +![Serverpod Insights](/img/serverpod-insights.webp) + +## Creating a new project + +To create a new Serverpod project, use the `serverpod create` command. It will set up a new project with a server, a client, and a Flutter app. +The project will be created in a new directory with the name you specify. For example, to create a new project called `my_project`, run the following command: + +```bash +serverpod create my_project +``` + +:::tip +The name of the project must be a valid Dart package name. It should start with a lowercase letter and can only contain lowercase letters, numbers, and underscores. For example, `my_project` is a valid name, but `MyCounter` is not. +::: + +After running the command, the following structure will be created: + +```text +my_project/ +├── my_project_server/ # Contains your server-side code. +├── my_project_client/ # Code needed for the app to communicate with the server. +└── my_project_flutter/ # Flutter app, pre-configured to connect to your local server. +``` + +The root-level `pubspec.yaml` file includes support for [Dart pub workspaces](https://dart.dev/tools/pub/workspaces) by default, which allows fetching dependencies at once by calling `dart pub get` from the project root. + +:::info +During project creation, dependencies are automatically fetched. +::: + +To run your new project you must first start the database from the Docker file that is included with the project. Do this by running the `docker compose up` command in the server directory: + +```bash +cd my_project/my_project_server +docker compose up +``` + +This will start the PostgreSQL database. You can stop the database server by pressing `Ctrl+C` in the terminal. If you want to run the servers in the background, you can use the `-d` flag: + +```bash +docker compose up -d +``` + +This will start the database server in detached mode, meaning it will run in the background and you can safely close the terminal window without stopping it. Stop the database container by running the following command from the server directory: + +```bash +docker compose down +``` + +:::tip +If you are using Docker Desktop, you can see and manage all your installed Docker containers from there. It's easy to start and stop containers, and to remove the ones you are no longer using. +::: + +Now that the database is up and running we can start the Serverpod server. Because we are running the project for the first time, we need to create the database tables used by Serverpod. This is done through a [database migration](./06-concepts/06-database/11-migrations.md). An initial migration is already created for us, so all we need to do is pass the `--apply-migrations` flag when starting the server: + +```bash +cd my_project/my_project_server +dart run bin/main.dart --apply-migrations +``` + +This will start the server and set up the initial database tables. You can now access the server at `http://localhost:8080` and the web server is available at `http://localhost:8082`. It should look like this: + +![Serverpod web](/img/getting-started/serverpod-web.png) + +Now let's run our Flutter app. You can do this by running `flutter run -d chrome` in the flutter directory: + +```bash +cd my_project/my_project_flutter +flutter run -d chrome +``` + +This will start the Flutter app in your browser. It should look like this: + +![Example Flutter App](/img/getting-started/flutter-example-web.png) + +## Next steps + +The quickest way to learn Serverpod is to follow our 30-minute **[Getting Started](01-get-started/01-creating-endpoints.md)** guide. This will give you an excellent overview of creating endpoints and models and working with the database. You will create a fun app that magically creates recipes from the ingredients you have in your fridge. \ No newline at end of file diff --git a/docs/serverpod-mini.md b/docs/serverpod-mini.md index d9a254ca..54883a22 100644 --- a/docs/serverpod-mini.md +++ b/docs/serverpod-mini.md @@ -40,7 +40,7 @@ Serverpod Mini is a lightweight version of Serverpod that is perfect for small p Create a mini project by running: ```bash -$ serverpod create myminipod --mini +serverpod create myminipod --mini ``` Serverpod will create a new project for you. It contains three Dart packages, but you only need to pay attention to the `myminipod_server` and `myminipod_flutter` directories. The server directory contains your server files, and the flutter directory contains your app. The third package (`myminipod_client`) contains generated code that is used by the Flutter app to communicate with the server. @@ -48,15 +48,15 @@ Serverpod will create a new project for you. It contains three Dart packages, bu Start your server by changing directory into your server directory, and run the `bin/main.dart` file: ```bash -$ cd myminipod/myminipod_server -$ dart bin/main.dart +cd myminipod/myminipod_server +dart bin/main.dart ``` Your default project comes with a sample Flutter app, all hooked up to talk with your server. Run it with the `flutter` command: ```bash -$ cd myminipod/myminipod_flutter -$ flutter run -d chrome +cd myminipod/myminipod_flutter +flutter run -d chrome ``` Easy as that. 🥳 @@ -84,8 +84,8 @@ For types, you can use most basic Dart types, such as `String`, `double`, `int`, Whenever you add or edit a model file, run `serverpod generate` in your server directory. Then, Serverpod will generate all the updated Dart classes: ```bash -$ cd myminipod/myminipod_server -$ serverpod generate +cd myminipod/myminipod_server +serverpod generate ``` ## Adding methods to your server @@ -121,8 +121,8 @@ class CompanyEndpoint extends Endpoint { After adding or modifying endpoints and endpoint methods, you must run `serverpod generate` to keep your Flutter app up-to-date. ```bash -$ cd myminipod/myminipod_server -$ serverpod generate +cd myminipod/myminipod_server +serverpod generate ``` ## Calling the server methods from the app