Skip to content

Commit

Permalink
docs: load express-related APIs from @loopback/rest
Browse files Browse the repository at this point in the history
Update code snippets to import from `@loopback/rest` instead
of `@loopback/express`.

Signed-off-by: Miroslav Bajtoš <[email protected]>
  • Loading branch information
bajtos committed Jun 9, 2020
1 parent b307383 commit f3ce27b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions docs/site/Express-middleware.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ If the Express middleware only exposes the handler function without a factory or
a single instance is desired, use `toInterceptor`.

```ts
import {toInterceptor} from '@loopback/express';
import {toInterceptor} from '@loopback/rest';
import morgan from 'morgan';

const morganInterceptor = toInterceptor(morgan('combined'));
Expand All @@ -183,7 +183,7 @@ When the Express middleware module exports a factory function that takes an
optional argument for configuration, use `createInterceptor`.

```ts
import {createInterceptor} from '@loopback/express';
import {createInterceptor} from '@loopback/rest';
import helmet, {IHelmetConfiguration} from 'helmet';
const helmetConfig: IHelmetConfiguration = {};
const helmetInterceptor = createInterceptor(helmet, helmetConfig);
Expand All @@ -208,7 +208,7 @@ for the middleware. We can use `defineInterceptorProvider` to simplify
definition of such provider classes.

```ts
import {defineInterceptorProvider} from '@loopback/express';
import {defineInterceptorProvider} from '@loopback/rest';
import helmet, {IHelmetConfiguration} from 'helmet';

const helmetProviderClass = defineInterceptorProvider<IHelmetConfiguration>(
Expand All @@ -225,7 +225,7 @@ import {config} from '@loopback/core';
import {
ExpressMiddlewareInterceptorProvider,
createMiddlewareInterceptorBinding,
} from '@loopback/express';
} from '@loopback/rest';
import helmet, {IHelmetConfiguration} from 'helmet';

class HelmetInterceptorProvider extends ExpressMiddlewareInterceptorProvider<
Expand Down Expand Up @@ -317,7 +317,7 @@ Let's update `src/interceptors/helmet.interceptor.ts:
```ts
import {config, globalInterceptor} from '@loopback/core';
import helmet, {IHelmetConfiguration} from 'helmet';
import {ExpressMiddlewareInterceptorProvider} from '@loopback/express';
import {ExpressMiddlewareInterceptorProvider} from '@loopback/rest';

@globalInterceptor('middleware', {tags: {name: 'Helmet'}})
export class MorganInterceptor extends ExpressMiddlewareInterceptorProvider<
Expand All @@ -343,7 +343,7 @@ To allow a similar usage in LoopBack, we can create an Express router and
register it to LoopBack as follows:

```ts
import {ExpressRequestHandler, Router} from '@loopback/express';
import {ExpressRequestHandler, Router} from '@loopback/rest';

const handler: ExpressRequestHandler = async (req, res, next) => {
res.send(req.path);
Expand Down
2 changes: 1 addition & 1 deletion docs/site/Middleware.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ work with the `MiddlewareContext` - a wrapper object for `request` and
`response`. The signature is of `Middleware` is:

```ts
import {MiddlewareContext} from '@loopback/express';
import {MiddlewareContext} from '@loopback/rest';
import {Next, ValueOrPromise, InvocationResult} from '@loopback/core';

(context: MiddlewareContext, next: Next) => ValueOrPromise<InvocationResult>;
Expand Down

0 comments on commit f3ce27b

Please sign in to comment.