Skip to content

Instantly share code, notes, and snippets.

@ktutnik
Last active May 7, 2021 21:44
Show Gist options
  • Save ktutnik/ed38a16d1d48d9c72701e6bf29d33573 to your computer and use it in GitHub Desktop.
Save ktutnik/ed38a16d1d48d9c72701e6bf29d33573 to your computer and use it in GitHub Desktop.
@genericController()
@Entity()
export class Shop {
@PrimaryGeneratedColumn()
id: number
/** ------ other properties ------ **/
@authorize.readonly()
@Column()
createdBy:User
@preSave("post")
assignCreatedBy(@bind.user() user:JwtClaims){
// @bind.user() is the same as ctx.user
// is the JWT claims of Authorization request header
this.createdBy = { id: user.userId } as User
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment