Skip to content

Commit

Permalink
fix(docs): fix various doc issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nfroidure committed Jun 19, 2022
1 parent 8070ed5 commit 105ce77
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 47 deletions.
14 changes: 7 additions & 7 deletions packages/whook-aws-lambda/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ You can find a complete setup with a Terraform deployment example in

## Quick setup

Install this module and its peer dependencies :
Install this module:

```sh
npm i @whook/aws-lambda;
npm i --save-dev @whook/http-transaction esbuild
```

Add this module to your Whook plugins and tweak the 2 build functions in your
`build.ts` main file:
`src/build.ts` main file:

```diff
import {
// (...)
- runBuild as runBaseBuild,
- prepareBuildEnvironment as prepareBaseBuildEnvironment,
// (...)
} from '@whook/whook';
+import {
Expand Down Expand Up @@ -155,7 +155,7 @@ export default CONFIG;

# Build

To build your functions :
To build your functions:

```sh
# Build all functions
Expand All @@ -167,18 +167,18 @@ npm run build -- getPing

# Debug

You can easily test your function builds by adding `@whook/aws-lambda` to your
You can easily test your functions builds by adding `@whook/aws-lambda` to your
`WHOOK_PLUGINS` list. It provides you some commands like the `testHTTPLambda`
one:

```sh
npx whook testHTTPLambda --name getPing
```

To get more insights when errors happens:
To get more insights when some errors happens:

```sh
npm run whook-dev -- testHTTPLambda --name getPing
DEBUG=whook npm run whook-dev -- testHTTPLambda --name getPing
```

## Deployment
Expand Down
11 changes: 5 additions & 6 deletions packages/whook-gcp-functions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@ You can find a complete setup with a Terraform deployment example in

## Quick setup

Install this module and its peer dependencies :
Install this module:

```sh
npm i @whook/gcp-functions;
npm i --save-dev @whook/http-transaction esbuild
```

Add this module to your Whook plugins and tweak the 2 build functions in your
`build.ts` main file:
`src/build.ts` main file:

```diff
import {
Expand Down Expand Up @@ -155,7 +154,7 @@ export default CONFIG;

# Build

To build your functions :
To build your functions:

```sh
# Build all functions
Expand All @@ -175,10 +174,10 @@ your `WHOOK_PLUGINS` list. It provides you some commands like the
npx whook testHTTPFunction --name getPing
```

To get more insights when errors happens:
To get more insights when some errors happens:

```sh
npm run whook-dev -- testHTTPFunction --name getPing
DEBUG=whook npm run whook-dev -- testHTTPFunction --name getPing
```

## Deployment
Expand Down
6 changes: 3 additions & 3 deletions packages/whook-graphiql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This module provides the GraphIQL UI to your local
## Usage

The `DEV_MODE=1` environment variable must be used when starting your server
(`npm run dev` does it by default).
(the `npm run dev` script of default Whook projects does it by default).

## Setup

Expand All @@ -32,9 +32,9 @@ Update the types (usually in `src/whook.d.ts`):

```diff
+import type {
+ WhookGraphIQLEnv
+ WhookGraphIQLEnv,
+ WhookGraphIQLConfig,
+} from '@whook/swagger-ui';
+} from '@whook/graphiql';

// ...

Expand Down
10 changes: 5 additions & 5 deletions packages/whook-graphql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

