diff --git a/.gitignore b/.gitignore index d3546bc..78d4fc7 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,6 @@ /documentation # Logs -logs *.log npm-debug.log* yarn-debug.log* diff --git a/src/config/entities.config.ts b/src/config/entities.config.ts index 3240690..e40e305 100644 --- a/src/config/entities.config.ts +++ b/src/config/entities.config.ts @@ -1,5 +1,6 @@ import { SESSIONS_ENTITIES } from 'src/domain/sessions/entities' import { USERS_ENTITIES } from 'src/domain/users/entities' import { IPS_ENTITIES } from 'src/domain/ips/entities' +import { LOG_ENTITIES } from 'src/domain/logs/entities' -export const ENTITIES = [...USERS_ENTITIES, ...SESSIONS_ENTITIES, ...IPS_ENTITIES] +export const ENTITIES = [...USERS_ENTITIES, ...SESSIONS_ENTITIES, ...IPS_ENTITIES, ...LOG_ENTITIES] diff --git a/src/core/namespaces/index.ts b/src/core/namespaces/index.ts index 39657e4..77bb152 100644 --- a/src/core/namespaces/index.ts +++ b/src/core/namespaces/index.ts @@ -2,3 +2,4 @@ export * from './sessions.namespace' export * from './users.namespace' export * from './ips.namespace' export * from './sms.namespace' +export * from './logs.namespace' diff --git a/src/core/namespaces/logs.namespace.ts b/src/core/namespaces/logs.namespace.ts new file mode 100644 index 0000000..76bf5a5 --- /dev/null +++ b/src/core/namespaces/logs.namespace.ts @@ -0,0 +1,29 @@ +export namespace Logs { + export enum Type { + Black = 'b', + White = 'w', + } + + export interface ILog { + /** Унікальний ідентифікатор */ + id?: number + + /** IP адреса */ + ip?: string + + /** Ідентифіктор користувача */ + userId?: number + + /** Дата створення */ + createdAt?: string + + /** Дата останньої зміни */ + updatedAt?: string + + /** Опис */ + description?: string + + /** Тип */ + type?: Type + } +} diff --git a/src/domain/logs/entities/index.ts b/src/domain/logs/entities/index.ts new file mode 100644 index 0000000..225ed15 --- /dev/null +++ b/src/domain/logs/entities/index.ts @@ -0,0 +1,5 @@ +import { Log } from './log.entity' + +export const LOG_ENTITIES = [Log] + +export { Log } diff --git a/src/domain/logs/entities/log.entity.ts b/src/domain/logs/entities/log.entity.ts new file mode 100644 index 0000000..7c9d11d --- /dev/null +++ b/src/domain/logs/entities/log.entity.ts @@ -0,0 +1,26 @@ +import { Logs } from 'src/core' +import { Column, CreateDateColumn, Entity, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm' + +@Entity('logs') +export class Log implements Logs.ILog { + @PrimaryGeneratedColumn() + id: number + + @Column({ nullable: true }) + userId?: number + + @Column({ nullable: true }) + ip?: string + + @CreateDateColumn({ type: 'timestamp', default: () => 'LOCALTIMESTAMP' }) + createdAt: string + + @UpdateDateColumn({ type: 'timestamp', default: () => 'LOCALTIMESTAMP' }) + updatedAt: string + + @Column({ type: 'char', nullable: true }) + type?: Logs.Type + + @Column({ nullable: true }) + description?: string +}