add 127.0.0.1 *.localhost
in /etc/hosts
file or hosts file of your operating system.
Note: All requirements can run native on Linux, Mac or Windows.
# use nvm for better control and secure node environments for users.
# DO NOT USE sudo or root privileges
npm i lerna @angular/cli @nestjs/cli -g
git clone https://gitlab.com/castlecraft/building-blocks
cd building-blocks
rm -fr node_modules && yarn
rm -fr apps/**/node_modules && rm -fr frontends/**/node_modules
yarn --cwd apps/authorization-server
yarn --cwd apps/communication-server
yarn --cwd apps/identity-provider
yarn --cwd apps/infrastructure-console
yarn --cwd frontends/admin-client
yarn --cwd frontends/authorization-client
yarn --cwd frontends/identity-client
Required environment variables to start backing services in .env
file:
DB_USER=admin
DB_PASSWORD=admin
DB_NAME=test_authorization-server
MONGODB_ROOT_PASSWORD=admin
For required environment variables, place appropriate .env
files under each app's package root
.env
file.env
file.env
file.env
fileExecute following to copy example env files
cp docker/env-example/backing-services-env .env
cp docker/env-example/authorization-server-env apps/authorization-server/.env
cp docker/env-example/communication-server-env apps/communication-server/.env
cp docker/env-example/identity-provider-env apps/identity-provider/.env
cp docker/env-example/infrastructure-console-env apps/infrastructure-console/.env
docker-compose \
--project-name bb \
-f docker/docker-compose-mongo.yml \
-f docker/docker-compose-events.yml \
up -d
Wait for mongodb to start
docker logs bb_mongo_1 --follow
Execute following command to set users and dbs
docker exec -it bb_mongo_1 /docker-entrypoint-initdb.d/createdatabases.sh
Start Development backend and frontend using following commands
# for packages in apps/ directory,
# execute following command from the app package root
yarn start:debug
# for packages in frontends/ directory,
# execute following command from the frontend package root
yarn start
or use VS Code Setup, refer example
Execute to initialize administrator user and core trusted clients
Note:
./scripts/setup-wizard --help
./scripts/setup-wizard
# Output
Setting Up Authorization Server and Infrastructure Console
Creating Clients
Setup Identity Provider
Setup Communication Server
Update auth server settings for Example Inc.
Visit Admin URL http://admin.localhost:4220
Login using email 'admin@example.com' or phone '+919876543210'
Use the password configured during setup wizard, default password Secret@1234
Urls:
Authorization Server http://accounts.localhost:4210
Communication Server http://connect.localhost:4100
Identity Provider http://myaccount.localhost:4420
All apps dependencies and services are up for debug and development.
# NestJS unit tests
lerna run test:server
# Drop databases for auth-server e2e
mongo admin -u root -p admin --authenticationDatabase admin
> use test_authorization-server
> db.dropDatabase()
> exit
# Or use command to drop test database
echo -e "use test_authorization-server;\n db.dropDatabase()" | mongo -u root -p admin --authenticationDatabase admin
# NestJS e2e/integration
lerna run test:e2e
# Angular unit tests
export NODE_ENV=test
lerna run test
# Angular e2e
lerna --concurrency 1 run e2e
# Check format
lerna run format:check
# Check Linting
lerna run lint
# To execute from project root
lerna run format && lerna run lint -- --fix
# OR execute from app or frontend package root
yarn format && yarn lint -- --fix