Brings GraphQL to your [Whook](https://github.com/nfroidure/whook) server!

This module uses [Apollo](https://www.apollographql.com/) under the hood most of
This module uses [Apollo](https://www.apollographql.com/) under the hood. Most of
its concepts (modules, plugins...) applies to it.

## Quick setup

Install the module in your project:
Install the module and its dependencies in your project:

```sh
npm i @whook/graphql apollo-server-core
Expand All @@ -29,9 +29,9 @@ Update the types (usually in `src/whook.d.ts`):

```diff
+import type {
+ WhookGraphQLEnv
+ WhookGraphQLEnv,
+ WhookGraphQLConfig,
+} from '@whook/swagger-ui';
+} from '@whook/graphql';

// ...

Expand All @@ -56,7 +56,7 @@ declare module '@whook/whook' {
}
```

Declare the plugin into your `index.ts` file:
Declare the plugin into your `src/index.ts` file:

```diff
+ import { gql } from 'apollo-server-core';
Expand Down
3 changes: 2 additions & 1 deletion packages/whook-graphql/src/handlers/postGraphQL.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { autoHandler } from 'knifecycle';
import { YHTTPError } from 'yhttperror';
import { noop, WhookHeaders } from '@whook/whook';
import { noop } from '@whook/whook';
import { Headers } from 'apollo-server-env';
import { runHttpQuery } from 'apollo-server-core';
import type {
WhookAPIHandlerDefinition,
WhookOperation,
WhookResponse,
WhookHeaders,
} from '@whook/whook';
import type { LogService } from 'common-services';
import type { WhookGraphQLService } from '../index.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/whook-graphql/src/services/graphQL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export type WhookGraphQLFragmentService = {
};

export type WhookGraphQLEnv = {
DEV_MODE: string;
DEV_MODE?: string;
};
export type WhookGraphQLConfig = {
GRAPHQL_SERVER_OPTIONS?: Config;
Expand Down
31 changes: 18 additions & 13 deletions packages/whook-oauth2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,21 @@ authenticate and allow client applications to act on behalf of them.

![Code Flow Overview](./code_flow_overview.svg)

The module provides :
The module provides:

- 3 handlers : the 2 OAuth2 standard endpoints (`getOAuth2authorize` and
`postOAuth2Tokentoken`) plus the `postOAuth2Acknowledge` to be used by the SSR
frontend,
- the 5 OAuth2 standard grant types implemented through plug and play services.
You can create your own granter services to create additional grant types.
- 2 OAuth2 handlers implementing the 2 OAuth2 standard endpoints
(`getOAuth2authorize`, `postOAuth2Tokentoken`) to be used by OAuth2 client
applications,
- 4 authentication endpoints to be used by the authorization server directly to
authenticate users (`postAuthLogin`, `postAuthRefresh`, `postAuthLogout`) and
acknowledge the client requests (`postOAuth2Acknowledge`),
- 5 OAuth2 services implementing the standard grant types. You can create your
own granter services to create additional grant types.

This module requires you to implement some services it relies on:

- `oAuth2AccessToken` that generates and checks the `access_token` and the
`oAuth2RefreshToken` for the `refresh_token` both have the same interface,
`oAuth2RefreshToken` for the `refresh_token`, both have the same interface,
- `checkApplication` service that is supposed to check whether an application
can be used or not for a given grant type, a given scope and redirect URI,
- `oAuth2PasswordService` aimed to check the `password` grant type with your own
Expand All @@ -48,7 +51,7 @@ Install the module in your project:
npm i @whook/oauth2
```

Declare the plugin into your `index.ts` file:
Declare the plugin into your `src/index.ts` file:

```diff
// (...)
Expand Down Expand Up @@ -123,7 +126,7 @@ The `oAuth2Granters` service gather the various granters services you can use in
your application but you can write your own that uses a subset or a superset of
these granters.

Here, for example an handler that implement a verify token mechanism in order to
Here, for example a handler that implement a verify token mechanism in order to
validate a user subscription:

```ts
Expand Down Expand Up @@ -259,15 +262,16 @@ export default initPostAuthRefresh;
```

Additionnaly, you could create any handler in the `/auth` path in order to
receive the auth cookies.
receive the auth cookies. For example, you may want to serve user profiles
there.

## Customizing handlers

The endpoints definitions are designed to support the standard OAuth2
definitions but can be easily overriden.

You will have to protect the `postOAuth2Acknowledge` with your own security
mechanism :
You will also have to protect the `postOAuth2Acknowledge` with your own security
mechanism:

```ts
import {
Expand All @@ -283,6 +287,7 @@ export const definition: WhookAPIHandlerDefinition = {
...postOAuth2AcknowledgeDefinition,
operation: {
...postOAuth2AcknowledgeDefinition.operation,
// Complete the definition to protect the endpoint
security: [
{
bearerAuth: ['user'],
Expand Down Expand Up @@ -331,7 +336,7 @@ export const definition: WhookAPIHandlerDefinition = {
```

You will probably need to also protect the `postOAuth2Token` endpoint with your
own security mecanism :
own security mecanism:

```ts
// In a `src/handlers/postOAuth2Token.ts` fileimport {
Expand Down
24 changes: 13 additions & 11 deletions packages/whook-swagger-ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,25 @@
[//]: # (::contents:start)

This module provides the GraphIQL UI to your local
[Whook](https://github.com/nfroidure/whook) server !
[Whook](https://github.com/nfroidure/whook) server !

## Usage

The `DEV_MODE=1` environment variable must be used
when starting your server (`npm run dev` does it
by default).
The `DEV_MODE=1` environment variable must be used when starting your server
(`npm run dev` does it by default).

## Setup

Install the module:

```sh
npm i @whook/swagger-ui
```

To use it, just wrap the HTTP router with this module and
register it again with the `Knifecycle` instance inside the
`runServer` function (usually in `src/index.ts`):
To use it, just wrap the HTTP router with this module and override its
registration with the `Knifecycle` instance inside the `runServer` function
(usually in `src/index.ts`):

```diff
+ import initHTTPRouter from '@whook/http-router';
+ import wrapHTTPRouterWithSwaggerUI from '@whook/swagger-ui';
Expand All @@ -53,11 +54,11 @@ export async function runServer(injectedNames = [], $ = new Knifecycle()) {
}
```

Declare this module types in your `src/whook.d.ts` type
definitions:
Declare this module types in your `src/whook.d.ts` type definitions:

```diff
+import type {
+ WhookSwaggerUIEnv
+ WhookSwaggerUIEnv,
+ WhookAPIOperationSwaggerConfig,
+ WhookSwaggerUIConfig,
+} from '@whook/swagger-ui';
Expand All @@ -69,7 +70,7 @@ declare module '@whook/whook' {
// (...)
+ WhookGraphIQLEnv,
WhookSwaggerUIEnv {}

// ...

export interface WhookConfigs
Expand All @@ -96,6 +97,7 @@ declare module '@whook/whook' {
```

And add the SwaggerUI config (usually in `src/config/common/config.js`):

```diff
import type { WhookConfigs } from '@whook/whook';

Expand Down

0 comments on commit 105ce77

Please sign in to comment.