#Microservice or not in this use case
25 messages · Page 1 of 1 (latest)
"micro-service" designates standalone code that lives outside of your app
Here if the question is "should I merge user and alarm services" the answer is "most likely absolutely not"
just have an agnostic alarm service that take users (or a subset of it, or something that looks like it) as an arg of needed methods
coupling both you will most likely regret it hard later
any example of database attributes of it?
You should post some code for more help
Note that it's ok to call say the UserModel (or UserService) from the AlarmService
Alert.entity is:
import {
Column,
CreateDateColumn,
Entity,
ManyToOne,
UpdateDateColumn
} from 'typeorm'
import { Customer } from '@rest-api/customers/entities/customer.entity'
import { AbstractEntity } from '@app/common';
@Entity()
export class Alert extends AbstractEntity<Alert>{
@ApiProperty()
@Column({ default: 0, type: 'integer' })
severity: number
@Column({ length: 100 })
description: string
@CreateDateColumn()
createdAt: number
@UpdateDateColumn()
updatedAt: number
@Column()
customerId: string
@ManyToOne(() => Customer, (customer) => customer.alerts)
customer: Customer
}
Customer is related with another entity in other sub-app. My solution has been remove alarm sub-app, thinking maybe is a little overengineering for this use case
what does "sub-app" mean ?
sub-app is terminology of nest workspaces https://docs.nestjs.com/cli/monorepo
Nest is a framework for building efficient, scalable Node.js server-side applications. It uses progressive JavaScript, is built with TypeScript and combines elements of OOP (Object Oriented Programming), FP (Functional Programming), and FRP (Functional Reactive Programming).
does it refer to the same data in the same db ?
in one app I have customers and in other app alerts for those customers
yes but do these apps share the same db ?
yes
and the problem is the entity relationship cannot be made for some reason ?
it was a problem typeorm was not finding the relationship
was or is ?
now is working because it is not a "microservice", at the beginning of the day was a "microservice"
probably the Customer model wasn't loaded in your alert typeorm instance
did you get an error message ?
I will try to return to my init idea... but I think is not necessary...
nop.. but I will try to reproduce that behavior..
usually the boring solution is the good one
thank u @echo flax