Skip to content

Commit

Permalink
feat(cli): use app.static for default home page
Browse files Browse the repository at this point in the history
See #1988
  • Loading branch information
raymondfeng committed Nov 8, 2018
1 parent a6ed72f commit 1dcf169
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 138 deletions.
4 changes: 4 additions & 0 deletions examples/soap-calculator/src/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {RepositoryMixin} from '@loopback/repository';
import {RestApplication} from '@loopback/rest';
import {ServiceMixin} from '@loopback/service-proxy';
import {MySequence} from './sequence';
import * as path from 'path';

export class SoapCalculatorApplication extends BootMixin(
ServiceMixin(RepositoryMixin(RestApplication)),
Expand All @@ -14,6 +15,9 @@ export class SoapCalculatorApplication extends BootMixin(
// Set up the custom sequence
this.sequence(MySequence);

// Set up default home page
this.static('/', path.join(__dirname, '../../public'));

this.projectRoot = __dirname;
// Customize @loopback/boot Booter Conventions here
this.bootOptions = {
Expand Down
31 changes: 0 additions & 31 deletions examples/soap-calculator/src/controllers/home-page.controller.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {Client} from '@loopback/testlab';
import {SoapCalculatorApplication} from '../..';
import {setupApplication} from './test-helper';

describe('HomePageController', () => {
describe('HomePage', () => {
let app: SoapCalculatorApplication;
let client: Client;

Expand Down
4 changes: 4 additions & 0 deletions examples/todo-list/src/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {ApplicationConfig} from '@loopback/core';
import {RepositoryMixin} from '@loopback/repository';
import {RestApplication} from '@loopback/rest';
import {MySequence} from './sequence';
import * as path from 'path';

export class TodoListApplication extends BootMixin(
RepositoryMixin(RestApplication),
Expand All @@ -18,6 +19,9 @@ export class TodoListApplication extends BootMixin(
// Set up the custom sequence
this.sequence(MySequence);

// Set up default home page
this.static('/', path.join(__dirname, '../../public'));

this.projectRoot = __dirname;
// Customize @loopback/boot Booter Conventions here
this.bootOptions = {
Expand Down
31 changes: 0 additions & 31 deletions examples/todo-list/src/controllers/home-page.controller.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {Client} from '@loopback/testlab';
import {TodoListApplication} from '../..';
import {setupApplication} from './test-helper';

describe('HomePageController', () => {
describe('HomePage', () => {
let app: TodoListApplication;
let client: Client;

Expand Down
4 changes: 4 additions & 0 deletions examples/todo/src/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {RepositoryMixin} from '@loopback/repository';
import {RestApplication} from '@loopback/rest';
import {ServiceMixin} from '@loopback/service-proxy';
import {MySequence} from './sequence';
import * as path from 'path';

export class TodoListApplication extends BootMixin(
ServiceMixin(RepositoryMixin(RestApplication)),
Expand All @@ -19,6 +20,9 @@ export class TodoListApplication extends BootMixin(
// Set up the custom sequence
this.sequence(MySequence);

// Set up default home page
this.static('/', path.join(__dirname, '../../public'));

this.projectRoot = __dirname;
// Customize @loopback/boot Booter Conventions here
this.bootOptions = {
Expand Down
31 changes: 0 additions & 31 deletions examples/todo/src/controllers/home-page.controller.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {Client} from '@loopback/testlab';
import {TodoListApplication} from '../..';
import {setupApplication} from './test-helper';

describe('HomePageController', () => {
describe('HomePage', () => {
let app: TodoListApplication;
let client: Client;

Expand Down
4 changes: 4 additions & 0 deletions packages/cli/generators/app/templates/src/application.ts.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {RestApplication} from '@loopback/rest';
import {ServiceMixin} from '@loopback/service-proxy';
<% } -%>
import {MySequence} from './sequence';
import * as path from 'path';

<% if (project.appClassWithMixins) { -%>
export class <%= project.applicationName %> extends BootMixin(
Expand All @@ -24,6 +25,9 @@ export class <%= project.applicationName %> extends BootMixin(RestApplication) {
// Set up the custom sequence
this.sequence(MySequence);
// Set up default home page
this.static('/', path.join(__dirname, '../../public'));
this.projectRoot = __dirname;
// Customize @loopback/boot Booter Conventions here
this.bootOptions = {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {Client} from '@loopback/testlab';
import {<%= project.applicationName %>} from '../..';
import {setupApplication} from './test-helper';

describe('HomePageController', () => {
describe('HomePage', () => {
let app: <%= project.applicationName %>;
let client: Client;

Expand Down
12 changes: 2 additions & 10 deletions packages/cli/test/integration/generators/app.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,8 @@ describe('app-generator specific files', () => {
/describe\('PingController'/,
);
assert.fileContent(
'src/controllers/home-page.controller.ts',
/export class HomePageController/,
);
assert.fileContent(
'src/controllers/home-page.controller.ts',
/homePage\(\)/,
);
assert.fileContent(
'test/acceptance/home-page.controller.acceptance.ts',
/describe\('HomePageController'/,
'test/acceptance/home-page.acceptance.ts',
/describe\('HomePage'/,
);
assert.fileContent(
'test/acceptance/test-helper.ts',
Expand Down

0 comments on commit 1dcf169

Please sign in to comment.