Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions docs/site/express-with-lb4-rest-tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,9 @@ import {ApplicationConfig} from '@loopback/core';
import express from 'express';

export class ExpressServer {
private app: express.Application;
private lbApp: NoteApplication;
public readonly app: express.Application;
public readonly lbApp: NoteApplication;
private server?: http.Server;

constructor(options: ApplicationConfig = {}) {
this.app = express();
Expand Down Expand Up @@ -223,8 +224,9 @@ Express application:
import pEvent from 'p-event';

export class ExpressServer {
private app: express.Application;
private lbApp: NoteApplication;
public readonly app: express.Application;
public readonly lbApp: NoteApplication;
private server?: http.Server;

constructor(options: ApplicationConfig = {}) {
//...
Expand All @@ -236,7 +238,7 @@ export class ExpressServer {

public async start() {
await this.lbApp.start();
const port = this.lbApp.restServer.config.port || 3000;
const port = this.lbApp.restServer.config.port ?? 3000;
const host = this.lbApp.restServer.config.host || '127.0.0.1';
this.server = this.app.listen(port, host);
await pEvent(this.server, 'listening');
Expand Down
8 changes: 8 additions & 0 deletions examples/express-composition/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright IBM Corp. 2020. All Rights Reserved.
// Node module: @loopback/example-express-composition
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

module.exports = {
extends: ['@loopback/eslint-config'],
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function setupExpressApplication(): Promise<AppWithClient> {

const lbApp = server.lbApp;

const client = supertest('http://127.0.0.1:3000');
const client = supertest(server.app);

return {server, client, lbApp};
}
Expand Down
4 changes: 2 additions & 2 deletions examples/express-composition/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import path from 'path';
import {NoteApplication} from './application';

export class ExpressServer {
private app: express.Application;
public readonly app: express.Application;
public readonly lbApp: NoteApplication;
private server?: http.Server;

Expand Down Expand Up @@ -40,7 +40,7 @@ export class ExpressServer {

public async start() {
await this.lbApp.start();
const port = this.lbApp.restServer.config.port || 3000;
const port = this.lbApp.restServer.config.port ?? 3000;
const host = this.lbApp.restServer.config.host ?? '127.0.0.1';
this.server = this.app.listen(port, host);
await pEvent(this.server, 'listening');
Expand Down