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
1 change: 1 addition & 0 deletions examples/access-control-migration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"test:dev": "lb-mocha --allow-console-logs dist/__tests__/**/*.js",
"verify": "npm pack && tar xf loopback-access-control-migration*.tgz && tree package && npm run clean",
"migrate": "node ./dist/migrate",
"openapi-spec": "node ./dist/openapi-spec",
"prestart": "npm run build",
"start": "node ."
},
Expand Down
25 changes: 25 additions & 0 deletions examples/access-control-migration/src/migrate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright IBM Corp. 2020. All Rights Reserved.
// Node module: @loopback/example-access-control-migration
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

import {AccessControlApplication} from './application';

export async function migrate(args: string[]) {
const existingSchema = args.includes('--rebuild') ? 'drop' : 'alter';
console.log('Migrating schemas (%s existing schema)', existingSchema);

const app = new AccessControlApplication();
await app.boot();
await app.migrateSchema({existingSchema});

// Connectors usually keep a pool of opened connections,
// this keeps the process running even after all work is done.
// We need to exit explicitly.
process.exit(0);
}

migrate(process.argv).catch(err => {
console.error('Cannot migrate database schema', err);
process.exit(1);
});
28 changes: 28 additions & 0 deletions examples/access-control-migration/src/openapi-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright IBM Corp. 2020. All Rights Reserved.
// Node module: @loopback/example-access-control-migration
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

import {ApplicationConfig} from '@loopback/core';
import {AccessControlApplication} from './application';

/**
* Export the OpenAPI spec from the application
*/
async function exportOpenApiSpec(): Promise<void> {
const config: ApplicationConfig = {
rest: {
port: +(process.env.PORT ?? 3000),
host: process.env.HOST ?? 'localhost',
},
};
const outFile = process.argv[2] ?? '';
const app = new AccessControlApplication(config);
await app.boot();
await app.exportOpenApiSpec(outFile);
}

exportOpenApiSpec().catch(err => {
console.error('Fail to export OpenAPI spec from the application.', err);
process.exit(1);
});
1 change: 1 addition & 0 deletions examples/greeting-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"test": "lb-mocha \"dist/__tests__/**/*.js\"",
"posttest": "npm run lint",
"test:dev": "lb-mocha --allow-console-logs dist/__tests__/**/*.js && npm run posttest",
"openapi-spec": "node ./dist/openapi-spec",
"prestart": "npm run build",
"start": "node .",
"verify": "npm pack && tar xf *example-greeting-app*.tgz && tree package && npm run clean"
Expand Down
28 changes: 28 additions & 0 deletions examples/greeting-app/src/openapi-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright IBM Corp. 2020. All Rights Reserved.
// Node module: @loopback/example-greeting-app
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

import {ApplicationConfig} from '@loopback/core';
import {GreetingApplication} from './application';

/**
* Export the OpenAPI spec from the application
*/
async function exportOpenApiSpec(): Promise<void> {
const config: ApplicationConfig = {
rest: {
port: +(process.env.PORT ?? 3000),
host: process.env.HOST ?? 'localhost',
},
};
const outFile = process.argv[2] ?? '';
const app = new GreetingApplication(config);
await app.boot();
await app.exportOpenApiSpec(outFile);
}

exportOpenApiSpec().catch(err => {
console.error('Fail to export OpenAPI spec from the application.', err);
process.exit(1);
});
1 change: 1 addition & 0 deletions examples/lb3-application/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"test:dev": "lb-mocha --allow-console-logs dist/__tests__/**/*.js && npm run posttest",
"verify": "npm pack && tar xf loopback-lb3-application*.tgz && tree package && npm run clean",
"migrate": "node ./dist/migrate",
"openapi-spec": "node ./dist/openapi-spec",
"prestart": "npm run build",
"start": "node ."
},
Expand Down
28 changes: 28 additions & 0 deletions examples/lb3-application/src/openapi-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright IBM Corp. 2020. All Rights Reserved.
// Node module: @loopback/example-lb3-application
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

import {ApplicationConfig} from '@loopback/core';
import {CoffeeShopApplication} from './application';

/**
* Export the OpenAPI spec from the application
*/
async function exportOpenApiSpec(): Promise<void> {
const config: ApplicationConfig = {
rest: {
port: +(process.env.PORT ?? 3000),
host: process.env.HOST ?? 'localhost',
},
};
const outFile = process.argv[2] ?? '';
const app = new CoffeeShopApplication(config);
await app.boot();
await app.exportOpenApiSpec(outFile);
}

