Skip to content

Commit

Permalink
feat(sandbox): example for feature toggle service (sourcefuse#398)
Browse files Browse the repository at this point in the history
* feat(sandbox): example for feature toggle service

MIGRATION CHANGE:
migration-20211019091305- example for feature toggle service
migration-20210913104858- example for feature toggle service

sourcefusegh-396

* feat(sandbox): example for feature toggle service

MIGRATION CHANGE:
migration-20211019091305- example for feature toggle service

sourcefusegh-396

* feat(sandbox): feature toggle example

sourcefusegh-396

* feat(sandbox): feature toggle example

sourcefusegh-396

* feat(sandbox): feature toggle service

sourcefusegh-396

* feat(sandbox): rebasing

sourcefusegh-396
  • Loading branch information
yeshamavani authored Dec 10, 2021
1 parent 4735004 commit 9410472
Show file tree
Hide file tree
Showing 64 changed files with 17,274 additions and 1,532 deletions.
3 changes: 2 additions & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"@sourceloop/workflow-ms-example",
"@sourceloop/pubnub-example",
"@sourceloop/search-ms-example",
"@sourceloop/search-client-example"
"@sourceloop/search-client-example",
"@sourceloop/feature-toggle-example"
]
},
"clean": {
Expand Down
1 change: 1 addition & 0 deletions sandbox/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ docker push ${REGISTRY}/video-conferencing-ms-example
docker push ${REGISTRY}/in-mail-example
docket push ${REGISTRY}/search-ms-example
docker push ${REGISTRY}/chat-notification-pubnub-example
docker push ${REGISTRY}/feature-toggle-example
4 changes: 4 additions & 0 deletions sandbox/ci_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ local_docker_push() {
docker push ${LOCAL_REGISTRY}/in-mail-example
docker push ${LOCAL_REGISTRY}/search-ms-example
docker push ${LOCAL_REGISTRY}/chat-notification-pubnub-example
docker push ${LOCAL_REGISTRY}/feature-toggle-example

}

docker_push() {
Expand All @@ -46,6 +48,7 @@ docker_push() {
docker tag ${LOCAL_REGISTRY}/in-mail-example ${DOCKER_USERNAME}/in-mail-example
docker tag ${LOCAL_REGISTRY}/search-ms-example ${DOCKER_USERNAME}/search-ms-example
docker tag ${LOCAL_REGISTRY}/chat-notification-pubnub-example ${DOCKER_USERNAME}/chat-notification-pubnub-example
docker push ${LOCAL_REGISTRY}/feature-toggle-example ${DOCKER_USERNAME}/feature-toggle-example

docker push ${DOCKER_USERNAME}/auth-multitenant-example
docker push ${DOCKER_USERNAME}/notification-socket-example
Expand All @@ -56,6 +59,7 @@ docker_push() {
docker push ${DOCKER_USERNAME}/in-mail-example
docker push ${DOCKER_USERNAME}/search-ms-example
docker push ${DOCKER_USERNAME}/chat-notification-pubnub-example
docker push ${DOCKER_USERNAME}/feature-toggle-example

# TODO: should we clean up after build? Since agent is ephemeral, some caching may be helpful after an initial run
# TODO: remove specific images and cache
Expand Down
47 changes: 47 additions & 0 deletions sandbox/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,22 @@ x-pubnub-variables: &pubnub-variables
JWT_SECRET: i_am_a_strong_secret
JWT_ISSUER: https://loopback4-microservice-catalog

x-feature-toggle-variables: &feature-toggle-variables
NODE_ENV: dev
LOG_LEVEL: debug
DB_HOST: postgres
DB_PORT: 5432
DB_USER: ${POSTGRES_USER:-postgres}
DB_PASSWORD: ${POSTGRES_PASSWORD:-changeme}
DB_DATABASE: feature-toggle_db
REDIS_HOST: redis
REDIS_PORT: 6379
REDIS_URL:
REDIS_PASSWORD:
REDIS_DB: 0
JWT_SECRET: i_am_a_strong_secret
JWT_ISSUER: https://loopback4-microservice-catalog

x-scheduler-variables: &scheduler-variables
NODE_ENV: dev
LOG_LEVEL: debug
Expand Down Expand Up @@ -451,6 +467,36 @@ services:
- sandbox
restart: on-failure

feature-toggle-example:
image: ${REGISTRY:-localhost:32000}/feature-toggle-example
build:
context: ./feature-toggle-example
dockerfile: Dockerfile
ports:
- '3039:3000'
networks:
- sandbox
environment: *feature-toggle-variables
depends_on:
- postgres
- postgres_orchestrator
- feature-toggle-migration
restart: on-failure

feature-toggle-migration:
image: ${REGISTRY:-localhost:32000}/feature-toggle:latest
command: sh -c "sleep 60 && npm run db:migrate"
build:
context: ./feature-toggle-example
dockerfile: Dockerfile
environment: *feature-toggle-variables
depends_on:
- postgres
- postgres_orchestrator
networks:
- sandbox
restart: on-failure

scheduler-example:
image: ${REGISTRY:-localhost:32000}/scheduler-example
build:
Expand Down Expand Up @@ -562,6 +608,7 @@ services:
psql -U ${POSTGRES_USER:-postgres} -d postgres -h postgres -c 'create database workflow_db' &&
psql -U ${POSTGRES_USER:-postgres} -d postgres -h postgres -c 'create database audit_db' &&
psql -U ${POSTGRES_USER:-postgres} -d postgres -h postgres -c 'create database pubnub_db' &&
psql -U ${POSTGRES_USER:-postgres} -d postgres -h postgres -c 'create database feature-toggle_db' &&
psql -U ${POSTGRES_USER:-postgres} -d postgres -h postgres -c 'create database scheduler_db' &&
psql -U ${POSTGRES_USER:-postgres} -d postgres -h postgres -c 'create database in_mail_db'&&
psql -U ${POSTGRES_USER:-postgres} -d postgres -h postgres -c 'create database search_db'&&
Expand Down
5 changes: 5 additions & 0 deletions sandbox/feature-toggle-example/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
npm-debug.log
/dist
# Cache used by TypeScript's incremental build
*.tsbuildinfo
16 changes: 16 additions & 0 deletions sandbox/feature-toggle-example/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
DB_HOST=
PORT=
DB_PORT=
DB_USER=
DB_PASSWORD=
DB_DATABASE=
REDIS_HOST=
REDIS_PORT=
REDIS_PASSWORD=
REDIS_DB=
JWT_SECRET=
JWT_ISSUER=
UNLEASH_URL=
APP_NAME=
APP_ENV=
UNLEASH_AUTH=
6 changes: 6 additions & 0 deletions sandbox/feature-toggle-example/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules/
dist/
coverage/
migrations/
migration.js
.eslintrc.js
3 changes: 3 additions & 0 deletions sandbox/feature-toggle-example/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: '@loopback/eslint-config',
};
64 changes: 64 additions & 0 deletions sandbox/feature-toggle-example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# Transpiled JavaScript files from Typescript
/dist

# Cache used by TypeScript's incremental build
*.tsbuildinfo
5 changes: 5 additions & 0 deletions sandbox/feature-toggle-example/.mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"exit": true,
"recursive": true,
"require": "source-map-support/register"
}
2 changes: 2 additions & 0 deletions sandbox/feature-toggle-example/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package-lock=true
scripts-prepend-node-path=true
2 changes: 2 additions & 0 deletions sandbox/feature-toggle-example/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
*.json
7 changes: 7 additions & 0 deletions sandbox/feature-toggle-example/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"bracketSpacing": false,
"singleQuote": true,
"printWidth": 80,
"trailingComma": "all",
"arrowParens": "avoid"
}
38 changes: 38 additions & 0 deletions sandbox/feature-toggle-example/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/dist/index.js",
},
{
"type": "node",
"request": "launch",
"name": "Run Mocha tests",
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
"runtimeArgs": [
"-r",
"${workspaceRoot}/node_modules/source-map-support/register"
],
"cwd": "${workspaceRoot}",
"autoAttachChildProcesses": true,
"args": [
"--config",
"${workspaceRoot}/.mocharc.json",
"${workspaceRoot}/dist/__tests__/**/*.js",
"-t",
"0"
]
},
{
"type": "node",
"request": "attach",
"name": "Attach to Process",
"port": 5858
}
]
}
32 changes: 32 additions & 0 deletions sandbox/feature-toggle-example/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"editor.rulers": [80],
"editor.tabCompletion": "on",
"editor.tabSize": 2,
"editor.trimAutoWhitespace": true,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true,
"source.fixAll.eslint": true
},

