Headless ecommerce micorservice build on top of nestjs
It has
- GraphQL modules, DB using TypeORM as seen on https://docs.nestjs.com/
- Cqrs parttern https://microservices.io/patterns/data/cqrs.html
- Keycloak authentication https://www.keycloak.org/
- GRPC https://grpc.io/docs/what-is-grpc/introduction/
- Nestcloud https://github.com/nest-cloud
Run docker compose
docker-compose up -d
Build lib
npx nest build proto-schema
Use consul docker
docker run -d --name=dev-consul -p 8500:8500 -e CONSUL_BIND_INTERFACE=eth0 consul
Use jaeger docker (tracing)
docker run -d --name jaeger \
-e COLLECTOR_ZIPKIN_HOST_PORT=:9411 \
-p 5775:5775/udp \
-p 6831:6831/udp \
-p 6832:6832/udp \
-p 5778:5778 \
-p 16686:16686 \
-p 14268:14268 \
-p 14250:14250 \
-p 9411:9411 \
jaegertracing/all-in-one:1.27
Run debug
npm nest start service-catalog
Build service
npm nest build service-catalog
Run service ( use for low memory )
node dist/apps/service-catalog/main.js
# run docker file
$ docker-compose up -d
Import seed data from seed folder
- Right click sidebar, select
Add realm
button - Click
Select file
button, choose file realm-export.json - Press
Create
- Update client secret
Chọn client GRAPHQL
- Replace new secret in env
KEYCLOAK_GRAPHQL_CLIENT_SECRET
Nestcloud grpc example
https://github.com/nest-cloud/nestcloud-grpc-example
https://github.com/pelotom/runtypes
https://gcanti.github.io/fp-ts/ecosystem
# install protoc with administrator right
$ choco install protoc
# update cmd gent-ts.sh for windows
--plugin=node_modules/ts-proto/protoc-gen-ts_proto.cmd
# using git bash
$ npm run setup:local
Export impl before handlers
- Create proto in libs/proto-schema/proto and add to service
- Create module in service folder and add to AppModule
- Create entity and repository in libs/repository
- Create module in gateway folder and add to AppModule
- Install package vscode-proto3
- Open settings.json add below option
"protoc": {
"options": ["--proto_path=libs/proto-schema/src/proto"],
"use_absolute_path": true
}