@@ -242,22 +242,15 @@ npx platformatic db migrations apply
242
242
```
243
243
244
244
- You can now reload your GraphiQL and OpenAPI pages and you will
245
- automatically see the updated schemas as the migrations are auto-applied .
245
+ automatically see the updated schemas.
246
246
247
- - In case you edit the migrations file before running the rollback,
248
- the database will be on a non-consistent state.
249
- You might need to delete the ` db.sqlite ` file and restart the server:
250
- ``` shell
251
- rm db.sqlite
252
- npm start
253
- ```
254
247
---
255
248
256
249
# Step 2: Create DB schema (3/3)
257
250
258
251
- Note that migration ` 001.do.sql ` is applied:
259
252
260
- <img src =" /assets/step-2-run.png " width =" 500 " class =" center " >
253
+ <img src =" /assets/step-2-run.png " width =" 600 " class =" center " >
261
254
262
255
Platformatic is now exposing the 'quotes' entity through GraphQL and OpenAPI!
263
256
@@ -494,15 +487,13 @@ module.exports = async function (app) {}
494
487
495
488
- ...and the configuration in ` platformatic.db.json ` :
496
489
497
- ``` json{3-7}
498
- {
490
+ ``` json{2-7}
499
491
...
500
492
"plugins": {
501
493
"paths": [
502
494
"plugin.js"
503
495
]
504
496
}
505
- }
506
497
507
498
```
508
499
@@ -516,7 +507,14 @@ See: https://github.com/platformatic/platformatic/issues/55
516
507
# Step 5: Plugins
517
508
518
509
- Platformatic DB can be extended with [ ** Fastify Plugins** ] ( https://www.fastify.io/docs/latest/Reference/Plugins/ )
519
- - When Platformatic DB starts, loads the plugins (try adding a ` app.log.info ` in ` plugin.js ` ).
510
+ - When Platformatic DB starts, loads the plugins (try adding a ` app.log.info ` in ` plugin.js ` ):
511
+
512
+ ``` javascript{2}
513
+ module.exports = async function (app) {
514
+ app.log.info('plugin loaded')
515
+ }
516
+ ```
517
+ See the log on the server:
520
518
521
519
``` shell {2}
522
520
[10:09:20.052] INFO (146270): running 003.do.sql
@@ -562,7 +560,7 @@ module.exports = async function plugin (app) {
562
560
563
561
- We can extract a ` incrementQuoteLikes` function for reuse in `plugin.js`:
564
562
565
- ```js{5-13,18-20 }
563
+ ```js{4-12,16-18 }
566
564
const S = require (' fluent-json-schema' )
567
565
module.exports = async function plugin (app) {
568
566
app .log .info (' plugin loaded' )
@@ -607,9 +605,11 @@ module.exports = async function plugin (app) {
607
605
}
608
606
609
607
` ` `
608
+ ---
610
609
611
- - Try the mutation with GraphiQL
610
+ # Try the mutation with GraphiQL
612
611
612
+ <img src="/assets/step-6-mutation.png" class="center">
613
613
614
614
<!--
615
615
mutation {
@@ -628,15 +628,15 @@ npm install
628
628
npm start
629
629
` ` `
630
630
631
- This should start :
631
+ You should see this :
632
632
` ` ` shell {8 }
633
- ➜ npm start
633
+ ➜ npm start
634
634
635
635
> start
636
636
> astro dev -- port 3000
637
637
638
- 🚀 astro v1.3 . 1 started in 38ms
639
-
638
+ 🚀 astro v1.9 . 2 started in 72ms
639
+
640
640
┃ Local http: // localhost:3000/
641
641
┃ Network use -- host to expose
642
642
` ` `
@@ -663,7 +663,7 @@ Apparently, `vite` starts on http://localhost:3000/ on linux, and http://127.0.
663
663
}
664
664
` ` `
665
665
666
- - Restart the Platformatic DB server
666
+ - ~~ Restart the Platformatic DB server~~ (not needed! 🎉)
667
667
668
668
<!--
669
669
BONUS STEP.
@@ -672,14 +672,124 @@ BONUS STEP.
672
672
673
673
---
674
674
675
- # Open with the browser
675
+ # Step 7: Open with the browser
676
676
677
677
<img src="/assets/step-7-ui.png" width="500" class="center">
678
678
679
679
---
680
680
681
- # Next Steps
682
681
682
+ # Step 8: Deploy on Platformatic Cloud
683
+
684
+ - Point your browser to https://platformatic.cloud
685
+ - Login with github (you may beed to accept the terms and conditions if not done yet)
686
+ - You should see the **Dashboard** page on your personal organization, which is created automatically. Click on "Create an App"
687
+
688
+ <div flex justify-center m-4>
689
+ <img src="/assets/step-8-org.png" width="400"/>
690
+ </div>
691
+ ---
692
+
693
+ # Step 8: Create an Application
694
+
695
+ <div flex justify-center m-4>
696
+ <img src="/assets/step-8-create-app.png"/>
697
+ </div>
698
+
699
+ ---
700
+
701
+ # Step 8: Create a Wokspace
702
+
703
+ <div flex justify-center m-4>
704
+ <img src="/assets/step-8-workspace.png"/>
705
+ </div>
706
+
707
+ ---
708
+
709
+ # Step 8: Wokspace ID and Key
710
+
711
+ <div flex justify-center m-4>
712
+ <img src="/assets/step-8-workspace-ids.png"/>
713
+ </div>
714
+
715
+ ---
716
+
717
+ # Step 8: Download the Workspace env
718
+
719
+ - You can also download the ` env` file with both workspaceId and the key.
720
+ - The file is called ` ${workspace- name}.plt .txt `
721
+ - Save it in ` movie- quotes/ apps/ movie- quotes- api` folder in your project
722
+
723
+ <div flex justify-center m-4>
724
+ <img src="/assets/step-8-workspace-ids-2.png" width="500"/>
725
+ </div>
726
+
727
+ ---
728
+
729
+ # Step 8: Now the Workspace is ready!
730
+
731
+ <div flex justify-center m-4>
732
+ <img src="/assets/step-8-workspace-ready.png"/>
733
+ </div>
734
+
735
+ ---
736
+
737
+ # Step 8: Deploy using the CLI
738
+
739
+ - Go in the ` movie- quotes- api` folder:
740
+ ` ` ` bash
741
+ cd ./ movie- quotes/ apps/ movie- quotes- api
742
+ ` ` `
743
+
744
+ - Launch the deployment:
745
+
746
+ ` ` ` bash
747
+ npx platformatic deploy -- keys= ./ test- workspace- demo .plt .txt
748
+ ` ` `
749
+
750
+ <div flex justify-center m-4>
751
+ <img src="/assets/step-8-deploy.png"/>
752
+ </div>
753
+
754
+ ---
755
+
756
+ # Step 8: Check the deployment:
757
+
758
+ <div flex justify-center m-4>
759
+ <img src="/assets/step-8-deploy-ok.png" width="800"/>
760
+ </div>
761
+
762
+ ---
763
+
764
+ # Step 8: Test the deployment:
765
+
766
+ ` ` ` bash
767
+ curl https: // gorgeous-vacuous-young-chalk.deploy.space/quotes
768
+ ` ` `
769
+
770
+
771
+ <div flex justify-center m-4>
772
+ <img src="/assets/step-8-deploy-test.png" width="500"/>
773
+ </div>
774
+
775
+
776
+ ---
777
+
778
+ # Step 8: Connect the UI to the deployed API
779
+
780
+ - Open ` movie- quotes/ apps/ movie- quotes- frontend/ .env ` and change ` PUBLIC_GRAPHQL_API_ENDPOINT ` to the deployed API endpoint (use the actual URL):
781
+
782
+
783
+ ` ` ` js
784
+ PUBLIC_GRAPHQL_API_ENDPOINT = https: // gorgeous-vacuous-young-chalk.deploy.space/graphql
785
+ ` ` `
786
+
787
+ - Restart the frontend dev server and check the UI is still working
788
+
789
+ ---
790
+
791
+ # Next Steps
792
+
683
793
- Add security integrating with a third party authentication service (like [Auth0](https://auth0.com/), see how [here](https://oss.platformatic.dev/docs/next/guides/jwt-auth0)).
684
794
- Add authorizations at API level (see [references](https://oss.platformatic.dev/docs/next/reference/db-authorization/introduction))
685
795
- Generate [TypeScript](https://www.typescriptlang.org/) types
0 commit comments