exportOpenApiSpec().catch(err => {
console.error('Fail to export OpenAPI spec from the application.', err);
process.exit(1);
});
1 change: 1 addition & 0 deletions examples/multi-tenancy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"docker:build": "docker build -t @loopback/example-multi-tenancy .",
"docker:run": "docker run -p 3000:3000 -d @loopback/example-multi-tenancy",
"migrate": "node ./dist/migrate",
"openapi-spec": "node ./dist/openapi-spec",
"prestart": "npm run build",
"start": "node -r source-map-support/register .",
"clean": "lb-clean dist *.tsbuildinfo .eslintcache"
Expand Down
28 changes: 28 additions & 0 deletions examples/multi-tenancy/src/openapi-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright IBM Corp. 2020. All Rights Reserved.
// Node module: @loopback/example-multi-tenancy
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

import {ApplicationConfig} from '@loopback/core';
import {ExampleMultiTenancyApplication} from './application';

/**
* Export the OpenAPI spec from the application
*/
async function exportOpenApiSpec(): Promise<void> {
const config: ApplicationConfig = {
rest: {
port: +(process.env.PORT ?? 3000),
host: process.env.HOST ?? 'localhost',
},
};
const outFile = process.argv[2] ?? '';
const app = new ExampleMultiTenancyApplication(config);
await app.boot();
await app.exportOpenApiSpec(outFile);
}

exportOpenApiSpec().catch(err => {
console.error('Fail to export OpenAPI spec from the application.', err);
process.exit(1);
});
1 change: 1 addition & 0 deletions examples/rest-crud/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"test:dev": "lb-mocha --allow-console-logs dist/__tests__/**/*.js && npm run posttest",
"verify": "npm pack && tar xf loopback-rest-crud*.tgz && tree package && npm run clean",
"migrate": "node ./dist/migrate",
"openapi-spec": "node ./dist/openapi-spec",
"prestart": "npm run build",
"start": "node ."
},
Expand Down
28 changes: 28 additions & 0 deletions examples/rest-crud/src/openapi-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright IBM Corp. 2020. All Rights Reserved.
// Node module: @loopback/example-rest-crud
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

import {ApplicationConfig} from '@loopback/core';
import {TodoApplication} from './application';

/**
* Export the OpenAPI spec from the application
*/
async function exportOpenApiSpec(): Promise<void> {
const config: ApplicationConfig = {
rest: {
port: +(process.env.PORT ?? 3000),
host: process.env.HOST ?? 'localhost',
},
};
const outFile = process.argv[2] ?? '';
const app = new TodoApplication(config);
await app.boot();
await app.exportOpenApiSpec(outFile);
}

exportOpenApiSpec().catch(err => {
console.error('Fail to export OpenAPI spec from the application.', err);
process.exit(1);
});
1 change: 1 addition & 0 deletions examples/todo-jwt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"test:dev": "lb-mocha --allow-console-logs dist/__tests__/**/*.js && npm run posttest",
"verify": "npm pack && tar xf loopback-todo*.tgz && tree package && npm run clean",
"migrate": "node ./dist/migrate",
"openapi-spec": "node ./dist/openapi-spec",
"prestart": "npm run build",
"start": "node ."
},
Expand Down
28 changes: 28 additions & 0 deletions examples/todo-jwt/src/openapi-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright IBM Corp. 2020. All Rights Reserved.
// Node module: @loopback/example-todo-jwt
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

import {ApplicationConfig} from '@loopback/core';
import {TodoListApplication} from './application';

/**
* Export the OpenAPI spec from the application
*/
async function exportOpenApiSpec(): Promise<void> {
const config: ApplicationConfig = {
rest: {
port: +(process.env.PORT ?? 3000),
host: process.env.HOST ?? 'localhost',
},
};
const outFile = process.argv[2] ?? '';
const app = new TodoListApplication(config);
await app.boot();
await app.exportOpenApiSpec(outFile);
}

exportOpenApiSpec().catch(err => {
console.error('Fail to export OpenAPI spec from the application.', err);
process.exit(1);
});
1 change: 1 addition & 0 deletions examples/todo-list/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"test:dev": "lb-mocha --allow-console-logs dist/__tests__/**/*.js && npm run posttest",
"verify": "npm pack && tar xf loopback-todo-list*.tgz && tree package && npm run clean",
"migrate": "node ./dist/migrate",
"openapi-spec": "node ./dist/openapi-spec",
"prestart": "npm run build",
"start": "node ."
},
Expand Down
28 changes: 28 additions & 0 deletions examples/todo-list/src/openapi-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright IBM Corp. 2020. All Rights Reserved.
// Node module: @loopback/example-todo-list
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

