Skip to content

Commit b7276a3

Browse files
committed
Initial commit
Signed-off-by: kvmw <mshamsi@broadcom.com>
0 parents  commit b7276a3

30 files changed

+6092
-0
lines changed

.github/workflows/greeter-ci.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: greeter-ci
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
paths: ["greeter/**"]
7+
pull_request:
8+
branches: ["main"]
9+
paths: ["greeter/**"]
10+
11+
jobs:
12+
check:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: "20"
23+
cache: "npm"
24+
cache-dependency-path: "greeter/package-lock.json"
25+
26+
- name: Install dependencies
27+
working-directory: ./greeter
28+
run: npm ci
29+
30+
- name: Check Lint
31+
working-directory: ./greeter
32+
run: npm run check
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: greeter-messages-ci
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
paths: ["greeter-messages/**"]
7+
pull_request:
8+
branches: ["main"]
9+
paths: ["greeter-messages/**"]
10+
11+
jobs:
12+
check:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: "20"
23+
cache: "npm"
24+
cache-dependency-path: "greeter-messages/package-lock.json"
25+
26+
- name: Install dependencies
27+
working-directory: ./greeter-messages
28+
run: npm ci
29+
30+
- name: Check Lint
31+
working-directory: ./greeter-messages
32+
run: npm run check

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Dependency directories
2+
node_modules/
3+
4+
# dotenv environment variable files
5+
.env
6+
.env.*
7+
!.env.development

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Service Registry nodejs sample
2+
3+
![Greeter CI](https://github.com/spring-cloud-services-samples/greeting-nodejs/actions/workflows/greeter-ci.yml/badge.svg)
4+
![Greeter Messages CI](https://github.com/spring-cloud-services-samples/greeting-nodejs/actions/workflows/greeter-messages-ci.yml/badge.svg)
5+
6+
Sample nodejs application demonstrating the use of Service Registry in Tanzu Platform for Cloud Foundry.
7+
8+
For information on the Service Registry product in Tanzu Platform for Cloud Foundry, please [see the documentation](https://techdocs.broadcom.com/us/en/vmware-tanzu/spring/spring-cloud-services-for-cloud-foundry/3-3/scs-tanzu/service-registry-index.html).
9+
10+
## Building and Deploying
11+
12+
- Create a Service Registry instance:
13+
14+
```
15+
cf create-service p.service-registry standard greeter-service-registry
16+
```
17+
18+
- Push the `greeter-messages` application:
19+
20+
```
21+
cd greeter-messages && npm install && cf push
22+
```
23+
24+
- Push the `greeter` application:
25+
26+
```
27+
cd greeter && npm install && cf push
28+
```
29+
30+
## Trying It Out
31+
32+
Call `[ROUTE]/hello`, where `[ROUTE]` is the route bound to the `greeter` application, with optional `name` and `salutation` parameters.
33+
34+
```
35+
$ curl -k greeter.apps.example.cf-app.com/hello?name=John
36+
Hello, John!
37+
```

greeter-messages/.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
dist/

greeter-messages/.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"semi": true,
3+
"tabWidth": 2,
4+
"singleQuote": true,
5+
"trailingComma": "all",
6+
"printWidth": 80
7+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PORT=8080
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import path from 'path';
2+
import { config } from 'dotenv';
3+
import { fileURLToPath } from 'url';
4+
5+
// Get __dirname equivalent in ESM
6+
const __filename = fileURLToPath(import.meta.url);
7+
const __dirname = path.dirname(__filename);
8+
9+
// Load environment variables from .env file based on NODE_ENV
10+
config({
11+
path: path.resolve(
12+
__dirname,
13+
`.env.${process.env.NODE_ENV || 'development'}`,
14+
),
15+
});
16+
17+
export default {
18+
port: process.env.PORT,
19+
};

greeter-messages/eslint.config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { defineConfig, globalIgnores } from 'eslint/config';
2+
import globals from 'globals';
3+
import js from '@eslint/js';
4+
import prettier from 'eslint-plugin-prettier/recommended';
5+
6+
export default defineConfig([
7+
prettier,
8+
{ files: ['**/*.js'], languageOptions: { globals: globals.node } },
9+
{ files: ['**/*.js'], plugins: { js }, extends: ['js/recommended'] },
10+
globalIgnores(['node_modules/', 'dist/']),
11+
]);

greeter-messages/manifest.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
applications:
2+
- name: greeter-messages
3+
random-route: true
4+
memory: 64M
5+
buildpack: nodejs_buildpack
6+
services:
7+
- greeter-service-registry
8+
env:
9+
NODE_ENV: development

0 commit comments

Comments
 (0)