Skip to content

Commit 3a66b16

Browse files
committed
update broker.createService signature
1 parent 7d30cc3 commit 3a66b16

File tree

16 files changed

+77
-54
lines changed

16 files changed

+77
-54
lines changed

examples/authentication/index.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
/**
44
* This example shows how to use authentication with API Gateway
5-
*
5+
*
66
* Example:
7-
*
7+
*
88
* - Try to call /test/whoami. It will show a message "Who are you?"
9-
*
9+
*
1010
* http://localhost:3000/test/whoami
11-
*
11+
*
1212
* - Set a query param "access_token" with value "12345" and try again. Authentication will succeed and a message with the "Hello John" will be shown
13-
*
13+
*
1414
*/
1515

1616
let path = require("path");
@@ -27,7 +27,7 @@ broker.loadService(path.join(__dirname, "..", "test.service"));
2727

2828
// Load API Gateway
2929
broker.createService({
30-
mixins: ApiGatewayService,
30+
mixins: [ApiGatewayService],
3131

3232
settings: {
3333

@@ -42,12 +42,12 @@ broker.createService({
4242
methods: {
4343
/**
4444
* Authenticate the user from request
45-
*
46-
* @param {Context} ctx
45+
*
46+
* @param {Context} ctx
4747
* @param {Object} route
48-
* @param {IncomingMessage} req
49-
* @param {ServerResponse} res
50-
* @returns
48+
* @param {IncomingMessage} req
49+
* @param {ServerResponse} res
50+
* @returns
5151
*/
5252
authenticate(ctx, route, req, res) {
5353
let accessToken = req.query["access_token"];

examples/authorization/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ broker.loadService(path.join(__dirname, "..", "test.service"));
2929

3030
// Load API Gateway
3131
broker.createService({
32-
mixins: ApiGatewayService,
32+
mixins: [ApiGatewayService],
3333

3434
settings: {
3535

examples/auto-aliases/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ broker.loadService(path.join(__dirname, "..", "post.service"));
2929
broker.loadService(path.join(__dirname, "..", "auth.service"));
3030

3131
// Load API Gateway
32-
broker.createService(ApiService, {
32+
broker.createService({
33+
mixins: [ApiService],
3334
settings: {
3435
routes: [
3536
{

examples/direct-calls/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ let broker = new ServiceBroker({
2424
});
2525

2626
// Load API Gateway
27-
broker.createService(ApiService, {
27+
broker.createService({
28+
mixins: [ApiService],
2829
settings: {
2930
routes: [
3031
{

examples/express/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ broker.loadService(path.join(__dirname, "..", "test.service"));
2727

2828
// Load API Gateway
2929
const svc = broker.createService({
30-
mixins: ApiGatewayService,
30+
mixins: [ApiGatewayService],
3131

3232
settings: {
3333
server: false,

examples/file/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ broker.loadService("./examples/file.service.js");
2828

2929
// Load API Gateway
3030
broker.createService({
31-
mixins: ApiGatewayService,
31+
mixins: [ApiGatewayService],
3232
settings: {
3333
path: "/upload",
3434

examples/full/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ broker.loadServices(path.join(__dirname, ".."), "*.service.js");
7070

7171
// Load API Gateway
7272
broker.createService({
73-
mixins: ApiGatewayService,
73+
mixins: [ApiGatewayService],
7474

7575
settings: {
7676
// Exposed port

examples/middlewares/index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ let broker = new ServiceBroker({
2626
broker.loadService(path.join(__dirname, "..", "test.service"));
2727

2828
// Load API Gateway
29-
broker.createService(ApiService, {
29+
broker.createService({
30+
mixins: [ApiService],
3031
settings: {
3132
routes: [
3233
{
@@ -38,7 +39,7 @@ broker.createService(ApiService, {
3839
whitelist: ["**"],
3940
use: [
4041
(req, res, next) => next(new Error("Something went wrong")),
41-
function (err, req, res, next) {
42+
function(err, req, res, next) {
4243
this.logger.warn("Error occured in middlewares! Terminating request and sending response");
4344
res.end("Handled. No problem.");
4445
},

examples/multi-auth/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ broker.loadService(path.join(__dirname, "..", "test.service"));
3232

3333
// Load API Gateway
3434
broker.createService({
35-
mixins: ApiGatewayService,
35+
mixins: [ApiGatewayService],
3636

3737
settings: {
3838

examples/raw/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const broker = new ServiceBroker({});
2626

2727
// Load API Gateway
2828
broker.createService({
29-
mixins: ApiGatewayService,
29+
mixins: [ApiGatewayService],
3030
settings: {
3131
path: "/api",
3232

examples/rest/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ broker.loadService(path.join(__dirname, "..", "post.service"));
4949

5050
// Load API Gateway
5151
broker.createService({
52-
mixins: ApiGatewayService,
52+
mixins: [ApiGatewayService],
5353
settings: {
5454
routes: [{
5555
// RESTful aliases

examples/routing/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ broker.loadService(path.join(__dirname, "..", "test.service"));
3333

3434
// Load API Gateway
3535
broker.createService({
36-
mixins: ApiGatewayService,
36+
mixins: [ApiGatewayService],
3737
settings: {
3838
optimizeOrder: false,
3939
routes: [

examples/spdy/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ broker.loadService(path.join(__dirname, "..", "test.service"));
2828

2929
// Load API Gateway
3030
broker.createService({
31-
mixins: ApiGatewayService,
31+
mixins: [ApiGatewayService],
3232

3333
settings: {
3434
key: fs.readFileSync(path.join(__dirname, "../ssl/key.pem")),

examples/ssl/index.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22

33
/**
44
* This example demonstrates how to use API Gateway as HTTPS server with whitelist.
5-
*
5+
*
66
* You can access only to math.add, math.div & file.* actions via https://localhost:3000
7-
*
7+
*
88
* Example:
9-
*
9+
*
1010
* - Add two numbers
1111
* https://localhost:3000/math/add?a=25&b=13
12-
*
12+
*
1313
* - Divide two numbers
1414
* https://localhost:3000/math/add?a=25&b=13
15-
*
15+
*
1616
* - Get the logo image (Content-Type: image/png)
1717
* https://localhost:3000/file/image
18-
*
19-
*
18+
*
19+
*
2020
*/
2121

2222
let fs = require("fs");
@@ -35,7 +35,7 @@ broker.loadService(path.join(__dirname, "..", "file.service"));
3535

3636
// Load API Gateway
3737
broker.createService({
38-
mixins: ApiService,
38+
mixins: [ApiService],
3939

4040
// Override default settings
4141
settings: {
@@ -57,7 +57,7 @@ broker.createService({
5757
// Use JSON body-parser module
5858
bodyParsers: {
5959
json: true
60-
}
60+
}
6161
}
6262
]
6363
}

examples/www/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ broker.loadService(path.join(__dirname, "..", "file.service"));
4343

4444
// Load API Gateway
4545
broker.createService({
46-
mixins: ApiGatewayService,
46+
mixins: [ApiGatewayService],
4747

4848
settings: {
4949

0 commit comments

Comments
 (0)