Skip to content

Commit

Permalink
Docs: Improve example
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed May 9, 2020
1 parent 6dc06f8 commit 7546880
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const startPlugin = require('@overlook/plugin-start');
const express = require('express');

const StartStopRoute = Route.extend( startPlugin );
const { START_ROUTE, STOP_ROUTE } = startPlugin;
const { START_ROUTE, STOP_ROUTE, START, STOP } = startPlugin;

const SERVER = Symbol('SERVER');
const PORT = 3000;
Expand Down Expand Up @@ -85,9 +85,16 @@ class ServerRoute extends StartStopRoute {
await super[STOP_ROUTE]();
}
}
```

When the application is loaded, you can then call `router[START]` to start it serving requests.
const app = new ServerRoute();

// Start app
await app.init();
await app[START]();

// Later, stop app
await app[STOP]();
```

NB [@overlook/plugin-serve-http](https://www.npmjs.com/package/@overlook/plugin-serve-http) does much the same as above example.

Expand Down

0 comments on commit 7546880

Please sign in to comment.