Explorar el Código

docs: Add links to real-world-vendure repo

Relates to #214
Michael Bromley hace 6 años
padre
commit
838983fbfe

+ 4 - 0
docs/content/docs/developer-guide/payment-integrations.md

@@ -7,6 +7,10 @@ showtoc: true
 
 Vendure can support many kinds of payment workflows, such as authorizing and capturing payment in a single step upon checkout or authorizing on checkout and then capturing on fulfillment. 
 
+{{% alert "primary" %}}
+  For a complete working example of a real payment integration, see the [real-world-vendure Braintree plugin](https://github.com/vendure-ecommerce/real-world-vendure/tree/master/src/plugins/braintree)
+{{% /alert %}}
+
 ## Creating an integration
 
 Payment integrations are created by creating a new [PaymentMethodHandler]({{< relref "payment-method-handler" >}}) and passing that handler into the [`paymentOptions.paymentMethodHandlers`]({{< relref "payment-options" >}}) array in the VendureConfig.

+ 31 - 5
docs/content/docs/developer-guide/plugins/_index.md

@@ -33,6 +33,10 @@ A plugin in Vendure is a specialized Nestjs Module which is decorated with the [
 
 Here are some simplified examples of plugins which serve to illustrate what can be done with Vendure plugins. *Note: implementation details are skipped in these examples for the sake of brevity. A complete example with explanation can be found in [Writing A Vendure Plugin]({{< relref "writing-a-vendure-plugin" >}}).*
 
+{{% alert "primary" %}}
+  For a complete working example of a Vendure plugin, see the [real-world-vendure Reviews plugin](https://github.com/vendure-ecommerce/real-world-vendure/tree/master/src/plugins/reviews)
+{{% /alert %}}
+
 ### Modifying the VendureConfig
 
 This example shows how to modify the VendureConfig, in this case by adding a custom field to allow product ratings.
@@ -51,6 +55,26 @@ This example shows how to modify the VendureConfig, in this case by adding a cus
 class ProductRatingPlugin {}
 ```
 
+### Defining a new database entity
+
+This example shows how new TypeORM database entities can be defined by plugins.
+
+```TypeScript
+@Entity()
+class ProductReview extends VendureEntity {
+  @Column()
+  text: string;
+  
+  @Column()
+  rating: number;
+}
+
+@VendurePlugin({
+  entites: [ProductReview],
+})
+export class ReviewsPlugin {}
+```
+
 ### Extending the GraphQL API
 
 This example adds a new query to the GraphQL Admin API. It also demonstrates how [Nest's dependency injection](https://docs.nestjs.com/providers) can be used to encapsulate and inject services within the plugin module.
@@ -112,7 +136,9 @@ export class ProductsController {
 
 ### Running processes on the Worker
 
-This example shows how to set up a microservice running on the Worker process, as well as subcribing to events via the EventBus.
+This example shows how to set up a microservice running on the Worker process, as well as subscribing to events via the EventBus.
+
+Also see the docs for [WorkerService]({{< relref "worker-service" >}}) and [WorkerMessage]({{< relref "worker-message" >}}).
 
 ```TypeScript
 @VendurePlugin({
@@ -122,7 +148,7 @@ This example shows how to set up a microservice running on the Worker process, a
 export class OrderAnalyticsPlugin implements OnVendureBootstrap {
 
   constructor(
-    @Inject(VENDURE_WORKER_CLIENT) private client: ClientProxy,
+    private workerService: WorkerService,
     private eventBus: EventBus,
   ) {}
   
@@ -133,9 +159,9 @@ export class OrderAnalyticsPlugin implements OnVendureBootstrap {
    * the Worker process to let it process that order.
    */
   onVendureBootstrap() {
-    this.eventBus.subscribe(OrderStateTransitionEvent, event => {
+    this.eventBus.ofType(OrderStateTransitionEvent).subscribe(event => {
       if (event.toState === 'Fulfilled') {
-        this.client.send('ORDER_PLACED', event.order).subscribe();
+        this.workerService.send(new ProcessOrderMessage({ order: event.order })).subscribe();
       }
     });
   }
@@ -148,7 +174,7 @@ export class OrderAnalyticsPlugin implements OnVendureBootstrap {
 @Controller()
 class OrderProcessingController {
 
-  @MessagePattern('ORDER_PLACED')
+  @MessagePattern(ProcessOrderMessage.pattern)
   async processOrder(order) {
     // Do some expensive computation
   }

+ 4 - 0
docs/content/docs/developer-guide/plugins/extending-the-admin-ui.md

@@ -12,6 +12,10 @@ This is possible by defining [AdminUiExtensions]({{< ref "admin-ui-extension" >}
 Note: an understanding of [Angular](https://angular.io/) is required to successfully work with UI extensions. Try [Angular's "Getting Started" guide](https://angular.io/start) to learn more.
 {{% /alert %}}
 
+{{% alert "primary" %}}
+  For a complete working example of a Vendure plugin which extends the Admin UI, see the [real-world-vendure Reviews plugin](https://github.com/vendure-ecommerce/real-world-vendure/tree/master/src/plugins/reviews)
+{{% /alert %}}
+
 ## Simple Example
 
 Here is a very simple example to illustrate how a UI extension works:

+ 4 - 0
docs/content/docs/developer-guide/plugins/writing-a-vendure-plugin.md

@@ -7,6 +7,10 @@ weight: 0
 
 This is a complete example of how to implement a simple plugin step-by-step.
 
+{{% alert "primary" %}}
+  For a complete working example of a Vendure plugin, see the [real-world-vendure Reviews plugin](https://github.com/vendure-ecommerce/real-world-vendure/tree/master/src/plugins/reviews)
+{{% /alert %}}
+
 ## Example: RandomCatPlugin
 
 Let's learn about Vendure plugins by writing a plugin which defines a new database entity and GraphQL mutation.

+ 4 - 0
docs/content/docs/developer-guide/testing.md

@@ -9,6 +9,10 @@ Vendure plugins allow you to extend all aspects of the standard Vendure server.
 
 The `@vendure/testing` package gives you some simple but powerful tooling for creating end-to-end tests for your custom Vendure code.
 
+{{% alert "primary" %}}
+  For a working example of a Vendure plugin with e2e testing, see the [real-world-vendure Reviews plugin](https://github.com/vendure-ecommerce/real-world-vendure/tree/master/src/plugins/reviews)
+{{% /alert %}}
+
 ## Usage
 
 ### Install dependencies

+ 10 - 10
packages/core/src/worker/types.ts

@@ -4,28 +4,28 @@
  * by the {@link WorkerService} `send` method.
  *
  * @example
- * ```
+ * ```TypeScript
  * export class ReindexMessage extends WorkerMessage<{ ctx: RequestContext }, boolean> {
- *     static readonly pattern = 'Reindex';
+ *   static readonly pattern = 'Reindex';
  * }
  *
  * // in a Service running on the main process
  * class MyService {
  *
- *      constructor(private workerService: WorkerService) {}
+ *   constructor(private workerService: WorkerService) {}
  *
- *      reindex(ctx: RequestContext): Observable<boolean>> {
- *          return this.workerService.send(new ReindexMessage({ ctx }))
- *      }
+ *   reindex(ctx: RequestContext): Observable<boolean>> {
+ *     return this.workerService.send(new ReindexMessage({ ctx }))
+ *   }
  * }
  *
  * // in a microservice Controller on the worker process
  * class MyController {
  *
- *      \@MessagePattern(ReindexMessage.pattern)
- *      reindex({ ctx: rawContext }: ReindexMessage['data']): Observable<ReindexMessage['response']> {
- *         // ... some long-running workload
- *      }
+ *  \@MessagePattern(ReindexMessage.pattern)
+ *  reindex({ ctx: rawContext }: ReindexMessage['data']): Observable<ReindexMessage['response']> {
+ *    // ... some long-running workload
+ *  }
  * }
  * ```
  *