ajout des méthodes basiques pour le user + méthodes basique pour les relations amicales. Doit être testé. Manque les routes pour les relations amicales.

This commit is contained in:
batche
2022-10-25 16:45:55 +02:00
parent 5e53a2df78
commit 0eb8d00a7d
92 changed files with 1040 additions and 18 deletions

View File

@@ -13,6 +13,8 @@ const app_service_1 = require("./app.service");
const users_module_1 = require("./users/users.module");
const typeorm_1 = require("@nestjs/typeorm");
const config_1 = require("@nestjs/config");
const friendshipstatuses_module_1 = require("./friendship/friendshipstatuses/friendshipstatuses.module");
const friendship_controller_1 = require("./friendship/friendship/friendship.controller");
let AppModule = class AppModule {
};
AppModule = __decorate([
@@ -29,8 +31,10 @@ AppModule = __decorate([
autoLoadEntities: true,
synchronize: true,
}),
friendshipstatuses_module_1.FriendshipstatusesModule,
common_1.Module,
],
controllers: [app_controller_1.AppController],
controllers: [app_controller_1.AppController, friendship_controller_1.FriendshipController],
providers: [app_service_1.AppService],
})
], AppModule);

View File

@@ -1 +1 @@
{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../src/app.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,qDAAiD;AACjD,+CAA2C;AAC3C,uDAAmD;AACnD,6CAAgD;AAChD,2CAA8C;AAsBvC,IAAM,SAAS,GAAf,MAAM,SAAS;CAAG,CAAA;AAAZ,SAAS;IAnBrB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,0BAAW;YACpB,qBAAY,CAAC,OAAO,EAAE;YACtB,uBAAa,CAAC,OAAO,CAAC;gBACrB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa;gBAC/B,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;gBACzC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa;gBACnC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB;gBACvC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB;gBACvC,gBAAgB,EAAE,IAAI;gBAGtB,WAAW,EAAE,IAAI;aACjB,CAAC;SACJ;QACC,WAAW,EAAE,CAAC,8BAAa,CAAC;QAC5B,SAAS,EAAE,CAAC,wBAAU,CAAC;KACxB,CAAC;GACW,SAAS,CAAG;AAAZ,8BAAS"}
{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../src/app.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,qDAAiD;AACjD,+CAA2C;AAC3C,uDAAmD;AACnD,6CAAgD;AAChD,2CAA8C;AAC9C,yGAAqG;AACrG,yFAAqF;AAyB9E,IAAM,SAAS,GAAf,MAAM,SAAS;CAAG,CAAA;AAAZ,SAAS;IArBrB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,0BAAW;YACpB,qBAAY,CAAC,OAAO,EAAE;YACtB,uBAAa,CAAC,OAAO,CAAC;gBACrB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa;gBAC/B,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;gBACzC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa;gBACnC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB;gBACvC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB;gBACvC,gBAAgB,EAAE,IAAI;gBAGtB,WAAW,EAAE,IAAI;aACjB,CAAC;YACF,oDAAwB;YACxB,eAAM;SACR;QACC,WAAW,EAAE,CAAC,8BAAa,EAAE,4CAAoB,CAAC;QAClD,SAAS,EAAE,CAAC,wBAAU,CAAC;KACxB,CAAC;GACW,SAAS,CAAG;AAAZ,8BAAS"}

View File

@@ -0,0 +1,2 @@
export declare class Module {
}

View File

@@ -0,0 +1,19 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var Module_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Module = void 0;
const common_1 = require("@nestjs/common");
Object.defineProperty(exports, "Module", { enumerable: true, get: function () { return common_1.Module; } });
let Module = Module_1 = class Module {
};
Module = Module_1 = __decorate([
(0, common_1.Module)({})
], Module);
exports.Module = Module;
//# sourceMappingURL=.module.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":".module.js","sourceRoot":"","sources":["../../src/friendship/.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAwC;AAG3B,uFAHJ,eAAM,OAGI;AAAZ,IAAM,MAAM,cAAZ,MAAM,MAAM;CAAG,CAAA;AAAT,MAAM;IADlB,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,MAAM,CAAG;AAAT,wBAAM"}

View File

@@ -0,0 +1,6 @@
import { FriendshipStatus } from '../entities/friendship.entity';
export declare class CreateFriendshipDto {
readonly requesterId: string;
readonly addresseeId: string;
readonly status: FriendshipStatus;
}

View File

@@ -0,0 +1,30 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CreateFriendshipDto = void 0;
const class_validator_1 = require("class-validator");
const friendship_entity_1 = require("../entities/friendship.entity");
class CreateFriendshipDto {
}
__decorate([
(0, class_validator_1.IsInt)(),
__metadata("design:type", String)
], CreateFriendshipDto.prototype, "requesterId", void 0);
__decorate([
(0, class_validator_1.IsInt)(),
__metadata("design:type", String)
], CreateFriendshipDto.prototype, "addresseeId", void 0);
__decorate([
(0, class_validator_1.IsEnum)(friendship_entity_1.FriendshipStatus),
__metadata("design:type", String)
], CreateFriendshipDto.prototype, "status", void 0);
exports.CreateFriendshipDto = CreateFriendshipDto;
//# sourceMappingURL=create-friendship.dto%20copy.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"create-friendship.dto copy.js","sourceRoot":"","sources":["../../../src/friendship/dto/create-friendship.dto copy.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAmE;AACnE,qEAAiE;AAEjE,MAAa,mBAAmB;CAO/B;AANA;IAAC,IAAA,uBAAK,GAAE;;wDACqB;AAC7B;IAAC,IAAA,uBAAK,GAAE;;wDACqB;AAC7B;IAAC,IAAA,wBAAM,EAAC,oCAAgB,CAAC;;mDACS;AANnC,kDAOC"}

View File

@@ -0,0 +1,6 @@
import { FriendshipStatus } from '../entities/friendship.entity';
export declare class CreateFriendshipDto {
readonly requesterId: number;
readonly addresseeId: number;
readonly status: FriendshipStatus;
}

View File

@@ -0,0 +1,30 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CreateFriendshipDto = void 0;
const class_validator_1 = require("class-validator");
const friendship_entity_1 = require("../entities/friendship.entity");
class CreateFriendshipDto {
}
__decorate([
(0, class_validator_1.IsInt)(),
__metadata("design:type", Number)
], CreateFriendshipDto.prototype, "requesterId", void 0);
__decorate([
(0, class_validator_1.IsInt)(),
__metadata("design:type", Number)
], CreateFriendshipDto.prototype, "addresseeId", void 0);
__decorate([
(0, class_validator_1.IsEnum)(friendship_entity_1.FriendshipStatus),
__metadata("design:type", String)
], CreateFriendshipDto.prototype, "status", void 0);
exports.CreateFriendshipDto = CreateFriendshipDto;
//# sourceMappingURL=create-friendship.dto.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"create-friendship.dto.js","sourceRoot":"","sources":["../../../src/friendship/dto/create-friendship.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAgD;AAChD,qEAAiE;AAEjE,MAAa,mBAAmB;CAO/B;AANA;IAAC,IAAA,uBAAK,GAAE;;wDACqB;AAC7B;IAAC,IAAA,uBAAK,GAAE;;wDACqB;AAC7B;IAAC,IAAA,wBAAM,EAAC,oCAAgB,CAAC;;mDACS;AANnC,kDAOC"}

View File

@@ -0,0 +1,6 @@
export declare class CreateUsersDto {
readonly name: string;
readonly username: string;
readonly password: string;
readonly email: string;
}

View File

@@ -0,0 +1,33 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CreateUsersDto = void 0;
const class_validator_1 = require("class-validator");
class CreateUsersDto {
}
__decorate([
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], CreateUsersDto.prototype, "name", void 0);
__decorate([
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], CreateUsersDto.prototype, "username", void 0);
__decorate([
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], CreateUsersDto.prototype, "password", void 0);
__decorate([
(0, class_validator_1.IsEmail)(),
__metadata("design:type", String)
], CreateUsersDto.prototype, "email", void 0);
exports.CreateUsersDto = CreateUsersDto;
//# sourceMappingURL=create-users.dto.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"create-users.dto.js","sourceRoot":"","sources":["../../../src/friendship/dto/create-users.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAoD;AAEpD,MAAa,cAAc;CAS1B;AARA;IAAC,IAAA,0BAAQ,GAAE;;4CACW;AACtB;IAAC,IAAA,0BAAQ,GAAE;;gDACe;AAC1B;IAAC,IAAA,0BAAQ,GAAE;;gDACe;AAC1B;IAAC,IAAA,yBAAO,GAAE;;6CACa;AARxB,wCASC"}

View File

@@ -0,0 +1,5 @@
import { CreateFriendshipDto } from "./create-friendship.dto";
declare const UpdateFriendshipDto_base: import("@nestjs/mapped-types").MappedType<Partial<CreateFriendshipDto>>;
export declare class UpdateFriendshipDto extends UpdateFriendshipDto_base {
}
export {};

View File

@@ -0,0 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UpdateFriendshipDto = void 0;
const mapped_types_1 = require("@nestjs/mapped-types");
const create_friendship_dto_1 = require("./create-friendship.dto");
class UpdateFriendshipDto extends (0, mapped_types_1.PartialType)(create_friendship_dto_1.CreateFriendshipDto) {
}
exports.UpdateFriendshipDto = UpdateFriendshipDto;
//# sourceMappingURL=update-friendship.dto.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"update-friendship.dto.js","sourceRoot":"","sources":["../../../src/friendship/dto/update-friendship.dto.ts"],"names":[],"mappings":";;;AAAA,uDAAmD;AACnD,mEAA8D;AAE9D,MAAa,mBAAoB,SAAQ,IAAA,0BAAW,EAAC,2CAAmB,CAAC;CAAE;AAA3E,kDAA2E"}

View File

@@ -0,0 +1,13 @@
export declare enum FriendshipStatus {
REQUESTED = "R",
ACCEPTED = "A",
DECLINED = "D",
BLOCKED = "B"
}
export declare class Friendship {
id: number;
date: Date;
requesterId: number;
addresseeId: number;
status: FriendshipStatus;
}

View File

@@ -0,0 +1,50 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Friendship = exports.FriendshipStatus = void 0;
const typeorm_1 = require("typeorm");
const user_entity_1 = require("../../users/entities/user.entity");
var FriendshipStatus;
(function (FriendshipStatus) {
FriendshipStatus["REQUESTED"] = "R";
FriendshipStatus["ACCEPTED"] = "A";
FriendshipStatus["DECLINED"] = "D";
FriendshipStatus["BLOCKED"] = "B";
})(FriendshipStatus = exports.FriendshipStatus || (exports.FriendshipStatus = {}));
let Friendship = class Friendship {
};
__decorate([
(0, typeorm_1.PrimaryGeneratedColumn)(),
__metadata("design:type", Number)
], Friendship.prototype, "id", void 0);
__decorate([
(0, typeorm_1.CreateDateColumn)(),
__metadata("design:type", Date)
], Friendship.prototype, "date", void 0);
__decorate([
(0, typeorm_1.Column)(),
(0, typeorm_1.ManyToOne)(type => user_entity_1.User, user => user.requesterId),
__metadata("design:type", Number)
], Friendship.prototype, "requesterId", void 0);
__decorate([
(0, typeorm_1.Column)(),
(0, typeorm_1.ManyToOne)(type => user_entity_1.User, user => user.addresseeId),
__metadata("design:type", Number)
], Friendship.prototype, "addresseeId", void 0);
__decorate([
(0, typeorm_1.Column)({ type: 'enum', enum: FriendshipStatus, default: FriendshipStatus.REQUESTED }),
__metadata("design:type", String)
], Friendship.prototype, "status", void 0);
Friendship = __decorate([
(0, typeorm_1.Entity)('friendships')
], Friendship);
exports.Friendship = Friendship;
//# sourceMappingURL=friendship.entity.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"friendship.entity.js","sourceRoot":"","sources":["../../../src/friendship/entities/friendship.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAwH;AACxH,kEAAwD;AAExD,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC3B,mCAAe,CAAA;IACf,kCAAc,CAAA;IACd,kCAAc,CAAA;IACd,iCAAa,CAAA;AACd,CAAC,EALW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAK3B;AAGM,IAAM,UAAU,GAAhB,MAAM,UAAU;CAiBtB,CAAA;AAhBA;IAAC,IAAA,gCAAsB,GAAE;;sCACd;AAEX;IAAC,IAAA,0BAAgB,GAAE;8BACZ,IAAI;wCAAC;AAEZ;IAAC,IAAA,gBAAM,GAAE;IACR,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAI,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC;;+CAC9B;AAEpB;IAAC,IAAA,gBAAM,GAAE;IACR,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAI,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC;;+CAC9B;AAEpB;IAAC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,gBAAgB,CAAC,SAAS,EAAE,CAAC;;0CAC7D;AAhBb,UAAU;IADtB,IAAA,gBAAM,EAAC,aAAa,CAAC;GACT,UAAU,CAiBtB;AAjBY,gCAAU"}

View File

@@ -0,0 +1,2 @@
export declare class FriendshipController {
}

View File

@@ -0,0 +1,17 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FriendshipController = void 0;
const common_1 = require("@nestjs/common");
let FriendshipController = class FriendshipController {
};
FriendshipController = __decorate([
(0, common_1.Controller)('friendship')
], FriendshipController);
exports.FriendshipController = FriendshipController;
//# sourceMappingURL=friendship.controller.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"friendship.controller.js","sourceRoot":"","sources":["../../src/friendship/friendship.controller.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAGrC,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;CAAG,CAAA;AAAvB,oBAAoB;IADhC,IAAA,mBAAU,EAAC,YAAY,CAAC;GACZ,oBAAoB,CAAG;AAAvB,oDAAoB"}

View File

@@ -0,0 +1,2 @@
export declare class FriendshipsModule {
}

View File

@@ -0,0 +1,22 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FriendshipsModule = void 0;
const common_1 = require("@nestjs/common");
const typeorm_1 = require("@nestjs/typeorm");
const friendship_service_1 = require("./friendship.service");
let FriendshipsModule = class FriendshipsModule {
};
FriendshipsModule = __decorate([
(0, common_1.Module)({
imports: [typeorm_1.TypeOrmModule.forFeature([Friendship, User])],
providers: [friendship_service_1.FriendshipService]
})
], FriendshipsModule);
exports.FriendshipsModule = FriendshipsModule;
//# sourceMappingURL=friendship.module.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"friendship.module.js","sourceRoot":"","sources":["../../src/friendship/friendship.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,6CAAgD;AAChD,6DAAyD;AAOlD,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;CAAG,CAAA;AAApB,iBAAiB;IAL7B,IAAA,eAAM,EAAC;QACP,OAAO,EAAE,CAAC,uBAAa,CAAC,UAAU,CAAC,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC;QAEtD,SAAS,EAAE,CAAC,sCAAiB,CAAC;KAC/B,CAAC;GACW,iBAAiB,CAAG;AAApB,8CAAiB"}

View File

@@ -0,0 +1,16 @@
import { User } from 'src/users/entities/user.entity';
import { Repository } from 'typeorm';
import { CreateFriendshipDto } from './dto/create-friendship.dto';
import { UpdateFriendshipDto } from './dto/update-friendship.dto';
import { Friendship } from './entities/friendship.entity';
export declare class FriendshipService {
private readonly friendshipRepository;
private readonly userRepository;
constructor(friendshipRepository: Repository<Friendship>, userRepository: Repository<User>);
findOne(id: string): Promise<Friendship>;
findAllFriends(id: string): Promise<Friendship[]>;
findAllBlockedFriends(id: string): Promise<Friendship[]>;
create({ requesterId, addresseeId, status }: CreateFriendshipDto): Promise<Friendship>;
updateFriendship(id: string, updateFriendshipDto: UpdateFriendshipDto): Promise<Friendship>;
removeFriendship(id: string): Promise<Friendship>;
}

View File

@@ -0,0 +1,88 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FriendshipService = void 0;
const common_1 = require("@nestjs/common");
const typeorm_1 = require("@nestjs/typeorm");
const user_entity_1 = require("../users/entities/user.entity");
const typeorm_2 = require("typeorm");
const friendship_entity_1 = require("./entities/friendship.entity");
let FriendshipService = class FriendshipService {
constructor(friendshipRepository, userRepository) {
this.friendshipRepository = friendshipRepository;
this.userRepository = userRepository;
}
async findOne(id) {
const friendship = await this.friendshipRepository.findOneBy({ id: +id });
if (!friendship)
throw new common_1.HttpException(`The requested friendship not found.`, common_1.HttpStatus.NOT_FOUND);
return friendship;
}
async findAllFriends(id) {
const user = await this.userRepository.findOneBy({ id: +id });
if (!user)
throw new common_1.HttpException(`The requested user not found.`, common_1.HttpStatus.NOT_FOUND);
const friends = await this.friendshipRepository.find({ where: { requesterId: +id, status: friendship_entity_1.FriendshipStatus.ACCEPTED } });
return friends;
}
async findAllBlockedFriends(id) {
const user = await this.userRepository.findOneBy({ id: +id });
if (!user)
throw new common_1.HttpException(`The requested user not found.`, common_1.HttpStatus.NOT_FOUND);
const blocked = await this.friendshipRepository.find({ where: { requesterId: +id, status: friendship_entity_1.FriendshipStatus.BLOCKED } });
return blocked;
}
async create({ requesterId, addresseeId, status }) {
const requester = await this.userRepository.findOneBy({ id: +requesterId });
if (!requester)
throw new common_1.HttpException(`The user does not exist.`, common_1.HttpStatus.NOT_FOUND);
const addressee = await this.userRepository.findOneBy({ id: +addresseeId });
if (!addressee)
throw new common_1.HttpException(`The user does not exist.`, common_1.HttpStatus.NOT_FOUND);
if (requesterId == addresseeId)
throw new common_1.HttpException(`You can't add yourself.`, common_1.HttpStatus.NOT_FOUND);
const friendship = this.friendshipRepository.findOneBy({ requesterId: +requesterId, addresseeId: +addresseeId });
if ((await friendship).status === 'R')
throw new common_1.HttpException(`The friendship request has already been sent the ${(await friendship).date}.`, common_1.HttpStatus.OK);
if ((await friendship).status === 'A')
throw new common_1.HttpException(`The friendship request has already been accepted.`, common_1.HttpStatus.OK);
if ((await friendship).status === 'D')
throw new common_1.HttpException(``, common_1.HttpStatus.OK);
if ((await friendship).status === 'B')
throw new common_1.HttpException(`The user does not exist.`, common_1.HttpStatus.OK);
const newFriendship = this.friendshipRepository.create({ requesterId: +requesterId, addresseeId: +addresseeId, status: status });
return this.friendshipRepository.save(newFriendship);
}
async updateFriendship(id, updateFriendshipDto) {
const friendship = await this.friendshipRepository.preload(Object.assign({ id: +id }, updateFriendshipDto));
if (!friendship)
throw new common_1.HttpException(`The friendship could not be updated.`, common_1.HttpStatus.NOT_FOUND);
return this.friendshipRepository.save(friendship);
}
async removeFriendship(id) {
const friendship = await this.findOne(id);
if (!friendship)
throw new common_1.HttpException(`Your friend could not be deleted.`, common_1.HttpStatus.NOT_FOUND);
return this.friendshipRepository.remove(friendship);
}
};
FriendshipService = __decorate([
(0, common_1.Injectable)(),
__param(0, (0, typeorm_1.InjectRepository)(friendship_entity_1.Friendship)),
__param(1, (0, typeorm_1.InjectRepository)(user_entity_1.User)),
__metadata("design:paramtypes", [typeorm_2.Repository,
typeorm_2.Repository])
], FriendshipService);
exports.FriendshipService = FriendshipService;
//# sourceMappingURL=friendship.service.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"friendship.service.js","sourceRoot":"","sources":["../../src/friendship/friendship.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAuE;AACvE,6CAAmD;AACnD,+DAAsD;AACtD,qCAAqC;AAGrC,oEAA4E;AAGrE,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAE7B,YAEkB,oBAA4C,EAE5C,cAAgC;QAFhC,yBAAoB,GAApB,oBAAoB,CAAwB;QAE5C,mBAAc,GAAd,cAAc,CAAkB;IAC/C,CAAC;IAGJ,KAAK,CAAC,OAAO,CAAC,EAAU;QACvB,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC,EAAC,EAAE,EAAE,CAAC,EAAE,EAAC,CAAC,CAAC;QACxE,IAAI,CAAC,UAAU;YACd,MAAM,IAAI,sBAAa,CAAC,qCAAqC,EAAC,mBAAU,CAAC,SAAS,CAAC,CAAC;QACrF,OAAO,UAAU,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,EAAU;QAC9B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,EAAC,EAAE,EAAE,CAAC,EAAE,EAAC,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI;YACR,MAAM,IAAI,sBAAa,CAAC,+BAA+B,EAAC,mBAAU,CAAC,SAAS,CAAC,CAAC;QAC/E,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAC,KAAK,EAAE,EAAC,WAAW,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,oCAAgB,CAAC,QAAQ,EAAC,EAAC,CAAC,CAAC;QACrH,OAAO,OAAO,CAAC;I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QAChC,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAC1C,IAAI,CAAC,UAAU;YACd,MAAM,IAAI,sBAAa,CAAC,mCAAmC,EAAC,mBAAU,CAAC,SAAS,CAAC,CAAC;QACnF,OAAO,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACrD,CAAC;CACD,CAAA;AAtEY,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;IAIV,WAAA,IAAA,0BAAgB,EAAC,8BAAU,CAAC,CAAA;IAE5B,WAAA,IAAA,0BAAgB,EAAC,kBAAI,CAAC,CAAA;qCADgB,oBAAU;QAEhB,oBAAU;GANhC,iBAAiB,CAsE7B;AAtEY,8CAAiB"}

View File

@@ -0,0 +1,2 @@
export declare class FriendshipController {
}

View File

@@ -0,0 +1,17 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FriendshipController = void 0;
const common_1 = require("@nestjs/common");
let FriendshipController = class FriendshipController {
};
FriendshipController = __decorate([
(0, common_1.Controller)('friendship')
], FriendshipController);
exports.FriendshipController = FriendshipController;
//# sourceMappingURL=friendship.controller.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"friendship.controller.js","sourceRoot":"","sources":["../../../src/friendship/friendship/friendship.controller.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAGrC,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;CAAG,CAAA;AAAvB,oBAAoB;IADhC,IAAA,mBAAU,EAAC,YAAY,CAAC;GACZ,oBAAoB,CAAG;AAAvB,oDAAoB"}

View File

@@ -0,0 +1,2 @@
export declare class FriendshipService {
}

View File

@@ -0,0 +1,17 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FriendshipService = void 0;
const common_1 = require("@nestjs/common");
let FriendshipService = class FriendshipService {
};
FriendshipService = __decorate([
(0, common_1.Injectable)()
], FriendshipService);
exports.FriendshipService = FriendshipService;
//# sourceMappingURL=friendship.service.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"friendship.service.js","sourceRoot":"","sources":["../../../src/friendship/friendship/friendship.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAGrC,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;CAAG,CAAA;AAApB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;GACA,iBAAiB,CAAG;AAApB,8CAAiB"}

View File

@@ -0,0 +1,2 @@
export declare class FriendshipsModule {
}

View File

@@ -0,0 +1,27 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FriendshipsModule = void 0;
const common_1 = require("@nestjs/common");
const typeorm_1 = require("@nestjs/typeorm");
const friendship_service_1 = require("./friendship.service");
const friendship_controller_1 = require("./friendship.controller");
const friendship_entity_1 = require("./entities/friendship.entity");
const user_entity_1 = require("../users/entities/user.entity");
let FriendshipsModule = class FriendshipsModule {
};
FriendshipsModule = __decorate([
(0, common_1.Module)({
imports: [typeorm_1.TypeOrmModule.forFeature([friendship_entity_1.Friendship, user_entity_1.User])],
providers: [friendship_service_1.FriendshipService],
controllers: [friendship_controller_1.FriendshipController],
exports: [friendship_service_1.FriendshipService],
})
], FriendshipsModule);
exports.FriendshipsModule = FriendshipsModule;
//# sourceMappingURL=friendships.module.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"friendships.module.js","sourceRoot":"","sources":["../../src/friendship/friendships.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,6CAAgD;AAChD,6DAAyD;AACzD,mEAA+D;AAC/D,oEAA0D;AAC1D,+DAAqD;AAQ9C,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;CAAG,CAAA;AAApB,iBAAiB;IAN7B,IAAA,eAAM,EAAC;QACP,OAAO,EAAE,CAAC,uBAAa,CAAC,UAAU,CAAC,CAAC,8BAAU,EAAE,kBAAI,CAAC,CAAC,CAAC;QACvD,SAAS,EAAE,CAAC,sCAAiB,CAAC;QAC9B,WAAW,EAAE,CAAC,4CAAoB,CAAC;QACnC,OAAO,EAAE,CAAC,sCAAiB,CAAC;KAC5B,CAAC;GACW,iBAAiB,CAAG;AAApB,8CAAiB"}

View File

@@ -0,0 +1,2 @@
export declare class FriendshipstatusesController {
}

View File

@@ -0,0 +1,17 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FriendshipstatusesController = void 0;
const common_1 = require("@nestjs/common");
let FriendshipstatusesController = class FriendshipstatusesController {
};
FriendshipstatusesController = __decorate([
(0, common_1.Controller)('friendshipstatuses')
], FriendshipstatusesController);
exports.FriendshipstatusesController = FriendshipstatusesController;
//# sourceMappingURL=friendshipstatuses.controller.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"friendshipstatuses.controller.js","sourceRoot":"","sources":["../../../src/friendship/friendshipstatuses/friendshipstatuses.controller.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAGrC,IAAM,4BAA4B,GAAlC,MAAM,4BAA4B;CAAG,CAAA;AAA/B,4BAA4B;IADxC,IAAA,mBAAU,EAAC,oBAAoB,CAAC;GACpB,4BAA4B,CAAG;AAA/B,oEAA4B"}

View File

@@ -0,0 +1,2 @@
export declare class FriendshipstatusesModule {
}

View File

@@ -0,0 +1,20 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FriendshipstatusesModule = void 0;
const common_1 = require("@nestjs/common");
const friendshipstatuses_controller_1 = require("./friendshipstatuses.controller");
let FriendshipstatusesModule = class FriendshipstatusesModule {
};
FriendshipstatusesModule = __decorate([
(0, common_1.Module)({
controllers: [friendshipstatuses_controller_1.FriendshipstatusesController]
})
], FriendshipstatusesModule);
exports.FriendshipstatusesModule = FriendshipstatusesModule;
//# sourceMappingURL=friendshipstatuses.module.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"friendshipstatuses.module.js","sourceRoot":"","sources":["../../../src/friendship/friendshipstatuses/friendshipstatuses.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,mFAA+E;AAKxE,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;CAAG,CAAA;AAA3B,wBAAwB;IAHpC,IAAA,eAAM,EAAC;QACN,WAAW,EAAE,CAAC,4DAA4B,CAAC;KAC5C,CAAC;GACW,wBAAwB,CAAG;AAA3B,4DAAwB"}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
//# sourceMappingURL=create-friendship.dto.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"create-friendship.dto.js","sourceRoot":"","sources":["../../../src/users/dto/create-friendship.dto.ts"],"names":[],"mappings":""}

View File

@@ -2,4 +2,5 @@ export declare class CreateUsersDto {
readonly name: string;
readonly username: string;
readonly password: string;
readonly email: string;
}

View File

@@ -25,5 +25,9 @@ __decorate([
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], CreateUsersDto.prototype, "password", void 0);
__decorate([
(0, class_validator_1.IsEmail)(),
__metadata("design:type", String)
], CreateUsersDto.prototype, "email", void 0);
exports.CreateUsersDto = CreateUsersDto;
//# sourceMappingURL=create-users.dto.js.map

View File

@@ -1 +1 @@
{"version":3,"file":"create-users.dto.js","sourceRoot":"","sources":["../../../src/users/dto/create-users.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAA2C;AAE3C,MAAa,cAAc;CAO1B;AANA;IAAC,IAAA,0BAAQ,GAAE;;4CACW;AACtB;IAAC,IAAA,0BAAQ,GAAE;;gDACe;AAC1B;IAAC,IAAA,0BAAQ,GAAE;;gDACe;AAN3B,wCAOC"}
{"version":3,"file":"create-users.dto.js","sourceRoot":"","sources":["../../../src/users/dto/create-users.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAoD;AAEpD,MAAa,cAAc;CAS1B;AARA;IAAC,IAAA,0BAAQ,GAAE;;4CACW;AACtB;IAAC,IAAA,0BAAQ,GAAE;;gDACe;AAC1B;IAAC,IAAA,0BAAQ,GAAE;;gDACe;AAC1B;IAAC,IAAA,yBAAO,GAAE;;6CACa;AARxB,wCASC"}

View File

@@ -0,0 +1,6 @@
export declare class FriendshipStatus {
requesterId: number;
addresseeId: number;
dateOfInvitation: Date;
specifierId: number;
}

View File

@@ -0,0 +1,6 @@
export declare class FriendshipStatus {
requesterId: number;
addresseeId: number;
dateOfInvitation: Date;
specifierId: number;
}

View File

@@ -0,0 +1,40 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FriendshipStatus = void 0;
const typeorm_1 = require("typeorm");
const friendship_entity_1 = require("./friendship.entity");
const user_entity_1 = require("./user.entity");
(0, typeorm_1.Entity)('friendshipStatus');
class FriendshipStatus {
}
__decorate([
(0, typeorm_1.PrimaryColumn)(),
(0, typeorm_1.ManyToOne)(() => friendship_entity_1.Friendship, (friendship) => friendship.requesterId),
__metadata("design:type", Number)
], FriendshipStatus.prototype, "requesterId", void 0);
__decorate([
(0, typeorm_1.PrimaryColumn)(),
(0, typeorm_1.ManyToOne)(() => friendship_entity_1.Friendship, (friendship) => friendship.addresseeId),
__metadata("design:type", Number)
], FriendshipStatus.prototype, "addresseeId", void 0);
__decorate([
(0, typeorm_1.PrimaryColumn)(),
(0, typeorm_1.CreateDateColumn)(),
__metadata("design:type", Date)
], FriendshipStatus.prototype, "dateOfInvitation", void 0);
__decorate([
(0, typeorm_1.Column)(),
(0, typeorm_1.ManyToOne)(() => user_entity_1.User, (user) => user.requesterId),
__metadata("design:type", Number)
], FriendshipStatus.prototype, "specifierId", void 0);
exports.FriendshipStatus = FriendshipStatus;
//# sourceMappingURL=friendship-status.entity.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"friendship-status.entity.js","sourceRoot":"","sources":["../../../src/users/entities/friendship-status.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAqF;AACrF,2DAAiD;AACjD,+CAAqC;AAErC,IAAA,gBAAM,EAAC,kBAAkB,CAAC,CAAA;AAC1B,MAAa,gBAAgB;CAgB5B;AAfA;IAAC,IAAA,uBAAa,GAAE;IACf,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,8BAAU,EAAG,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC;;qDAChD;AAErB;IAAC,IAAA,uBAAa,GAAE;IACf,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,8BAAU,EAAG,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC;;qDAChD;AAErB;IAAC,IAAA,uBAAa,GAAE;IACf,IAAA,0BAAgB,GAAE;8BACA,IAAI;0DAAC;AAExB;IAAC,IAAA,gBAAM,GAAE;IACR,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,kBAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC;;qDAC7B;AAftB,4CAgBC"}

View File

@@ -0,0 +1,39 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FriendshipStatus = void 0;
const typeorm_1 = require("typeorm");
const friendship_entity_1 = require("./friendship.entity");
const user_entity_1 = require("./user.entity");
(0, typeorm_1.Entity)('friendshipStatus');
class FriendshipStatus {
}
__decorate([
(0, typeorm_1.PrimaryColumn)(),
(0, typeorm_1.ManyToOne)(() => friendship_entity_1.Friendship, (friendship) => friendship.requesterId),
__metadata("design:type", Number)
], FriendshipStatus.prototype, "requesterId", void 0);
__decorate([
(0, typeorm_1.PrimaryColumn)(),
(0, typeorm_1.ManyToOne)(() => friendship_entity_1.Friendship, (friendship) => friendship.addresseeId),
__metadata("design:type", Number)
], FriendshipStatus.prototype, "addresseeId", void 0);
__decorate([
(0, typeorm_1.PrimaryColumn)(),
__metadata("design:type", Date)
], FriendshipStatus.prototype, "dateOfInvitation", void 0);
__decorate([
(0, typeorm_1.Column)(),
(0, typeorm_1.ManyToOne)(() => user_entity_1.User, (user) => user.requesterId),
__metadata("design:type", Number)
], FriendshipStatus.prototype, "specifierId", void 0);
exports.FriendshipStatus = FriendshipStatus;
//# sourceMappingURL=friendship-status.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"friendship-status.js","sourceRoot":"","sources":["../../../src/users/entities/friendship-status.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAmE;AACnE,2DAAiD;AACjD,+CAAqC;AAErC,IAAA,gBAAM,EAAC,kBAAkB,CAAC,CAAA;AAC1B,MAAa,gBAAgB;CAe5B;AAdA;IAAC,IAAA,uBAAa,GAAE;IACf,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,8BAAU,EAAG,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC;;qDAChD;AAErB;IAAC,IAAA,uBAAa,GAAE;IACf,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,8BAAU,EAAG,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC;;qDAChD;AAErB;IAAC,IAAA,uBAAa,GAAE;8BACG,IAAI;0DAAC;AAExB;IAAC,IAAA,gBAAM,GAAE;IACR,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,kBAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC;;qDAC7B;AAdtB,4CAeC"}

View File

@@ -0,0 +1,8 @@
import { User } from "./user.entity";
export declare class Friendship {
requesterId: number;
addresseeId: number;
requester: User;
addressee: User;
date: Date;
}

View File

@@ -0,0 +1,13 @@
export declare enum FriendshipStatus {
REQUESTED = "R",
ACCEPTED = "A",
DECLINED = "D",
BLOCKED = "B"
}
export declare class Friendship {
id: number;
date: Date;
requesterId: number;
addresseeId: number;
status: FriendshipStatus;
}

View File

@@ -0,0 +1,50 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Friendship = exports.FriendshipStatus = void 0;
const typeorm_1 = require("typeorm");
const user_entity_1 = require("./user.entity");
var FriendshipStatus;
(function (FriendshipStatus) {
FriendshipStatus["REQUESTED"] = "R";
FriendshipStatus["ACCEPTED"] = "A";
FriendshipStatus["DECLINED"] = "D";
FriendshipStatus["BLOCKED"] = "B";
})(FriendshipStatus = exports.FriendshipStatus || (exports.FriendshipStatus = {}));
let Friendship = class Friendship {
};
__decorate([
(0, typeorm_1.PrimaryGeneratedColumn)(),
__metadata("design:type", Number)
], Friendship.prototype, "id", void 0);
__decorate([
(0, typeorm_1.CreateDateColumn)(),
__metadata("design:type", Date)
], Friendship.prototype, "date", void 0);
__decorate([
(0, typeorm_1.Column)(),
(0, typeorm_1.ManyToOne)(type => user_entity_1.User, user => user.requesterId),
__metadata("design:type", Number)
], Friendship.prototype, "requesterId", void 0);
__decorate([
(0, typeorm_1.Column)(),
(0, typeorm_1.ManyToOne)(type => user_entity_1.User, user => user.addresseeId),
__metadata("design:type", Number)
], Friendship.prototype, "addresseeId", void 0);
__decorate([
(0, typeorm_1.Column)({ type: 'enum', enum: FriendshipStatus, default: FriendshipStatus.REQUESTED }),
__metadata("design:type", String)
], Friendship.prototype, "status", void 0);
Friendship = __decorate([
(0, typeorm_1.Entity)('friendships')
], Friendship);
exports.Friendship = Friendship;
//# sourceMappingURL=friendship.entity.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"friendship.entity.js","sourceRoot":"","sources":["../../../src/users/entities/friendship.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAwH;AACxH,+CAAqC;AAErC,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC3B,mCAAe,CAAA;IACf,kCAAc,CAAA;IACd,kCAAc,CAAA;IACd,iCAAa,CAAA;AACd,CAAC,EALW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAK3B;AAGM,IAAM,UAAU,GAAhB,MAAM,UAAU;CAiBtB,CAAA;AAhBA;IAAC,IAAA,gCAAsB,GAAE;;sCACd;AAEX;IAAC,IAAA,0BAAgB,GAAE;8BACZ,IAAI;wCAAC;AAEZ;IAAC,IAAA,gBAAM,GAAE;IACR,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAI,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC;;+CAC9B;AAEpB;IAAC,IAAA,gBAAM,GAAE;IACR,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAI,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC;;+CAC9B;AAEpB;IAAC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,gBAAgB,CAAC,SAAS,EAAE,CAAC;;0CAC7D;AAhBb,UAAU;IADtB,IAAA,gBAAM,EAAC,aAAa,CAAC;GACT,UAAU,CAiBtB;AAjBY,gCAAU"}

View File

@@ -0,0 +1,43 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Friendship = void 0;
const typeorm_1 = require("typeorm");
const user_entity_1 = require("./user.entity");
let Friendship = class Friendship {
};
__decorate([
(0, typeorm_1.PrimaryColumn)(),
(0, typeorm_1.ManyToOne)(() => user_entity_1.User, (user) => user.id),
__metadata("design:type", Number)
], Friendship.prototype, "requesterId", void 0);
__decorate([
(0, typeorm_1.PrimaryColumn)(),
(0, typeorm_1.ManyToOne)(() => user_entity_1.User, (user) => user.id),
__metadata("design:type", Number)
], Friendship.prototype, "addresseeId", void 0);
__decorate([
(0, typeorm_1.ManyToOne)(() => user_entity_1.User, (user) => user.id),
__metadata("design:type", user_entity_1.User)
], Friendship.prototype, "requester", void 0);
__decorate([
(0, typeorm_1.ManyToOne)(() => user_entity_1.User, (user) => user.id),
__metadata("design:type", user_entity_1.User)
], Friendship.prototype, "addressee", void 0);
__decorate([
(0, typeorm_1.Column)(),
__metadata("design:type", Date)
], Friendship.prototype, "date", void 0);
Friendship = __decorate([
(0, typeorm_1.Entity)('friendships')
], Friendship);
exports.Friendship = Friendship;
//# sourceMappingURL=friendship.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"friendship.js","sourceRoot":"","sources":["../../../src/users/entities/friendship.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAmE;AACnE,+CAAqC;AAI9B,IAAM,UAAU,GAAhB,MAAM,UAAU;CAiBtB,CAAA;AAhBA;IAAC,IAAA,uBAAa,GAAE;IACf,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,kBAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;;+CACpB;AAErB;IAAC,IAAA,uBAAa,GAAE;IACf,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,kBAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;;+CACpB;AAErB;IAAC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,kBAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;8BAC7B,kBAAI;6CAAC;AAEjB;IAAC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,kBAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;8BAC7B,kBAAI;6CAAC;AAEjB;IAAC,IAAA,gBAAM,GAAE;8BACF,IAAI;wCAAC;AAhBA,UAAU;IADtB,IAAA,gBAAM,EAAC,aAAa,CAAC;GACT,UAAU,CAiBtB;AAjBY,gCAAU"}

View File

@@ -0,0 +1,10 @@
export declare enum StatusCode {
REQUESTED = "R",
ACCEPTED = "A",
DECLINED = "F",
BLOCKED = "B"
}
export declare class StatusForFriendship {
code: StatusCode;
name: string;
}

View File

@@ -0,0 +1,10 @@
export declare enum StatusCode {
REQUESTED = "R",
ACCEPTED = "A",
DECLINED = "F",
BLOCKED = "B"
}
export declare class StatusForFriendship {
code: StatusCode;
name: string;
}

View File

@@ -0,0 +1,35 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.StatusForFriendship = exports.StatusCode = void 0;
const typeorm_1 = require("typeorm");
var StatusCode;
(function (StatusCode) {
StatusCode["REQUESTED"] = "R";
StatusCode["ACCEPTED"] = "A";
StatusCode["DECLINED"] = "F";
StatusCode["BLOCKED"] = "B";
})(StatusCode = exports.StatusCode || (exports.StatusCode = {}));
let StatusForFriendship = class StatusForFriendship {
};
__decorate([
(0, typeorm_1.PrimaryColumn)(),
__metadata("design:type", String)
], StatusForFriendship.prototype, "code", void 0);
__decorate([
(0, typeorm_1.Column)(),
__metadata("design:type", String)
], StatusForFriendship.prototype, "name", void 0);
StatusForFriendship = __decorate([
(0, typeorm_1.Entity)("statusForFriendship")
], StatusForFriendship);
exports.StatusForFriendship = StatusForFriendship;
//# sourceMappingURL=status-for-friendship.entity.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"status-for-friendship.entity.js","sourceRoot":"","sources":["../../../src/users/entities/status-for-friendship.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAwD;AAExD,IAAY,UAKX;AALD,WAAY,UAAU;IACrB,6BAAc,CAAA;IACd,4BAAa,CAAA;IACb,4BAAc,CAAA;IACd,2BAAa,CAAA;AACd,CAAC,EALW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAKrB;AAGM,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;CAM/B,CAAA;AALA;IAAC,IAAA,uBAAa,GAAE;;iDACC;AAEjB;IAAC,IAAA,gBAAM,GAAE;;iDACI;AALD,mBAAmB;IAD/B,IAAA,gBAAM,EAAC,qBAAqB,CAAC;GACjB,mBAAmB,CAM/B;AANY,kDAAmB"}

View File

@@ -0,0 +1,35 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.StatusForFriendship = exports.StatusCode = void 0;
const typeorm_1 = require("typeorm");
var StatusCode;
(function (StatusCode) {
StatusCode["REQUESTED"] = "R";
StatusCode["ACCEPTED"] = "A";
StatusCode["DECLINED"] = "F";
StatusCode["BLOCKED"] = "B";
})(StatusCode = exports.StatusCode || (exports.StatusCode = {}));
let StatusForFriendship = class StatusForFriendship {
};
__decorate([
(0, typeorm_1.PrimaryColumn)(),
__metadata("design:type", String)
], StatusForFriendship.prototype, "code", void 0);
__decorate([
(0, typeorm_1.Column)(),
__metadata("design:type", String)
], StatusForFriendship.prototype, "name", void 0);
StatusForFriendship = __decorate([
(0, typeorm_1.Entity)("statusForFriendship")
], StatusForFriendship);
exports.StatusForFriendship = StatusForFriendship;
//# sourceMappingURL=status-for-friendship.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"status-for-friendship.js","sourceRoot":"","sources":["../../../src/users/entities/status-for-friendship.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAwD;AAExD,IAAY,UAKX;AALD,WAAY,UAAU;IACrB,6BAAc,CAAA;IACd,4BAAa,CAAA;IACb,4BAAc,CAAA;IACd,2BAAa,CAAA;AACd,CAAC,EALW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAKrB;AAGM,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;CAM/B,CAAA;AALA;IAAC,IAAA,uBAAa,GAAE;;iDACC;AAEjB;IAAC,IAAA,gBAAM,GAAE;;iDACI;AALD,mBAAmB;IAD/B,IAAA,gBAAM,EAAC,qBAAqB,CAAC;GACjB,mBAAmB,CAM/B;AANY,kDAAmB"}

View File

@@ -1,7 +1,11 @@
import { Friendship } from "../../friendship/entities/friendship.entity";
export declare class User {
id: number;
name: string;
username: string;
email: string;
password: string;
status: [string];
requesterId: Friendship[];
addresseeId: Friendship[];
}

View File

@@ -11,6 +11,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.User = void 0;
const typeorm_1 = require("typeorm");
const friendship_entity_1 = require("../../friendship/entities/friendship.entity");
let User = class User {
};
__decorate([
@@ -25,6 +26,10 @@ __decorate([
(0, typeorm_1.Column)(),
__metadata("design:type", String)
], User.prototype, "username", void 0);
__decorate([
(0, typeorm_1.Column)(),
__metadata("design:type", String)
], User.prototype, "email", void 0);
__decorate([
(0, typeorm_1.Column)(),
__metadata("design:type", String)
@@ -33,6 +38,16 @@ __decorate([
(0, typeorm_1.Column)('json', { nullable: true }),
__metadata("design:type", Array)
], User.prototype, "status", void 0);
__decorate([
(0, typeorm_1.JoinTable)(),
(0, typeorm_1.OneToMany)(type => friendship_entity_1.Friendship, (friendship) => friendship.requesterId),
__metadata("design:type", Array)
], User.prototype, "requesterId", void 0);
__decorate([
(0, typeorm_1.JoinTable)(),
(0, typeorm_1.OneToMany)(type => friendship_entity_1.Friendship, (friendship) => friendship.addresseeId),
__metadata("design:type", Array)
], User.prototype, "addresseeId", void 0);
User = __decorate([
(0, typeorm_1.Entity)('users')
], User);

View File

@@ -1 +1 @@
{"version":3,"file":"user.entity.js","sourceRoot":"","sources":["../../../src/users/entities/user.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAiE;AAG1D,IAAM,IAAI,GAAV,MAAM,IAAI;CAehB,CAAA;AAdA;IAAC,IAAA,gCAAsB,GAAE;;gCACd;AACX;IAAC,IAAA,gBAAM,GAAE;;kCACI;AACb;IAAC,IAAA,gBAAM,GAAE;;sCACQ;AAIjB;IAAC,IAAA,gBAAM,GAAE;;sCACQ;AAEjB;IAAC,IAAA,gBAAM,EAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;oCAClB;AAdL,IAAI;IADhB,IAAA,gBAAM,EAAC,OAAO,CAAC;GACH,IAAI,CAehB;AAfY,oBAAI"}
{"version":3,"file":"user.entity.js","sourceRoot":"","sources":["../../../src/users/entities/user.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,qCAA2G;AAC3G,mFAAyE;AAIlE,IAAM,IAAI,GAAV,MAAM,IAAI;CA8BhB,CAAA;AA5BA;IAAC,IAAA,gCAAsB,GAAE;;gCACd;AAEX;IAAC,IAAA,gBAAM,G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AC9B,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACtC,CAAC;IAID,MAAM,CAAS,cAA+B;QAC7C,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IACjD,CAAC;IAGD,MAAM,CAAc,EAAU,EAAU,cAA8B;QACrE,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC;IACrD,CAAC;IAGD,MAAM,CAAc,EAAU;QAC7B,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACrC,CAAC;CACD,CAAA;AA1BA;IAAC,IAAA,YAAG,GAAE;IACG,WAAA,IAAA,cAAK,GAAE,CAAA;;;;8CAGf;AAED;IAAC,IAAA,YAAG,EAAC,KAAK,CAAC;IACF,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;;;;8CAEnB;AAED;IAAC,IAAA,aAAI,GAAE;IACN,IAAA,iBAAQ,EAAC,mBAAU,CAAC,IAAI,CAAC;IAClB,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAkB,iCAAc;;6CAE7C;AAED;IAAC,IAAA,cAAK,EAAC,KAAK,CAAC;IACL,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;IAAc,WAAA,IAAA,aAAI,GAAE,CAAA;;6CAAiB,iCAAc;;6CAErE;AAED;IAAC,IAAA,eAAM,EAAC,KAAK,CAAC;IACN,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;;;;6CAElB;AA5BW,eAAe;IAD3B,IAAA,mBAAU,EAAC,OAAO,CAAC;qCAEwB,4BAAY;GAD3C,eAAe,CA6B3B;AA7BY,0CAAe"}

View File

@@ -12,11 +12,12 @@ const users_service_1 = require("./users.service");
const users_controller_1 = require("./users.controller");
const user_entity_1 = require("./entities/user.entity");
const typeorm_1 = require("@nestjs/typeorm");
const friendship_entity_1 = require("../friendship/entities/friendship.entity");
let UsersModule = class UsersModule {
};
UsersModule = __decorate([
(0, common_1.Module)({
imports: [typeorm_1.TypeOrmModule.forFeature([user_entity_1.User])],
imports: [typeorm_1.TypeOrmModule.forFeature([user_entity_1.User, friendship_entity_1.Friendship,])],
providers: [users_service_1.UsersService],
exports: [users_service_1.UsersService],
controllers: [users_controller_1.UsersController],

View File

@@ -1 +1 @@
{"version":3,"file":"users.module.js","sourceRoot":"","sources":["../../src/users/users.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,mDAA+C;AAC/C,yDAAqD;AACrD,wDAA8C;AAC9C,6CAAgD;AAQzC,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,WAAW;IANvB,IAAA,eAAM,EAAC;QACP,OAAO,EAAE,CAAC,uBAAa,CAAC,UAAU,CAAC,CAAC,kBAAI,CAAC,CAAC,CAAC;QAC3C,SAAS,EAAE,CAAC,4BAAY,CAAC;QACzB,OAAO,EAAE,CAAC,4BAAY,CAAC;QACvB,WAAW,EAAE,CAAC,kCAAe,CAAC;KAC9B,CAAC;GACW,WAAW,CAAG;AAAd,kCAAW"}
{"version":3,"file":"users.module.js","sourceRoot":"","sources":["../../src/users/users.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,mDAA+C;AAC/C,yDAAqD;AACrD,wDAA8C;AAC9C,6CAAgD;AAChD,gFAAsE;AAQ/D,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,WAAW;IANvB,IAAA,eAAM,EAAC;QACP,OAAO,EAAE,CAAC,uBAAa,CAAC,UAAU,CAAC,CAAC,kBAAI,EAAE,8BAAU,EAAE,CAAC,CAAC;QACxD,SAAS,EAAE,CAAC,4BAAY,CAAC;QACzB,OAAO,EAAE,CAAC,4BAAY,CAAC;QACvB,WAAW,EAAE,CAAC,kCAAe,CAAC;KAC9B,CAAC;GACW,WAAW,CAAG;AAAd,kCAAW"}

View File

@@ -2,9 +2,11 @@ import { User } from './entities/user.entity';
import { Repository } from 'typeorm';
import { CreateUsersDto } from './dto/create-users.dto';
import { UpdateUsersDto } from './dto/update-users.dto';
import { Friendship } from '../friendship/entities/friendship.entity';
export declare class UsersService {
private readonly userRepository;
constructor(userRepository: Repository<User>);
private readonly friendshipRepository;
constructor(userRepository: Repository<User>, friendshipRepository: Repository<Friendship>);
findOne(id: string): Promise<User>;
findAll(): Promise<User[]>;
create(createUserDto: CreateUsersDto): Promise<User>;

View File

@@ -17,9 +17,11 @@ const common_1 = require("@nestjs/common");
const typeorm_1 = require("@nestjs/typeorm");
const user_entity_1 = require("./entities/user.entity");
const typeorm_2 = require("typeorm");
const friendship_entity_1 = require("../friendship/entities/friendship.entity");
let UsersService = class UsersService {
constructor(userRepository) {
constructor(userRepository, friendshipRepository) {
this.userRepository = userRepository;
this.friendshipRepository = friendshipRepository;
}
async findOne(id) {
const user = await this.userRepository.findOneBy({ id: +id });
@@ -52,7 +54,9 @@ let UsersService = class UsersService {
UsersService = __decorate([
(0, common_1.Injectable)(),
__param(0, (0, typeorm_1.InjectRepository)(user_entity_1.User)),
__metadata("design:paramtypes", [typeorm_2.Repository])
__param(1, (0, typeorm_1.InjectRepository)(friendship_entity_1.Friendship)),
__metadata("design:paramtypes", [typeorm_2.Repository,
typeorm_2.Repository])
], UsersService);
exports.UsersService = UsersService;
//# sourceMappingURL=users.service.js.map

View File

@@ -1 +1 @@
{"version":3,"file":"users.service.js","sourceRoot":"","sources":["../../src/users/users.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAsG;AACtG,6CAAmD;AAEnD,wDAA8C;AAC9C,qCAAqC;AAM9B,IAAM,YAAY,GAAlB,MAAM,YAAY;IAExB,YAEiB,cAAgC;QAAhC,mBAAc,GAAd,cAAc,CAAkB;IAC9C,CAAC;IAEJ,KAAK,CAAC,OAAO,CAAC,EAAU;QACvB,MAAM,IAAI,GAAI,MAAM,IAAI,CAAC,cAAc,CAAC,SA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CAAgC,EAAC,mBAAU,CAAC,SAAS,CAAC,CAAC;QAChF,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAU;QACtB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACpC,IAAI,CAAC,IAAI;YACR,MAAM,IAAI,sBAAa,CAAC,gCAAgC,EAAC,mBAAU,CAAC,SAAS,CAAC,CAAC;QAChF,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;CACD,CAAA;AA1CY,YAAY;IADxB,IAAA,mBAAU,GAAE;IAIX,WAAA,IAAA,0BAAgB,EAAC,kBAAI,CAAC,CAAA;IAEtB,WAAA,IAAA,0BAAgB,EAAC,8BAAU,CAAC,CAAA;qCADI,oBAAU;QAEJ,oBAAU;GANrC,YAAY,CA0CxB;AA1CY,oCAAY"}

View File

@@ -4,6 +4,9 @@ import { AppService } from './app.service';
import { UsersModule } from './users/users.module';
import { TypeOrmModule } from '@nestjs/typeorm';
import { ConfigModule } from '@nestjs/config';
import { FriendshipstatusesModule } from './friendship/friendshipstatuses/friendshipstatuses.module';
import { FriendshipController } from './friendship/friendship/friendship.controller';
import { Module } from './friendship/.module';
@Module({
@@ -21,8 +24,10 @@ import { ConfigModule } from '@nestjs/config';
//avec une classe pour le module
synchronize: true,
}),
FriendshipstatusesModule,
Module,
],
controllers: [AppController],
controllers: [AppController, FriendshipController],
providers: [AppService],
})
export class AppModule {}

View File

@@ -0,0 +1,11 @@
import { IsEnum, IsInt } from 'class-validator';
import { FriendshipStatus } from '../entities/friendship.entity';
export class CreateFriendshipDto {
@IsInt()
readonly requesterId: number;
@IsInt()
readonly addresseeId: number;
@IsEnum(FriendshipStatus)
readonly status: FriendshipStatus;
}

View File

@@ -0,0 +1,4 @@
import { PartialType } from "@nestjs/mapped-types";
import { CreateFriendshipDto } from "./create-friendship.dto";
export class UpdateFriendshipDto extends PartialType(CreateFriendshipDto){}

View File

@@ -0,0 +1,29 @@
import { Column, CreateDateColumn, Entity, ManyToOne, OneToMany, PrimaryColumn, PrimaryGeneratedColumn } from "typeorm";
import { User } from "../../users/entities/user.entity";
export enum FriendshipStatus {
REQUESTED = 'R',
ACCEPTED = 'A',
DECLINED = 'D',
BLOCKED = 'B',
}
@Entity('friendships')
export class Friendship {
@PrimaryGeneratedColumn()
id: number;
@CreateDateColumn()
date : Date;
@Column()
@ManyToOne(type => User, user => user.requesterId)
requesterId: number;
@Column()
@ManyToOne(type => User, user => user.addresseeId)
addresseeId: number;
@Column({ type: 'enum', enum: FriendshipStatus, default: FriendshipStatus.REQUESTED })
status: FriendshipStatus;
}

View File

@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { FriendshipController } from './friendship.controller';
describe('FriendshipController', () => {
let controller: FriendshipController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [FriendshipController],
}).compile();
controller = module.get<FriendshipController>(FriendshipController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});

View File

@@ -0,0 +1,4 @@
import { Controller } from '@nestjs/common';
@Controller('friendship')
export class FriendshipController {}

View File

@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { FriendshipService } from './friendship.service';
describe('FriendshipService', () => {
let service: FriendshipService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [FriendshipService],
}).compile();
service = module.get<FriendshipService>(FriendshipService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});

View File

@@ -0,0 +1,80 @@
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { User } from 'src/users/entities/user.entity';
import { Repository } from 'typeorm';
import { CreateFriendshipDto } from './dto/create-friendship.dto';
import { UpdateFriendshipDto } from './dto/update-friendship.dto';
import { Friendship, FriendshipStatus } from './entities/friendship.entity';
@Injectable()
export class FriendshipService {
constructor(
@InjectRepository(Friendship)
private readonly friendshipRepository: Repository<Friendship>,
@InjectRepository(User)
private readonly userRepository: Repository<User>,
) {}
async findOne(id: string) {
const friendship = await this.friendshipRepository.findOneBy({id: +id});
if (!friendship)
throw new HttpException(`The requested friendship not found.`,HttpStatus.NOT_FOUND);
return friendship;
}
async findAllFriends(id: string) {
const user = await this.userRepository.findOneBy({id: +id});
if (!user)
throw new HttpException(`The requested user not found.`,HttpStatus.NOT_FOUND);
const friends = await this.friendshipRepository.find({where: {requesterId: +id, status: FriendshipStatus.ACCEPTED}});
return friends;
}
async findAllBlockedFriends(id: string) {
const user = await this.userRepository.findOneBy({id: +id});
if (!user)
throw new HttpException(`The requested user not found.`,HttpStatus.NOT_FOUND);
const blocked = await this.friendshipRepository.find({where: {requesterId: +id, status: FriendshipStatus.BLOCKED}});
return blocked;
}
async create({requesterId, addresseeId, status }: CreateFriendshipDto) {
const requester = await this.userRepository.findOneBy({id : +requesterId});
if (!requester)
throw new HttpException(`The user does not exist.`,HttpStatus.NOT_FOUND);
const addressee = await this.userRepository.findOneBy({id: +addresseeId});
if (!addressee)
throw new HttpException(`The user does not exist.`,HttpStatus.NOT_FOUND);
if (requesterId == addresseeId)
throw new HttpException(`You can't add yourself.`,HttpStatus.NOT_FOUND);
const friendship = this.friendshipRepository.findOneBy({requesterId: +requesterId, addresseeId: +addresseeId});
if ((await friendship).status === 'R')
throw new HttpException(`The friendship request has already been sent the ${(await friendship).date}.`,HttpStatus.OK);
if ((await friendship).status === 'A')
throw new HttpException(`The friendship request has already been accepted.`,HttpStatus.OK);
if ((await friendship).status === 'D')
throw new HttpException(``,HttpStatus.OK);
if ((await friendship).status === 'B')
throw new HttpException(`The user does not exist.`,HttpStatus.OK);
const newFriendship = this.friendshipRepository.create({requesterId: +requesterId, addresseeId: +addresseeId, status: status});
return this.friendshipRepository.save(newFriendship);
}
async updateFriendship(id: string, updateFriendshipDto: UpdateFriendshipDto) {
const friendship = await this.friendshipRepository.preload(
{id: +id,
...updateFriendshipDto});
if (!friendship)
throw new HttpException(`The friendship could not be updated.`,HttpStatus.NOT_FOUND);
return this.friendshipRepository.save(friendship);
}
async removeFriendship(id: string) {
const friendship = await this.findOne(id);
if (!friendship)
throw new HttpException(`Your friend could not be deleted.`,HttpStatus.NOT_FOUND);
return this.friendshipRepository.remove(friendship);
}
}

View File

@@ -0,0 +1,14 @@
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { FriendshipService } from './friendship.service';
import { FriendshipController } from './friendship.controller';
import { Friendship } from './entities/friendship.entity';
import { User } from '../users/entities/user.entity';
@Module({
imports: [TypeOrmModule.forFeature([Friendship, User])],
providers: [FriendshipService],
controllers: [FriendshipController],
exports: [FriendshipService],
})
export class FriendshipsModule {}

View File

@@ -1,4 +1,4 @@
import { IsString } from 'class-validator';
import { IsEmail, IsString } from 'class-validator';
export class CreateUsersDto {
@IsString()
@@ -7,4 +7,6 @@ export class CreateUsersDto {
readonly username: string;
@IsString()
readonly password: string;
@IsEmail()
readonly email: string;
}

View File

@@ -1,14 +1,24 @@
import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";
import { type } from "os";
import { Column, Entity, JoinTable, ManyToMany, OneToMany, PrimaryGeneratedColumn, Unique } from "typeorm";
import { Friendship } from "../../friendship/entities/friendship.entity";
@Entity('users')
export class User {
@PrimaryGeneratedColumn()
id: number;
@Column()
name: string;
@Column()
username: string;
@Column()
email: string;
//Dans le cadre d'un tableau on peut faire :
// @Column('json', { nullable: true })
@Column()
@@ -16,4 +26,12 @@ export class User {
@Column('json', { nullable: true })
status: [string];
@JoinTable()
@OneToMany(type => Friendship , (friendship) => friendship.requesterId)
requesterId: Friendship[];
@JoinTable()
@OneToMany(type => Friendship , (friendship) => friendship.addresseeId)
addresseeId: Friendship[];
}

View File

@@ -7,6 +7,7 @@ import { UpdateUsersDto } from './dto/update-users.dto';
import { UsersService } from './users.service';
@Controller('users')
export class UsersController {
constructor(private readonly usersService: UsersService) {}

View File

@@ -3,9 +3,10 @@ import { UsersService } from './users.service';
import { UsersController } from './users.controller';
import { User } from './entities/user.entity';
import { TypeOrmModule } from '@nestjs/typeorm';
import { Friendship } from '../friendship/entities/friendship.entity';
@Module({
imports: [TypeOrmModule.forFeature([User])],
imports: [TypeOrmModule.forFeature([User, Friendship,])],
providers: [UsersService],
exports: [UsersService],
controllers: [UsersController],

View File

@@ -5,6 +5,7 @@ import { User } from './entities/user.entity';
import { Repository } from 'typeorm';
import { CreateUsersDto } from './dto/create-users.dto';
import { UpdateUsersDto } from './dto/update-users.dto';
import { Friendship } from '../friendship/entities/friendship.entity';
@Injectable()
@@ -13,6 +14,8 @@ export class UsersService {
constructor(
@InjectRepository(User)
private readonly userRepository: Repository<User>,
@InjectRepository(Friendship)
private readonly friendshipRepository: Repository<Friendship>,
) {}
async findOne(id: string) {
@@ -48,6 +51,4 @@ export class UsersService {
throw new HttpException(`The user could not be deleted.`,HttpStatus.NOT_FOUND);
return this.userRepository.remove(user);
}
}