Skip to content

Commit b69cda1

Browse files
authored
chore(all-services): ping api in sandbox examples (#2134)
* chore(all-services): ping api in sandbox examples solve lint issues also gh-2133 * chore(all-services): lint fix gh-2133
1 parent 13a4945 commit b69cda1

File tree

58 files changed

+28448
-34024
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+28448
-34024
lines changed

package-lock.json

Lines changed: 28092 additions & 33964 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/cli/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ $ npm install -g @sourceloop/cli
1818
$ sl COMMAND
1919
running command...
2020
$ sl (-v|--version|version)
21-
@sourceloop/cli/9.0.1 linux-x64 node-v18.20.3
21+
@sourceloop/cli/9.0.1 darwin-arm64 node-v18.16.0
2222
$ sl --help [COMMAND]
2323
USAGE
2424
$ sl COMMAND

packages/core/src/components/logger-extension/winston/logger-console.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ export class WinstonConsoleLogger extends WinstonLoggerBase {
2424
format.timestamp(),
2525
format.printf(
2626
(log: LogEntry) =>
27-
`[${log.timestamp}] ${log.level} :: ${log.context ?? '-'} :: ${log.key} -> [${log.statusCode ?? '-'}] ${log.message}`,
27+
`[${log.timestamp}] ${log.level} :: ${log.context ?? '-'} :: ${
28+
log.key
29+
} -> [${log.statusCode ?? '-'}] ${log.message}`,
2830
),
2931
);
3032

sandbox/audit-ms-example/src/controllers/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
//
33
// This software is released under the MIT License.
44
// https://opensource.org/licenses/MIT
5+
export * from './ping.controller';
56
export * from './to-do.controller';
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright (c) 2023 Sourcefuse Technologies
2+
//
3+
// This software is released under the MIT License.
4+
// https://opensource.org/licenses/MIT
5+
import {inject} from '@loopback/core';
6+
import {Request, ResponseObject, RestBindings, get} from '@loopback/rest';
7+
import {CONTENT_TYPE, STATUS_CODE} from '@sourceloop/core';
8+
import {authorize} from 'loopback4-authorization';
9+
/**
10+
* OpenAPI response for ping()
11+
*/
12+
const contentType = 'Content-Type';
13+
const PING_RESPONSE: ResponseObject = {
14+
description: 'Ping Response',
15+
content: {
16+
[CONTENT_TYPE.JSON]: {
17+
schema: {
18+
type: 'object',
19+
title: 'PingResponse',
20+
properties: {
21+
greeting: {type: 'string'},
22+
date: {type: 'string'},
23+
url: {type: 'string'},
24+
headers: {
25+
type: 'object',
26+
properties: {
27+
[contentType]: {type: 'string'},
28+
},
29+
additionalProperties: true,
30+
},
31+
},
32+
},
33+
},
34+
},
35+
};
36+
37+
/**
38+
* A simple controller to bounce back http requests
39+
*/
40+
export class PingController {
41+
constructor(
42+
@inject(RestBindings.Http.REQUEST) private readonly req: Request,
43+
) {}
44+
45+
@authorize({permissions: ['*']})
46+
// Map to `GET /ping`
47+
@get('/ping', {
48+
responses: {
49+
[STATUS_CODE.OK]: PING_RESPONSE,
50+
},
51+
})
52+
ping(): object {
53+
// Reply with a greeting, the current time, the url, and request headers
54+
return {
55+
greeting: 'Hello from LoopBack',
56+
date: new Date(),
57+
url: this.req.url,
58+
headers: {...this.req.headers},
59+
};
60+
}
61+
}

sandbox/chat-notification-pubnub-example/services/chat-service/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"dotenv-extended": "^2.9.0",
6868
"loopback-connector-kv-redis": "^4.0.0",
6969
"loopback-connector-postgresql": "^7.1.1",
70+
"loopback4-authorization": "^7.0.2",
7071
"prom-client": "^14.0.1",
7172
"tslib": "^2.6.2"
7273
},

sandbox/chat-notification-pubnub-example/services/chat-service/src/controllers/ping.controller.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
//
33
// This software is released under the MIT License.
44
// https://opensource.org/licenses/MIT
5-
import {inject} from '@loopback/core';
6-
import {Request, ResponseObject, RestBindings, get} from '@loopback/rest';
7-
import {CONTENT_TYPE, STATUS_CODE} from '@sourceloop/core';
5+
import { inject } from '@loopback/core';
6+
import { Request, ResponseObject, RestBindings, get } from '@loopback/rest';
7+
import { CONTENT_TYPE, STATUS_CODE } from '@sourceloop/core';
8+
import { authorize } from 'loopback4-authorization';
89

910
/**
1011
* OpenAPI response for ping()
@@ -43,6 +44,7 @@ export class PingController {
4344
) {}
4445

4546
// Map to `GET /ping`
47+
@authorize({permissions: ['*']})
4648
@get('/ping', {
4749
responses: {
4850
[STATUS_CODE.OK]: PING_RESPONSE,

sandbox/chat-notification-pubnub-example/services/notifications-service/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
"loopback-connector-kv-redis": "^4.0.0",
6969
"loopback-connector-postgresql": "^7.1.1",
7070
"loopback4-notifications": "^8.0.3",
71+
"loopback4-authorization": "^7.0.2",
7172
"nodemailer": "^6.7.5",
7273
"prom-client": "^14.0.1",
7374
"aws-sdk": "^2.1613.0",

sandbox/chat-notification-pubnub-example/services/notifications-service/src/controllers/ping.controller.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import {inject} from '@loopback/core';
66
import {Request, ResponseObject, RestBindings, get} from '@loopback/rest';
77
import {CONTENT_TYPE, STATUS_CODE} from '@sourceloop/core';
8-
8+
import {authorize} from 'loopback4-authorization';
99
/**
1010
* OpenAPI response for ping()
1111
*/
@@ -43,6 +43,7 @@ export class PingController {
4343
) {}
4444

4545
// Map to `GET /ping`
46+
@authorize({permissions: ['*']})
4647
@get('/ping', {
4748
responses: {
4849
[STATUS_CODE.OK]: PING_RESPONSE,

sandbox/chat-notification-socketio-example/services/chat-service/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
"dotenv-extended": "^2.9.0",
6969
"loopback-connector-kv-redis": "^4.0.0",
7070
"loopback-connector-postgresql": "^7.1.1",
71+
"loopback4-authorization": "^7.0.2",
7172
"prom-client": "^14.0.1",
7273
"tslib": "^2.6.2"
7374
},

0 commit comments

Comments
 (0)