1 parent
3a04bb54bd
commit
e8727ca922
27 files changed
+145
-145
No files matched your search
+1
-1
@@ -8,5 +8,5 @@ export default {
|
||||
username: process.env.DB_USER,
|
||||
password: process.env.DB_PASSWORD,
|
||||
database: process.env.DB_NAME,
|
||||
entities: ["src/models/*.ts"]
|
||||
entities: ["src/models/entities/*.ts"]
|
||||
};
|
||||
@@ -2,9 +2,9 @@ import { JsonController, Param, Body, Get, Post, Put, Delete, OnUndefined } from
|
||||
import { getConnectionManager, Repository } from 'typeorm';
|
||||
import { EntityFromBody } from 'typeorm-routing-controllers-extensions';
|
||||
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
|
||||
import { Runner } from '../models/Runner';
|
||||
import { Runner } from '../models/entities/Runner';
|
||||
import { RunnerGroupNeededError, RunnerGroupNotFoundError, RunnerIdsNotMatchingError, RunnerNotFoundError, RunnerOnlyOneGroupAllowedError } from '../errors/RunnerErrors';
|
||||
import { CreateRunner } from '../models/CreateRunner';
|
||||
import { CreateRunner } from '../models/creation/CreateRunner';
|
||||
|
||||
|
||||
@JsonController('/runners')
|
||||
|
||||
@@ -2,10 +2,10 @@ import { JsonController, Param, Body, Get, Post, Put, Delete, OnUndefined } from
|
||||
import { getConnectionManager, Repository } from 'typeorm';
|
||||
import { EntityFromBody } from 'typeorm-routing-controllers-extensions';
|
||||
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
|
||||
import { RunnerOrganisation } from '../models/RunnerOrganisation';
|
||||
import { RunnerOrganisation } from '../models/entities/RunnerOrganisation';
|
||||
import { RunnerOrganisationIdsNotMatchingError, RunnerOrganisationNotFoundError } from '../errors/RunnerOrganisationErrors';
|
||||
import { CreateRunnerOrganisation } from '../models/CreateRunnerOrganisation';
|
||||
import { RunnerGroup } from '../models/RunnerGroup';
|
||||
import { CreateRunnerOrganisation } from '../models/creation/CreateRunnerOrganisation';
|
||||
import { RunnerGroup } from '../models/entities/RunnerGroup';
|
||||
|
||||
|
||||
@JsonController('/organisations')
|
||||
|
||||
@@ -2,10 +2,10 @@ import { JsonController, Param, Body, Get, Post, Put, Delete, NotFoundError, OnU
|
||||
import { getConnectionManager, Repository } from 'typeorm';
|
||||
import { EntityFromBody } from 'typeorm-routing-controllers-extensions';
|
||||
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
|
||||
import { Track } from '../models/Track';
|
||||
import { Track } from '../models/entities/Track';
|
||||
import { IsInt, IsNotEmpty, IsPositive, IsString } from 'class-validator';
|
||||
import { TrackIdsNotMatchingError, TrackNotFoundError } from "../errors/TrackErrors";
|
||||
import { CreateTrack } from '../models/CreateTrack';
|
||||
import { CreateTrack } from '../models/creation/CreateTrack';
|
||||
|
||||
@JsonController('/tracks')
|
||||
//@Authorized("TRACKS:read")
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { IsEmail, IsInt, IsNotEmpty, IsOptional, IsPhoneNumber, IsPositive, IsString } from 'class-validator';
|
||||
import { Runner } from '../models/Runner';
|
||||
import { Runner } from '../entities/Runner';
|
||||
import { getConnectionManager, Repository } from 'typeorm';
|
||||
import { group } from 'console';
|
||||
import { RunnerOnlyOneGroupAllowedError, RunnerGroupNeededError, RunnerGroupNotFoundError } from '../errors/RunnerErrors';
|
||||
import { RunnerOrganisation } from './RunnerOrganisation';
|
||||
import { RunnerTeam } from './RunnerTeam';
|
||||
import { RunnerGroup } from './RunnerGroup';
|
||||
import { RunnerOnlyOneGroupAllowedError, RunnerGroupNeededError, RunnerGroupNotFoundError } from '../../errors/RunnerErrors';
|
||||
import { RunnerOrganisation } from '../entities/RunnerOrganisation';
|
||||
import { RunnerTeam } from '../entities/RunnerTeam';
|
||||
import { RunnerGroup } from '../entities/RunnerGroup';
|
||||
import { Address } from 'cluster';
|
||||
|
||||
export class CreateRunner {
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import { IsString } from 'class-validator';
|
||||
import { RunnerOrganisation } from './RunnerOrganisation';
|
||||
import { RunnerOrganisation } from '../entities/RunnerOrganisation';
|
||||
|
||||
export class CreateRunnerOrganisation {
|
||||
@IsString()
|
||||
@@ -1,5 +1,5 @@
|
||||
import { IsInt, IsNotEmpty, IsPositive, IsString } from 'class-validator';
|
||||
import { Track } from './Track';
|
||||
import { Track } from '../entities/Track';
|
||||
|
||||
export class CreateTrack {
|
||||
/**
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,130 +1,130 @@
|
||||
import { Entity, Column, OneToMany, ManyToOne, PrimaryGeneratedColumn, Generated, Unique, JoinTable, ManyToMany } from "typeorm";
|
||||
import { IsBoolean, IsEmail, IsInt, IsNotEmpty, IsOptional, IsPhoneNumber, IsString, isUUID, } from "class-validator";
|
||||
import { UserGroup } from './UserGroup';
|
||||
import { Permission } from './Permission';
|
||||
import { UserAction } from './UserAction';
|
||||
|
||||
/**
|
||||
* Defines a admin user.
|
||||
*/
|
||||
@Entity()
|
||||
export class User {
|
||||
/**
|
||||
* autogenerated unique id (primary key).
|
||||
*/
|
||||
@PrimaryGeneratedColumn()
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
id: number;
|
||||
|
||||
/**
|
||||
* autogenerated uuid
|
||||
*/
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
@Generated("uuid")
|
||||
uuid: string;
|
||||
|
||||
/**
|
||||
* user email
|
||||
*/
|
||||
@IsEmail()
|
||||
email: string;
|
||||
|
||||
/**
|
||||
* user phone
|
||||
*/
|
||||
@IsPhoneNumber("ZZ")
|
||||
@IsOptional()
|
||||
phone: string;
|
||||
|
||||
/**
|
||||
* username
|
||||
*/
|
||||
@IsString()
|
||||
username: string;
|
||||
|
||||
/**
|
||||
* firstname
|
||||
*/
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
firstname: string;
|
||||
|
||||
/**
|
||||
* middlename
|
||||
*/
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
middlename: string;
|
||||
|
||||
/**
|
||||
* lastname
|
||||
*/
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
lastname: string;
|
||||
|
||||
/**
|
||||
* password
|
||||
*/
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
password: string;
|
||||
|
||||
/**
|
||||
* permissions
|
||||
*/
|
||||
@ManyToOne(() => Permission, permission => permission.users, { nullable: true })
|
||||
permissions: Permission[];
|
||||
|
||||
/**
|
||||
* groups
|
||||
*/
|
||||
@ManyToMany(() => UserGroup)
|
||||
@JoinTable()
|
||||
groups: UserGroup[];
|
||||
|
||||
/**
|
||||
* is user enabled?
|
||||
*/
|
||||
@IsBoolean()
|
||||
enabled: boolean;
|
||||
|
||||
/**
|
||||
* jwt refresh count
|
||||
*/
|
||||
@IsInt()
|
||||
@Column({ default: 1 })
|
||||
refreshTokenCount: number;
|
||||
|
||||
/**
|
||||
* profilepic
|
||||
*/
|
||||
@IsString()
|
||||
profilepic: string;
|
||||
|
||||
/**
|
||||
* actions
|
||||
*/
|
||||
@OneToMany(() => UserAction, action => action.user)
|
||||
actions: UserAction
|
||||
|
||||
/**
|
||||
* calculate all permissions
|
||||
*/
|
||||
public get calc_permissions(): Permission[] {
|
||||
let final_permissions = []
|
||||
this.groups.forEach((permission) => {
|
||||
if (!final_permissions.includes(permission)) {
|
||||
final_permissions.push(permission)
|
||||
}
|
||||
})
|
||||
this.permissions.forEach((permission) => {
|
||||
if (!final_permissions.includes(permission)) {
|
||||
final_permissions.push(permission)
|
||||
}
|
||||
})
|
||||
return final_permissions
|
||||
}
|
||||
}
|
||||
import { Entity, Column, OneToMany, ManyToOne, PrimaryGeneratedColumn, Generated, Unique, JoinTable, ManyToMany } from "typeorm";
|
||||
import { IsBoolean, IsEmail, IsInt, IsNotEmpty, IsOptional, IsPhoneNumber, IsString, isUUID, } from "class-validator";
|
||||
import { UserGroup } from './UserGroup';
|
||||
import { Permission } from './Permission';
|
||||
import { UserAction } from './UserAction';
|
||||
|
||||
/**
|
||||
* Defines a admin user.
|
||||
*/
|
||||
@Entity()
|
||||
export class User {
|
||||
/**
|
||||
* autogenerated unique id (primary key).
|
||||
*/
|
||||
@PrimaryGeneratedColumn()
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
id: number;
|
||||
|
||||
/**
|
||||
* autogenerated uuid
|
||||
*/
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
@Generated("uuid")
|
||||
uuid: string;
|
||||
|
||||
/**
|
||||
* user email
|
||||
*/
|
||||
@IsEmail()
|
||||
email: string;
|
||||
|
||||
/**
|
||||
* user phone
|
||||
*/
|
||||
@IsPhoneNumber("ZZ")
|
||||
@IsOptional()
|
||||
phone: string;
|
||||
|
||||
/**
|
||||
* username
|
||||
*/
|
||||
@IsString()
|
||||
username: string;
|
||||
|
||||
/**
|
||||
* firstname
|
||||
*/
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
firstname: string;
|
||||
|
||||
/**
|
||||
* middlename
|
||||
*/
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
middlename: string;
|
||||
|
||||
/**
|
||||
* lastname
|
||||
*/
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
lastname: string;
|
||||
|
||||
/**
|
||||
* password
|
||||
*/
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
password: string;
|
||||
|
||||
/**
|
||||
* permissions
|
||||
*/
|
||||
@ManyToOne(() => Permission, permission => permission.users, { nullable: true })
|
||||
permissions: Permission[];
|
||||
|
||||
/**
|
||||
* groups
|
||||
*/
|
||||
@ManyToMany(() => UserGroup)
|
||||
@JoinTable()
|
||||
groups: UserGroup[];
|
||||
|
||||
/**
|
||||
* is user enabled?
|
||||
*/
|
||||
@IsBoolean()
|
||||
enabled: boolean;
|
||||
|
||||
/**
|
||||
* jwt refresh count
|
||||
*/
|
||||
@IsInt()
|
||||
@Column({ default: 1 })
|
||||
refreshTokenCount: number;
|
||||
|
||||
/**
|
||||
* profilepic
|
||||
*/
|
||||
@IsString()
|
||||
profilepic: string;
|
||||
|
||||
/**
|
||||
* actions
|
||||
*/
|
||||
@OneToMany(() => UserAction, action => action.user)
|
||||
actions: UserAction
|
||||
|
||||
/**
|
||||
* calculate all permissions
|
||||
*/
|
||||
public get calc_permissions(): Permission[] {
|
||||
let final_permissions = []
|
||||
this.groups.forEach((permission) => {
|
||||
if (!final_permissions.includes(permission)) {
|
||||
final_permissions.push(permission)
|
||||
}
|
||||
})
|
||||
this.permissions.forEach((permission) => {
|
||||
if (!final_permissions.includes(permission)) {
|
||||
final_permissions.push(permission)
|
||||
}
|
||||
})
|
||||
return final_permissions
|
||||
}
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
Reference in new issue
Block a user