2.7.11 • Published 2 months ago

@mingsterism/trpc-process v2.7.11

Weekly downloads
-
License
-
Repository
-
Last release
2 months ago

@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

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

To run jest test

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

  1. npm login
  2. delete dist folder
  3. increase package version in package.json
  4. npm i
  5. git push
  6. npm publish

Recommended local ports for trpc services

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)

  1. 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)
    }
})
  1. cd ./grafana_loki
  2. docker-compose pull
  3. docker-compose up
  4. go to http://localhost:3200 (view logs here)
  5. npm run dev
  6. 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