2.7.11 • Published 2 months ago
@mingsterism/trpc-process v2.7.11
@mingsterism/trpc-process
new
process trpc service to manage api and events
required
- create .env file with variables:
NPM_TOKEN=<npm-token>
PORT=<port>
APP_ENV=<environment> (local / development / production)
APP_BASE_URL=<app-base-url>
NATS_URL=<nats-url>
REDIS_HOST=<redis-host>
REDIS_PORT=<redis-port>
REDIS_USERNAME=<redis-username>
REDIS_PASSWORD=<redis-password>
DATABASE_URL=<database-url>
SUPABASE_JWT_SECRET=<supabase-jwt-secret>
GOOGLE_CLIENT_ID=<google-client-id>
GOOGLE_CLIENT_SECRET=<google-client-secret>
GOOGLE_DRIVE_CALLBACK_URL=<google-drive-callback-url>
GOOGLE_DRIVE_ROOT_FOLDER_NAME=<google-drive-root-folder-name>
GMAIL_CALLBACK_URL=<gmail-callback-url>
ACL_MICROSERVICE_URL=<acl-microservice-url>
GRAFANA_CLOUD_USER_ID=<grafana-cloud-user-id> (not required for local environment)
GRAFANA_CLOUD_API_KEY=<grafana-cloud-api-key> (not required for local environment)
TEMPORAL_URL=<temporal_url>
STRIPE_SECRET_KEY=<stripe-secret-key>
setup
# install dependencies
$ npm install
# run development app
$ npm run dev
# build production app
$ npm run build
# start production app
$ npm run start
How to run locally
1. Avianflow-npm-package
- clone and open https://github.com/theaviantech/avianflow-npm-packages.git latest branch
cd
into each subfolder under docker compose folderdocker-compose up -d
for each subfoldercd
into prisma foldernpm i
- paste
app_env
andpostgres_url
in .env in prisma npm run prisma:push
2. Trpc service repo
- comment out .npmrc
npm i
- create .env file (Variables are stated above. Follow the ports according to the services stated below to avoid issues when running all the services together locally)
- clone and run https://github.com/theaviantech/acl-backend.git latest branch first
- then,
npm run dev
to run the trpc services
To run playground.ts
- Make sure https://github.com/theaviantech/acl-backend.git latest branch is running
- Clone and run https://github.com/theaviantech/avianflow-web-auth-sveltekit.git latest branch locally
- Get the access token after login and paste it into playground.ts
npm run dev
tsx playground.ts
- See logs in terminal
To run jest test
- Make sure https://github.com/theaviantech/acl-backend.git latest branch is running
- Clone and run https://github.com/theaviantech/avianflow-web-auth-sveltekit.git latest branch locally
- Get the access token after login and update the details in test/config.ts
npm run dev
npm run test:1
(refer cmd in package.json)- See logs in terminal
Note: Make sure @mingsterism/prisma and @mingsterism/events is updated to latest version in all trpc services
How to publish trpc services updates to npm
npm login
- delete dist folder
- increase package version in package.json
npm i
git push
npm publish
Recommended local ports for trpc services
- trpc-process: http://127.0.0.1:3000
- trpc-form: http://127.0.0.1:3002
- trpc-autodoc: http://127.0.0.1:3003
- trpc-trigger: http://127.0.0.1:3004
Recommended local ports for microservices
- acl-microservice: http://localhost:3005
- custom-tables-miscroservice: http://localhost:3006
Note: Make sure the db container is on a different port too. Follow the instructions in the readme of the respective repos.
Running Grafana Loki locally
(Loki stores the logs coming from Winston Logger)
- change LokiTransport config in ./src/logger.ts:
new LokiTransport({
host: 'http://127.0.0.1:3100',
labels: { service: 'trpc-process' },
format: lokiFormat,
onConnectionError: (err) => {
console.error('Error connecting to Loki', err)
}
})
cd
./grafana_lokidocker-compose pull
docker-compose up
- go to http://localhost:3200 (view logs here)
npm run dev
npx tsx playground.ts
(to test the logs)
Note: We don't need the docker-compose.yaml when Loki is deployed to Grafana Cloud
Note: We are monitoring the deployed logs in our Grafana account