Skip to content

Commit

Permalink
feat(dependencies): nrwl/nx -> 6.4.0 , rebuild apps/api module with n…
Browse files Browse the repository at this point in the history
…x node-apps
  • Loading branch information
xmlking committed Oct 7, 2018
1 parent af401cc commit 4b38ff1
Show file tree
Hide file tree
Showing 14 changed files with 266 additions and 112 deletions.
2 changes: 1 addition & 1 deletion .deploy/api/prod.dockerfile
Expand Up @@ -18,7 +18,7 @@ RUN npm ci

COPY . .

RUN $(npm bin)/tsc -p ./apps/api/tsconfig.json
RUN $(npm bin)/tsc -p ./apps/api/tsconfig.app.json

EXPOSE 3000

Expand Down
30 changes: 15 additions & 15 deletions .deploy/transporter/README.md
Expand Up @@ -3,47 +3,47 @@ Transporter

This is a docker image, which includes a `Transporter` application with a predefined, parameterized pipeline definition.

The predefined pipeline migrates the current state of a MongoDB database into Elasticsearch, and then continues with syncing the changes too.
The predefined pipeline migrates the current state of a PostgreSQL database into Elasticsearch, and then continues with syncing the changes too.

+---------+ +-------------+ +---------------+
| mongodb |---->| transporter |---->| elasticsearch |
+---------+ +-------------+ +---------------+
+----------+ +-------------+ +---------------+
| postgres |---->| transporter |---->| elasticsearch |
+----------+ +-------------+ +---------------+


### Build
```bash
# build mongo-to-es transporter docker image
# build postgres-to-es transporter docker image
cd .deploy/transporter
docker build --tag=xmlking/mongo-to-es-transporter:latest .
docker build --tag=xmlking/postgres-to-es-transporter:latest .

# Tag
docker tag xmlking/mongo-to-es-transporter:latest xmlking/mongo-to-es-transporter:0.5.2
docker tag xmlking/postgres-to-es-transporter:latest xmlking/postgres-to-es-transporter:0.5.2
# Push
docker push xmlking/mongo-to-es-transporter:0.5.2
docker push xmlking/mongo-to-es-transporter:latest
docker push xmlking/postgres-to-es-transporter:0.5.2
docker push xmlking/postgres-to-es-transporter:latest
```

### Run

The configuration parameters for run:

- `DB_NAME`: The name of the database to transport from MongoDD to ES.
- `DB_NAME`: The name of the database to transport from PostgreSQL to ES.
It is also the name of the index will be created on ES. Default: `test`.
- `MONGODB_URI`: The full URI of the MongoDB server, including credentials, if there is any.
Use one of the following formats: `mongodb://<user>:password@host:port` or `mongodb://host:port`.
Default: `mongodb://localhost:27017`.
- `POSTGRES_URI`: The full URI of the PostgreSQL server, including credentials, if there is any.
Use one of the following formats: `postgres://<user>:password@host:port` or `postgres://host:port`.
Default: `postgres://localhost:5432`.
- `ELASTICSEARCH_URI`: The full URI of the Elasticsearch server, including credentials if there is any.
Use one of the following formats: `http://<user>:password@host:port` or `http://host:port`.
Default: `http://localhost:9200`.


```bash
docker run -it --rm xmlking/mongo-to-es-transporter:latest
docker run -it --rm xmlking/postgres-to-es-transporter:latest
```

