Skip to content

Commit 54656e6

Browse files
sardounisdaniasTraigorgiorgosnty
authored
Todo ts target (#413)
* Added nestjs code for the backend * Added envoy and the frontend in docker-compose.yml * Added dockerfile for backend service * Renamed Grafana variables * Added missing generated files * fixed typo * Added config to Dockerfile * added gitignore files * Added missing ENV * Added network to mongo1 * added general theory on event storming * added tracing to docker compose * Removed telemetry-consumer port * Added missing modify title handler * fixed a console log * fixed tarcing urls * updated telemetry readme * added links * fixed modify title * removed ports from consumer * Changed Grafana port to 3000 * added documentation for the event storming part * moved the module structure * Changed the numbering of the chapters - removed duplicates * did some structural changes as as well as some minor content changes * added technical features * added tracable to command and event handlers * Added autologin after registration * Fixed duplicates issue * added Jaeger pic and minor fixes * added traceable to command and event handlers * added traceable --------- Co-authored-by: Vasilis Danias <vasilis@bitloops.com> Co-authored-by: Spiros Grigoratos <spgrigoratos@gmail.com> Co-authored-by: giorgosnty <g.ntymenos@gmail.com>
1 parent 47f7b29 commit 54656e6

File tree

285 files changed

+25320
-5244
lines changed

Some content is hidden

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

285 files changed

+25320
-5244
lines changed

.development.env

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# copy and rename this to .development.env to add your configurations
2+
JWT_SECRET=p2s5v8x/A?D(G+KbPeShVmYq3t6w9z$B # !!! replace this with your own secret
3+
JWT_LIFETIME_SECONDS=3600
4+
HTTP_IP=localhost
5+
GRPC_IP=localhost
6+
IAM_DATABASE_HOST=localhost
7+
TODO_DATABASE_HOST=localhost
8+
PG_HOST=localhost
9+
PG_IAM_HOST=localhost
10+
MONGO_HOST=localhost
11+
MARKETING_DATABASE_HOST=localhost
12+
NATS_HOST=localhost

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,6 @@ dist
102102

103103
# TernJS port file
104104
.tern-port
105-
lib/
105+
/lib
106106
documentation/package-lock.json
107+
examples/todo/ts-target/telemetry-consumer/Dockerfile

boilerplate/ts/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lib

examples/README.md

Lines changed: 177 additions & 36 deletions
Large diffs are not rendered by default.

examples/banking/ts-target/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
deploy

examples/todo/frontend/src/App.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ function App(props: {service: TodoServiceClient}): JSX.Element {
5959
if (password.length < 8) return setErrorMessage('Password must be at least 8 characters long!');
6060
try {
6161
await axios.post(REGISTRATION_URL, { email, password });
62+
loginWithEmailPassword(email, password);
6263
} catch (error: any) {
6364
setErrorMessage(error?.response?.data?.message);
6465
}
@@ -138,10 +139,12 @@ function App(props: {service: TodoServiceClient}): JSX.Element {
138139

139140
useEffect(() => {
140141
if (event) {
142+
console.log('event', event);
141143
const { eventName, payload } = event;
142144
if (payload) switch (eventName) {
143145
case 'onadded':
144-
setTodos([...todos, payload]);
146+
todos.filter((todo) => todo.id === payload.id).length === 0 &&
147+
setTodos([...todos, payload]);
145148
break;
146149
case 'ondeleted':
147150
const remainingTodos = todos.filter((todo) => todo.id !== payload.id);

examples/todo/ts-target/.eslintignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

examples/todo/ts-target/.eslintrc

Lines changed: 0 additions & 19 deletions
This file was deleted.

examples/todo/ts-target/.eslintrc.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser',
3+
parserOptions: {
4+
project: 'tsconfig.json',
5+
tsconfigRootDir: __dirname,
6+
sourceType: 'module',
7+
},
8+
plugins: ['@typescript-eslint/eslint-plugin'],
9+
extends: [
10+
'plugin:@typescript-eslint/recommended',
11+
'plugin:prettier/recommended',
12+
],
13+
root: true,
14+
env: {
15+
node: true,
16+
jest: true,
17+
},
18+
ignorePatterns: ['.eslintrc.js', '**/generated/*.*'],
19+
rules: {
20+
'@typescript-eslint/interface-name-prefix': 'off',
21+
'@typescript-eslint/explicit-function-return-type': 'off',
22+
'@typescript-eslint/explicit-module-boundary-types': 'off',
23+
'@typescript-eslint/no-explicit-any': 'off',
24+
},
25+
};

examples/todo/ts-target/.gitignore

Lines changed: 29 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,110 +1,39 @@
1-
.env.dev
2-
serviceAccount.json
1+
# compiled output
2+
/dist
3+
/node_modules
34

45
# Logs
56
logs
67
*.log
78
npm-debug.log*
9+
pnpm-debug.log*
810
yarn-debug.log*
911
yarn-error.log*
1012
lerna-debug.log*
1113

12-
# Diagnostic reports (https://nodejs.org/api/report.html)
13-
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
14-
15-
# Runtime data
16-
pids
17-
*.pid
18-
*.seed
19-
*.pid.lock
20-
21-
# Directory for instrumented libs generated by jscoverage/JSCover
22-
lib-cov
23-
24-
# Coverage directory used by tools like istanbul
25-
coverage
26-
*.lcov
27-
28-
# nyc test coverage
29-
.nyc_output
30-
31-
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
32-
.grunt
33-
34-
# Bower dependency directory (https://bower.io/)
35-
bower_components
36-
37-
# node-waf configuration
38-
.lock-wscript
39-
40-
# Compiled binary addons (https://nodejs.org/api/addons.html)
41-
build/Release
42-
43-
# Dependency directories
44-
node_modules/
45-
jspm_packages/
46-
47-
# TypeScript v1 declaration files
48-
typings/
49-
50-
# TypeScript cache
51-
*.tsbuildinfo
52-
53-
# Optional npm cache directory
54-
.npm
55-
56-
# Optional eslint cache
57-
.eslintcache
58-
59-
# Microbundle cache
60-
.rpt2_cache/
61-
.rts2_cache_cjs/
62-
.rts2_cache_es/
63-
.rts2_cache_umd/
64-
65-
# Optional REPL history
66-
.node_repl_history
67-
68-
# Output of 'npm pack'
69-
*.tgz
70-
71-
# Yarn Integrity file
72-
.yarn-integrity
73-
74-
# dotenv environment variables file
75-
.env
76-
.env.test
77-
78-
# parcel-bundler cache (https://parceljs.org/)
79-
.cache
80-
81-
# Next.js build output
82-
.next
83-
84-
# Nuxt.js build / generate output
85-
.nuxt
86-
dist
87-
88-
# Gatsby files
89-
.cache/
90-
# Comment in the public line in if your project uses Gatsby and *not* Next.js
91-
# https://nextjs.org/blog/next-9-1#public-directory-support
92-
# public
93-
94-
# vuepress build output
95-
.vuepress/dist
96-
97-
# Serverless directories
98-
.serverless/
99-
100-
# FuseBox cache
101-
.fusebox/
102-
103-
# DynamoDB Local files
104-
.dynamodb/
105-
106-
# TernJS port file
107-
.tern-port
108-
109-
.vscode/
14+
# OS
11015
.DS_Store
16+
17+
# Tests
18+
/coverage
19+
/.nyc_output
20+
21+
# IDEs and editors
22+
/.idea
23+
.project
24+
.classpath
25+
.c9/
26+
*.launch
27+
.settings/
28+
*.sublime-workspace
29+
30+
# IDE - VSCode
31+
.vscode/*
32+
!.vscode/settings.json
33+
!.vscode/tasks.json
34+
!.vscode/launch.json
35+
!.vscode/extensions.json
36+
37+
data/mongo-1
38+
*.env
39+
data/*
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Ignore autogenerated files
2+
**/generated/*.*

examples/todo/ts-target/.prettierrc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{
2-
"semi": true,
3-
"trailingComma": "all",
42
"singleQuote": true,
5-
"printWidth": 100,
3+
"trailingComma": "all",
64
"tabWidth": 2
7-
}
5+
}

examples/todo/ts-target/.template-env

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# copy and rename this to .development.env to add your configurations
2+
JWT_SECRET=p2s5v8x/A?D(G+KbPeShVmYq3t6w9z$B # !!! replace this with your own secret
3+
JWT_LIFETIME_SECONDS=3600
4+
HTTP_IP=localhost
5+
GRPC_IP=localhost
6+
IAM_DATABASE_HOST=localhost
7+
TODO_DATABASE_HOST=localhost
8+
PG_HOST=localhost
9+
PG_IAM_HOST=localhost
10+
MONGO_HOST=localhost
11+
MARKETING_DATABASE_HOST=localhost
12+
NATS_HOST=localhost
13+
GRAFANA_ADMIN_USER=admin
14+
GRAFANA_ADMIN_PASSWORD=admin
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"cmake.configureOnOpen": false
3+
// "editor.formatOnSave": true,
4+
// "editor.defaultFormatter": "rvest.vs-code-prettier-eslint",
5+
}

examples/todo/ts-target/Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
FROM node:19-alpine
2+
# Set the working directory to /app inside the container
3+
WORKDIR /app
4+
# Copy app files
5+
COPY . .
6+
# BUILD
7+
# Install dependencies (--immutable makes sure the exact versions in the lockfile gets installed)
8+
RUN yarn install --immutable
9+
# Build the app
10+
RUN yarn build
11+
# RUN
12+
# Set the env to "production"
13+
ENV JWT_SECRET "p2s5v8x/A?D(G+KbPeShVmYq3t6w9z$B"
14+
ENV JWT_LIFETIME_SECONDS 3600
15+
ENV HTTP_IP backend
16+
ENV GRPC_IP backend
17+
ENV IAM_DATABASE_HOST backend
18+
ENV TODO_DATABASE_HOST mongo1
19+
ENV PG_IAM_HOST postgres
20+
ENV PG_HOST postgres
21+
ENV MONGO_HOST mongo1
22+
ENV MARKETING_DATABASE_HOST mongo1
23+
ENV NATS_HOST nats
24+
ENV GRAFANA_ADMIN_USER admin
25+
ENV GRAFANA_ADMIN_PASSWORD admin
26+
ENV NODE_ENV production
27+
ENV AUTH_URL "http://backend:8082/auth/login"
28+
ENV PROXY_URL "http://backend:8080"
29+
ENV REGISTRATION_URL "http://backend:8082/auth/register"
30+
# Expose the port on which the app will be running (3000 is the default that `serve` uses)
31+
EXPOSE 8081 8082
32+
# Start the app
33+
CMD [ "yarn", "start:prod" ]

examples/todo/ts-target/README.md

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,36 @@
1-
# Bitloops Language TypeScript Template
1+
# Todo App using nest.js and the Bitloops Language
22

3-
Bitloops Language Boilerplate code for TypeScript
3+
## Required software
44

5-
v0.0.6
5+
npm install -g grpc-tools grpc_tools_node_protoc_ts
6+
7+
## To generate the gRPC classes
8+
9+
!!! Note that there is a conflict with protoc and newer TypeScript versions. For now, v4.3.4 can be used without an issue but v4.7.4 breaks things.
10+
11+
https://github.com/thesayyn/protoc-gen-ts/issues/170
12+
https://github.com/microsoft/TypeScript/issues/50259
13+
14+
<!-- grpc_tools_node_protoc \
15+
--js_out=import_style=commonjs,binary:./src/proto \
16+
--grpc_out=grpc_js:./src/proto \
17+
--plugin=protoc-gen-grpc=`which grpc_tools_node_protoc_plugin` \
18+
-I ./src/proto \
19+
./src/proto/todo.proto
20+
21+
protoc \
22+
--plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts \
23+
--ts_out=grpc_js:./src/proto \
24+
-I ./src/proto \
25+
./src/proto/*.proto
26+
27+
./node_modules/.bin/grpc_tools_node_protoc \
28+
--plugin=protoc-gen-grpc=./node_modules/.bin/grpc_tools_node_protoc_plugin \
29+
--plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts \
30+
--js_out=import_style=commonjs,binary:./src/proto \
31+
--ts_out=grpc_js:./src/proto \
32+
--grpc_out=grpc_js:./src/proto \
33+
--proto_path=./src/proto \
34+
./src/proto/todo.proto -->
35+
36+
./node_modules/.bin/grpc_tools_node_protoc --plugin=protoc-gen-grpc=./node_modules/.bin/grpc_tools_node_protoc_plugin --plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts --js_out=import_style=commonjs,binary:./src/proto --ts_out=grpc_js:./src/proto --grpc_out=grpc_js:./src/proto --proto_path=./src/proto ./src/proto/todo.proto

examples/todo/ts-target/config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
GF_SECURITY_ADMIN_USER=admin
2+
GF_SECURITY_ADMIN_PASSWORD=changeme
3+
GF_USERS_ALLOW_SIGN_UP=false

examples/todo/ts-target/config.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)