mirror of
https://github.com/movie-web/backend.git
synced 2025-09-13 18:13:26 +00:00
fix bugs + add a lot of endpoints
Co-authored-by: William Oldham <github@binaryoverload.co.uk>
This commit is contained in:
@@ -27,7 +27,7 @@ export class Session {
|
||||
|
||||
export interface SessionDTO {
|
||||
id: string;
|
||||
user: string;
|
||||
userId: string;
|
||||
createdAt: string;
|
||||
accessedAt: string;
|
||||
device: string;
|
||||
@@ -37,7 +37,7 @@ export interface SessionDTO {
|
||||
export function formatSession(session: Session): SessionDTO {
|
||||
return {
|
||||
id: session.id,
|
||||
user: session.id,
|
||||
userId: session.user,
|
||||
createdAt: session.createdAt.toISOString(),
|
||||
accessedAt: session.accessedAt.toISOString(),
|
||||
device: session.device,
|
||||
|
@@ -1,6 +1,12 @@
|
||||
import { Entity, PrimaryKey, Property, types } from '@mikro-orm/core';
|
||||
import { randomUUID } from 'crypto';
|
||||
|
||||
export type UserProfile = {
|
||||
colorA: string;
|
||||
colorB: string;
|
||||
icon: string;
|
||||
};
|
||||
|
||||
@Entity({ tableName: 'users' })
|
||||
export class User {
|
||||
@PrimaryKey({ name: 'id', type: 'uuid' })
|
||||
@@ -14,18 +20,36 @@ export class User {
|
||||
|
||||
@Property({ name: 'permissions', type: types.array })
|
||||
roles: string[] = [];
|
||||
|
||||
@Property({
|
||||
name: 'profile',
|
||||
type: types.json,
|
||||
})
|
||||
profile!: UserProfile;
|
||||
}
|
||||
|
||||
export interface UserDTO {
|
||||
id: string;
|
||||
name: string;
|
||||
roles: string[];
|
||||
createdAt: string;
|
||||
profile: {
|
||||
colorA: string;
|
||||
colorB: string;
|
||||
icon: string;
|
||||
};
|
||||
}
|
||||
|
||||
export function formatUser(user: User): UserDTO {
|
||||
return {
|
||||
id: user.id,
|
||||
name: user.name,
|
||||
roles: user.roles,
|
||||
createdAt: user.createdAt.toISOString(),
|
||||
profile: {
|
||||
colorA: user.profile.colorA,
|
||||
colorB: user.profile.colorB,
|
||||
icon: user.profile.icon,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user