### Docker Compose
```bash
docker-compose up mongodb
docker-compose up postgres
docker-compose up elasticsearch
docker-compose up kibana
docker-compose up transporter
Expand Down
10 changes: 5 additions & 5 deletions .deploy/transporter/config/pipeline.js
@@ -1,5 +1,5 @@
var source = mongodb({
"uri": "${MONGODB_URI}/${DB_NAME}?authSource=admin",
var source = postgres({
"uri": "${POSTGRES_URI}/${DB_NAME}",
// "timeout": "30s",
// "tail": false,
"tail": true,
Expand All @@ -11,14 +11,14 @@ var source = mongodb({
"bulk": true
// "collection_filters": "{}",
// "read_preference": "Primary"
})
});

var sink = elasticsearch({
"uri": "${ELASTICSEARCH_URI}/${DB_NAME}"
// "timeout": "10s", // defaults to 30s
// "aws_access_key": "ABCDEF", // used for signing requests to AWS Elasticsearch service
// "aws_access_secret": "ABCDEF" // used for signing requests to AWS Elasticsearch service
// "parent_id": "elastic_parent" // defaults to "elastic_parent" parent identifier for Elasticsearch
})
});

t.Source("source", source, "/.*/").Save("sink", sink, "/.*/")
t.Source("source", source, "/.*/").Save("sink", sink, "/.*/");
3 changes: 1 addition & 2 deletions PLAYBOOK-NEST.md
Expand Up @@ -16,8 +16,7 @@ npm install -g @nestjs/cli
### Scaffold Project
> adding code dependencies
```bash
nest new api
nest new api "my api" "0.1.0-SNAPSHOT" "Sumanth Chinthagunta <xmlking@gmail.com>" -d
nest new apps/api "my api" "0.1.0-SNAPSHOT" "Sumanth Chinthagunta <xmlking@gmail.com>" -d

npm i @nestjs/core @nestjs/common
npm i @nestjs/microservices @nestjs/websockets @nestjs/testing @nestjs/typeorm typeorm mongodb
Expand Down
18 changes: 11 additions & 7 deletions PLAYBOOK.md
Expand Up @@ -9,11 +9,11 @@ Do-it-yourself step-by-step instructions to create this project structure from s
| Software | Version | Optional |
|-------------------------------|----------|----------|
| Node | v10.7.0 | |
| Node | v10.11.0 | |
| NPM | v6.4.0 | |
| Angular CLI | v6.0.8 | |
| Angular CLI | v6.2.4 | |
| @nrwl/schematics | v6.4.0 | |
| @nestjs/cli | v5.3.0 | |
| @nestjs/cli | v5.5.0 | |

### Install Prerequisites
```bash
Expand Down Expand Up @@ -56,7 +56,7 @@ npm remove -g semantic-release-cli
npm remove -g commitizen

npm install -g @angular/cli
npm install -g @nrwl/schematics@6.4.0-beta.3
npm install -g @nrwl/schematics
npm install -g @nestjs/cli
npm install -g semantic-release-cli
npm install -g commitizen
Expand Down Expand Up @@ -95,6 +95,7 @@ cd ngx-starter-kit

# setup your workspace to run tests with jest.
ng generate jest
# Ref: https://nrwl.io/nx/unit-testing-with-jest
# you may have to manually remove karma files (karma.conf.js) and dependencies from package.json

# make sure we are up-to-date
Expand All @@ -106,6 +107,9 @@ ng update --all

# generate webapp app
ng g app webapp --routing --style=scss --prefix=ngx --unit-test-runner=jest --tags=app-module

# generate api app
ng g node-app api --framework=express --unit-test-runner=jest --tags=api-module --dry-run
```

#### Dependencies
Expand Down Expand Up @@ -201,9 +205,9 @@ ng g lib experiments --routing --lazy --prefix=ngx --parent-module=libs/dashb
ng g lib widgets --routing --lazy --prefix=ngx --parent-module=libs/dashboard/src/lib/dashboard.module.ts --unit-test-runner=jest --tags=child-module
ng g lib grid --routing --lazy --prefix=ngx --parent-module=libs/dashboard/src/lib/dashboard.module.ts --unit-test-runner=jest --tags=child-module

