From f3ce27b315bcc6222e63ee8a500aa0a6e9104402 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Tue, 9 Jun 2020 09:45:39 +0200 Subject: [PATCH 1/2] docs: load express-related APIs from `@loopback/rest` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update code snippets to import from `@loopback/rest` instead of `@loopback/express`. Signed-off-by: Miroslav Bajtoš --- docs/site/Express-middleware.md | 12 ++++++------ docs/site/Middleware.md | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/site/Express-middleware.md b/docs/site/Express-middleware.md index 235fbb7f3b1d..97a45cc7f0cb 100644 --- a/docs/site/Express-middleware.md +++ b/docs/site/Express-middleware.md @@ -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')); @@ -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); @@ -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( @@ -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< @@ -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< @@ -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); diff --git a/docs/site/Middleware.md b/docs/site/Middleware.md index 884f98940123..22b6458f3e5a 100644 --- a/docs/site/Middleware.md +++ b/docs/site/Middleware.md @@ -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; From 6294607b9ca769bdf9932107a6bdd7b57f6e7681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Tue, 9 Jun 2020 09:46:24 +0200 Subject: [PATCH 2/2] fix: remove unused dependency MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miroslav Bajtoš --- examples/passport-login/package.json | 1 - examples/passport-login/tsconfig.json | 3 --- 2 files changed, 4 deletions(-) diff --git a/examples/passport-login/package.json b/examples/passport-login/package.json index 953479b0fd26..091b64807767 100644 --- a/examples/passport-login/package.json +++ b/examples/passport-login/package.json @@ -41,7 +41,6 @@ "@loopback/authentication-passport": "^2.1.6", "@loopback/boot": "^2.3.2", "@loopback/core": "^2.7.1", - "@loopback/express": "^1.2.2", "@loopback/openapi-v3": "^3.4.2", "@loopback/repository": "^2.6.0", "@loopback/rest": "^5.1.0", diff --git a/examples/passport-login/tsconfig.json b/examples/passport-login/tsconfig.json index 61f8ec695180..a4b67558f9d2 100644 --- a/examples/passport-login/tsconfig.json +++ b/examples/passport-login/tsconfig.json @@ -27,9 +27,6 @@ { "path": "../../packages/core/tsconfig.json" }, - { - "path": "../../packages/express/tsconfig.json" - }, { "path": "../../packages/http-caching-proxy/tsconfig.json" },