import {ApplicationConfig} from '@loopback/core';
import {TodoListApplication} from './application';

/**
* Export the OpenAPI spec from the application
*/
async function exportOpenApiSpec(): Promise<void> {
const config: ApplicationConfig = {
rest: {
port: +(process.env.PORT ?? 3000),
host: process.env.HOST ?? 'localhost',
},
};
const outFile = process.argv[2] ?? '';
const app = new TodoListApplication(config);
await app.boot();
await app.exportOpenApiSpec(outFile);
}

exportOpenApiSpec().catch(err => {
console.error('Fail to export OpenAPI spec from the application.', err);
process.exit(1);
});
1 change: 1 addition & 0 deletions examples/todo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"test:dev": "lb-mocha --allow-console-logs dist/__tests__/**/*.js && npm run posttest",
"verify": "npm pack && tar xf loopback-todo*.tgz && tree package && npm run clean",
"migrate": "node ./dist/migrate",
"openapi-spec": "node ./dist/openapi-spec",
"prestart": "npm run build",
"start": "node ."
},
Expand Down
28 changes: 28 additions & 0 deletions examples/todo/src/openapi-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright IBM Corp. 2018,2020. All Rights Reserved.
// Node module: @loopback/example-todo
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

import {ApplicationConfig} from '@loopback/core';
import {TodoListApplication} from './application';

/**
* Export the OpenAPI spec from the application
*/
async function exportOpenApiSpec(): Promise<void> {
const config: ApplicationConfig = {
rest: {
port: +(process.env.PORT ?? 3000),
host: process.env.HOST ?? 'localhost',
},
};
const outFile = process.argv[2] ?? '';
const app = new TodoListApplication(config);
await app.boot();
await app.exportOpenApiSpec(outFile);
}

exportOpenApiSpec().catch(err => {
console.error('Fail to export OpenAPI spec from the application.', err);
process.exit(1);
});
1 change: 1 addition & 0 deletions examples/validation-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"docker:build": "docker build -t validation-app .",
"docker:run": "docker run -p 3000:3000 -d validation-app",
"migrate": "node ./dist/migrate",
"openapi-spec": "node ./dist/openapi-spec",
"prestart": "npm run build",
"start": "node -r source-map-support/register ."
},
Expand Down
28 changes: 28 additions & 0 deletions examples/validation-app/src/openapi-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright IBM Corp. 2020. All Rights Reserved.
// Node module: @loopback/example-validation-app
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

import {ApplicationConfig} from '@loopback/core';
import {ValidationApplication} from './application';

/**
* Export the OpenAPI spec from the application
*/
async function exportOpenApiSpec(): Promise<void> {
const config: ApplicationConfig = {
rest: {
port: +(process.env.PORT ?? 3000),
host: process.env.HOST ?? 'localhost',
},
};
const outFile = process.argv[2] ?? '';
const app = new ValidationApplication(config);
await app.boot();
await app.exportOpenApiSpec(outFile);
}

exportOpenApiSpec().catch(err => {
console.error('Fail to export OpenAPI spec from the application.', err);
process.exit(1);
});
23 changes: 23 additions & 0 deletions packages/cli/generators/app/templates/src/openapi-spec.ts.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {ApplicationConfig} from '@loopback/core';
import {<%= project.applicationName %>} from './application';

/**
* Export the OpenAPI spec from the application
*/
async function exportOpenApiSpec(): Promise<void> {
const config: ApplicationConfig = {
rest: {
port: +(process.env.PORT ?? 3000),
host: process.env.HOST ?? 'localhost',
},
};
const outFile = process.argv[2] ?? '';
const app = new <%= project.applicationName %>(config);
await app.boot();
await app.exportOpenApiSpec(outFile);
}

exportOpenApiSpec().catch(err => {
console.error('Fail to export OpenAPI spec from the application.', err);
process.exit(1);
});
1 change: 1 addition & 0 deletions packages/cli/generators/project/templates/package.json.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"docker:run": "docker run -p 3000:3000 -d <%= project.name -%>",
<%_ } -%>
"migrate": "node ./dist/migrate",
"openapi-spec": "node ./dist/openapi-spec",
"prestart": "npm run build",
"start": "node -r source-map-support/register .",
<% } -%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"docker:run": "docker run -p 3000:3000 -d <%= project.name -%>",
<%_ } -%>
"migrate": "node ./dist/migrate",
"openapi-spec": "node ./dist/openapi-spec",
"start": "npm run build && node -r source-map-support/register .",
<% } -%>
"prepare": "npm run build"
Expand Down
Loading