ng g lib animations --nomodule -tags=utils --unit-test-runner=jest --dry-run
ng g lib Tree --nomodule --publishable=true --tags=utils --unit-test-runner=jest --dry-run
ng g lib utils --nomodule --tags=utils --unit-test-runner=jest --dry-run
ng g lib animations --module false -tags=utils --unit-test-runner=jest --dry-run
ng g lib Tree --module false --publishable=true --tags=utils --unit-test-runner=jest --dry-run
ng g lib utils --module false --tags=utils --unit-test-runner=jest --dry-run

# add `core` module which will be only inported into root/app module.
ng g lib core --prefix=ngx --tags=core-module --unit-test-runner=jest --dry-run
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -9,7 +9,7 @@ This project was generated with [Angular CLI](https://github.com/angular/angular

live [Demo](https://xmlking.github.io/ngx-starter-kit/index.html)

**MANT** (*MongoDB* - *Angular* - *NestJS* - *TypeScript*) Stack
**PANT** (*PostgreSQL* - *Angular* - *NestJS* - *TypeScript*) Stack

## Install

Expand Down
63 changes: 58 additions & 5 deletions angular.json
Expand Up @@ -199,14 +199,15 @@
}
},
"webapp-e2e": {
"root": "apps/webapp-e2e/",
"root": "apps/webapp-e2e",
"sourceRoot": "apps/webapp-e2e/src",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"builder": "@nrwl/builders:jest",
"options": {
"protractorConfig": "apps/webapp-e2e/protractor.conf.js",
"devServerTarget": "webapp:serve"
"jestConfig": "",
"tsConfig": "apps/webapp-e2e/tsconfig.e2e.json"
},
"configurations": {
"production": {
Expand All @@ -229,12 +230,41 @@
"root": "apps/api",
"sourceRoot": "apps/api/src",
"projectType": "application",
"prefix": "api",
"schematics": {},
"architect": {
"build": {
"builder": "@nrwl/builders:node-build",
"options": {
"outputPath": "dist/apps/api",
"main": "apps/api/src/main.ts",
"tsConfig": "apps/api/tsconfig.app.json",
"showCircularDependencies": false
},
"configurations": {
"production": {
"optimization": true,
"extractLicenses": true,
"fileReplacements": [
{
"replace": "apps/api/src/environments/environment.ts",
"with": "apps/api/src/environments/environment.prod.ts"
}
]
}
}
},
"serve": {
"builder": "@nrwl/builders:node-execute",
"options": {
"buildTarget": "api:build"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"apps/api/tsconfig.json",
"apps/api/tsconfig.app.json",
"apps/api/tsconfig.spec.json"
],
"exclude": [
Expand All @@ -251,6 +281,29 @@
}
}
},
"api-e2e": {
"root": "apps/api-e2e",
"sourceRoot": "apps/api-e2e/src",
"projectType": "application",
"architect": {
"test": {
"builder": "@nrwl/builders:jest",
"options": {
"jestConfig": "apps/api-e2e/jest.config.js",
"tsConfig": "apps/api-e2e/tsconfig.e2e.json"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": "apps/api-e2e/tsconfig.e2e.json",
"exclude": [
"**/node_modules/**"
]
}
}
}
},
"navigator": {
"root": "libs/navigator",
"sourceRoot": "libs/navigator/src",
Expand Down
6 changes: 3 additions & 3 deletions development.env
Expand Up @@ -9,11 +9,11 @@ ALLOW_WHITE_LIST=::ffff:127.0.0.1,::1
LOG_LEVEL=debug

# DB Connection
TYPEORM_CONNECTION=mongodb
TYPEORM_CONNECTION=postgres
TYPEORM_HOST=localhost
TYPEORM_PORT=27017
TYPEORM_PORT=5432
TYPEORM_DATABASE=cockpit
TYPEORM_USERNAME=mdbuser
TYPEORM_USERNAME=cockpit
TYPEORM_PASSWORD=cockpit123

# ORM Config
Expand Down

0 comments on commit 4b38ff1

Please sign in to comment.