"files.exclude": {
"**/.DS_Store": true,
"**/.git": true,
"**/.hg": true,
"**/.svn": true,
"**/CVS": true,
"dist": true,
},
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true,

"typescript.tsdk": "./node_modules/typescript/lib",
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false,
"typescript.preferences.quoteStyle": "single",
"eslint.run": "onSave",
"eslint.nodePath": "./node_modules",
"eslint.validate": [
"javascript",
"typescript"
]
}
29 changes: 29 additions & 0 deletions sandbox/feature-toggle-example/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Watch and Compile Project",
"type": "shell",
"command": "npm",
"args": ["--silent", "run", "build:watch"],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": "$tsc-watch"
},
{
"label": "Build, Test and Lint",
"type": "shell",
"command": "npm",
"args": ["--silent", "run", "test:dev"],
"group": {
"kind": "test",
"isDefault": true
},
"problemMatcher": ["$tsc", "$eslint-compact", "$eslint-stylish"]
}
]
}
6 changes: 6 additions & 0 deletions sandbox/feature-toggle-example/.yo-rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"@loopback/cli": {
"packageManager": "npm",
"version": "2.21.1"
}
}
36 changes: 36 additions & 0 deletions sandbox/feature-toggle-example/DEVELOPING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Developer's Guide

We use Visual Studio Code for developing LoopBack and recommend the same to our
users.

## VSCode setup

Install the following extensions:

- [eslint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
- [prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)

## Development workflow

### Visual Studio Code

1. Start the build task (Cmd+Shift+B) to run TypeScript compiler in the
background, watching and recompiling files as you change them. Compilation
errors will be shown in the VSCode's "PROBLEMS" window.

2. Execute "Run Rest Task" from the Command Palette (Cmd+Shift+P) to re-run the
test suite and lint the code for both programming and style errors. Linting
errors will be shown in VSCode's "PROBLEMS" window. Failed tests are printed
to terminal output only.

### Other editors/IDEs

1. Open a new terminal window/tab and start the continuous build process via
`npm run build:watch`. It will run TypeScript compiler in watch mode,
recompiling files as you change them. Any compilation errors will be printed
to the terminal.

2. In your main terminal window/tab, run `npm run test:dev` to re-run the test
suite and lint the code for both programming and style errors. You should run
this command manually whenever you have new changes to test. Test failures
and linter errors will be printed to the terminal.
Loading

0 comments on commit 9410472

Please sign in to comment.