ajout de routes basiques, à améliorer (certaines requêtes renvoient une erreur interne et pas un 404), ajout du service pour les relations amicales, mais pour l'instant c'est ultra pété
This commit is contained in:
@@ -13,13 +13,16 @@ 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");
|
||||
const friendships_module_1 = require("./friendship/friendships.module");
|
||||
const core_1 = require("@nestjs/core");
|
||||
const routes_1 = require("./routes/routes");
|
||||
let AppModule = class AppModule {
|
||||
};
|
||||
AppModule = __decorate([
|
||||
(0, common_1.Module)({
|
||||
imports: [users_module_1.UsersModule,
|
||||
friendships_module_1.FriendshipsModule,
|
||||
core_1.RouterModule.register(routes_1.routesForUsers),
|
||||
config_1.ConfigModule.forRoot(),
|
||||
typeorm_1.TypeOrmModule.forRoot({
|
||||
type: 'postgres',
|
||||
@@ -31,10 +34,8 @@ AppModule = __decorate([
|
||||
autoLoadEntities: true,
|
||||
synchronize: true,
|
||||
}),
|
||||
friendshipstatuses_module_1.FriendshipstatusesModule,
|
||||
common_1.Module,
|
||||
],
|
||||
controllers: [app_controller_1.AppController, friendship_controller_1.FriendshipController],
|
||||
controllers: [app_controller_1.AppController],
|
||||
providers: [app_service_1.AppService],
|
||||
})
|
||||
], AppModule);
|
||||
|
||||
@@ -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;AAC9C,yGAAqG;AACrG,yFAAqF;AAyB9E,IAAM,SAAS,GAAf,MAAM,SAAS;CAAG,CAAA;AAAZ,SAAS;IArBrB,IAAA,eAAM,EAAC;QACN,OAAO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AAO,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"}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { FriendshipStatus } from '../entities/friendship.entity';
|
||||
export declare class CreateFriendshipDto {
|
||||
readonly requesterId: number;
|
||||
readonly addresseeId: number;
|
||||
readonly requesterId: string;
|
||||
readonly addresseeId: string;
|
||||
readonly status: FriendshipStatus;
|
||||
}
|
||||
|
||||
@@ -15,15 +15,16 @@ const friendship_entity_1 = require("../entities/friendship.entity");
|
||||
class CreateFriendshipDto {
|
||||
}
|
||||
__decorate([
|
||||
(0, class_validator_1.IsInt)(),
|
||||
__metadata("design:type", Number)
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], CreateFriendshipDto.prototype, "requesterId", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsInt)(),
|
||||
__metadata("design:type", Number)
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], CreateFriendshipDto.prototype, "addresseeId", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsEnum)(friendship_entity_1.FriendshipStatus),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", String)
|
||||
], CreateFriendshipDto.prototype, "status", void 0);
|
||||
exports.CreateFriendshipDto = CreateFriendshipDto;
|
||||
|
||||
@@ -1 +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"}
|
||||
{"version":3,"file":"create-friendship.dto.js","sourceRoot":"","sources":["../../../src/friendship/dto/create-friendship.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAA4F;AAC5F,qEAAiE;AAEjE,MAAa,mBAAmB;CAQ/B;AAPA;IAAC,IAAA,0BAAQ,GAAE;;wDACkB;AAC7B;IAAC,IAAA,0BAAQ,GAAE;;wDACkB;AAC7B;IAAC,IAAA,wBAAM,EAAC,oCAAgB,CAAC;IACxB,IAAA,4BAAU,GAAE;;mDACqB;AAPnC,kDAQC"}
|
||||
@@ -7,7 +7,7 @@ export declare enum FriendshipStatus {
|
||||
export declare class Friendship {
|
||||
id: number;
|
||||
date: Date;
|
||||
requesterId: number;
|
||||
addresseeId: number;
|
||||
requesterId: string;
|
||||
addresseeId: string;
|
||||
status: FriendshipStatus;
|
||||
}
|
||||
|
||||
@@ -32,12 +32,12 @@ __decorate([
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)(),
|
||||
(0, typeorm_1.ManyToOne)(type => user_entity_1.User, user => user.requesterId),
|
||||
__metadata("design:type", Number)
|
||||
__metadata("design:type", String)
|
||||
], 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)
|
||||
__metadata("design:type", String)
|
||||
], Friendship.prototype, "addresseeId", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ type: 'enum', enum: FriendshipStatus, default: FriendshipStatus.REQUESTED }),
|
||||
|
||||
@@ -1 +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"}
|
||||
{"version":3,"file":"friendship.entity.js","sourceRoot":"","sources":["../../../src/friendship/entities/friendship.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,qCAAmI;AACnI,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;CAmBtB,CAAA;AAlBA;IAAC,IAAA,gCAAsB,GAAE;;sCACd;AAEX;IAAC,IAAA,0BAAgB,GAAE;8BACZ,IAAI;wCAAC;AAGZ;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;AAGpB;IAAC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,gBAAgB,CAAC,SAAS,EAAC,CAAC;;0CAC5D;AAlBb,UAAU;IADtB,IAAA,gBAAM,EAAC,aAAa,CAAC;GACT,UAAU,CAmBtB;AAnBY,gCAAU"}
|
||||
@@ -1,2 +1,15 @@
|
||||
import { CreateFriendshipDto } from './dto/create-friendship.dto';
|
||||
import { UpdateFriendshipDto } from './dto/update-friendship.dto';
|
||||
import { FriendshipService } from './friendship.service';
|
||||
export declare class FriendshipController {
|
||||
private readonly friendshipService;
|
||||
constructor(friendshipService: FriendshipService);
|
||||
findEmpty(userId: string): Promise<import("./entities/friendship.entity").Friendship[]>;
|
||||
findAllFriends(userId: string): Promise<import("./entities/friendship.entity").Friendship[]>;
|
||||
findAllBlocked(userId: string): Promise<import("./entities/friendship.entity").Friendship[]>;
|
||||
findAllPendant(userId: string): Promise<import("./entities/friendship.entity").Friendship[]>;
|
||||
findOneFriend(friendId: string): Promise<import("./entities/friendship.entity").Friendship[]>;
|
||||
create(createFriendshipDto: CreateFriendshipDto): Promise<import("./entities/friendship.entity").Friendship>;
|
||||
update(friendId: string, friendshipUpdateDto: UpdateFriendshipDto): Promise<import("./entities/friendship.entity").Friendship>;
|
||||
remove(friendId: string): Promise<import("./entities/friendship.entity").Friendship[]>;
|
||||
}
|
||||
|
||||
@@ -5,13 +5,108 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
||||
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.FriendshipController = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const create_friendship_dto_1 = require("./dto/create-friendship.dto");
|
||||
const update_friendship_dto_1 = require("./dto/update-friendship.dto");
|
||||
const friendship_service_1 = require("./friendship.service");
|
||||
let FriendshipController = class FriendshipController {
|
||||
constructor(friendshipService) {
|
||||
this.friendshipService = friendshipService;
|
||||
}
|
||||
findEmpty(userId) {
|
||||
return this.friendshipService.findAllFriends(userId);
|
||||
}
|
||||
findAllFriends(userId) {
|
||||
return this.friendshipService.findAllFriends(userId);
|
||||
}
|
||||
findAllBlocked(userId) {
|
||||
return this.friendshipService.findAllBlockedFriends(userId);
|
||||
}
|
||||
findAllPendant(userId) {
|
||||
return this.friendshipService.findAllPendantRequestsForFriendship(userId);
|
||||
}
|
||||
findOneFriend(friendId) {
|
||||
return this.friendshipService.findOneFriend(friendId);
|
||||
}
|
||||
create(createFriendshipDto) {
|
||||
return this.friendshipService.create(createFriendshipDto);
|
||||
}
|
||||
update(friendId, friendshipUpdateDto) {
|
||||
return this.friendshipService.updateFriendship(friendId, friendshipUpdateDto);
|
||||
}
|
||||
remove(friendId) {
|
||||
return this.friendshipService.removeFriendship(friendId);
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
(0, common_1.Get)(),
|
||||
__param(0, (0, common_1.Param)('userId')),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], FriendshipController.prototype, "findEmpty", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('friends'),
|
||||
__param(0, (0, common_1.Param)('userId')),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], FriendshipController.prototype, "findAllFriends", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('blocked'),
|
||||
__param(0, (0, common_1.Param)('userId')),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], FriendshipController.prototype, "findAllBlocked", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('pendant'),
|
||||
__param(0, (0, common_1.Param)('userId')),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], FriendshipController.prototype, "findAllPendant", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('friends/:friendId'),
|
||||
__param(0, (0, common_1.Param)('friendId')),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], FriendshipController.prototype, "findOneFriend", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)(),
|
||||
(0, common_1.HttpCode)(common_1.HttpStatus.CREATED),
|
||||
__param(0, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [create_friendship_dto_1.CreateFriendshipDto]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], FriendshipController.prototype, "create", null);
|
||||
__decorate([
|
||||
(0, common_1.Patch)(':friendId'),
|
||||
__param(0, (0, common_1.Param)('friendId')),
|
||||
__param(1, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String, update_friendship_dto_1.UpdateFriendshipDto]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], FriendshipController.prototype, "update", null);
|
||||
__decorate([
|
||||
(0, common_1.Delete)(':userId/:friendId'),
|
||||
__param(0, (0, common_1.Param)('friendId')),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], FriendshipController.prototype, "remove", null);
|
||||
FriendshipController = __decorate([
|
||||
(0, common_1.Controller)('friendship')
|
||||
(0, common_1.Controller)(),
|
||||
__metadata("design:paramtypes", [friendship_service_1.FriendshipService])
|
||||
], FriendshipController);
|
||||
exports.FriendshipController = FriendshipController;
|
||||
//# sourceMappingURL=friendship.controller.js.map
|
||||
@@ -1 +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"}
|
||||
{"version":3,"file":"friendship.controller.js","sourceRoot":"","sources":["../../src/friendship/friendship.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAwH;AAExH,uEAAkE;AAClE,uEAAkE;AAElE,6DAAyD;AAGlD,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAChC,YAA6B,iBAAoC;QAApC,sBAAiB,GAAjB,iBAAiB,CAAmB;IAAG,CAAC;IAGrE,SAAS,CAAkB,MAAc;QACxC,OAAO,IAAI,CAAC,iBAAiB,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IACtD,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,EAAC,mBAAmB,CAAC;IACV,WAAA,IAAA,cAAK,EAAC,UAAU,CAAC,CAAA;;;;yDAE/B;AAED;IAAC,IAAA,aAAI,GAAE;IACN,IAAA,iBAAQ,EAAC,mBAAU,CAAC,OAAO,CAAC;IACrB,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAsB,2CAAmB;;kDAEtD;AAED;IAAC,IAAA,cAAK,EAAC,WAAW,CAAC;IACX,WAAA,IAAA,cAAK,EAAC,UAAU,CAAC,CAAA;IAAoB,WAAA,IAAA,aAAI,GAAE,CAAA;;6CAAsB,2CAAmB;;kDAE3F;AAED;IAAC,IAAA,eAAM,EAAC,mBAAmB,CAAC;IACpB,WAAA,IAAA,cAAK,EAAC,UAAU,CAAC,CAAA;;;;kDAExB;AAzCW,oBAAoB;IADhC,IAAA,mBAAU,GAAE;qCAEoC,sCAAiB;GADrD,oBAAoB,CA0ChC;AA1CY,oDAAoB"}
|
||||
@@ -7,10 +7,12 @@ export declare class FriendshipService {
|
||||
private readonly friendshipRepository;
|
||||
private readonly userRepository;
|
||||
constructor(friendshipRepository: Repository<Friendship>, userRepository: Repository<User>);
|
||||
findOne(id: string): Promise<Friendship>;
|
||||
findOneFriend(id: string): Promise<Friendship[]>;
|
||||
findOneBlocked(id: string): Promise<Friendship[]>;
|
||||
findAllFriends(id: string): Promise<Friendship[]>;
|
||||
findAllBlockedFriends(id: string): Promise<Friendship[]>;
|
||||
create({ requesterId, addresseeId, status }: CreateFriendshipDto): Promise<Friendship>;
|
||||
findAllPendantRequestsForFriendship(id: string): Promise<Friendship[]>;
|
||||
create(createFriendshipDto: CreateFriendshipDto): Promise<Friendship>;
|
||||
updateFriendship(id: string, updateFriendshipDto: UpdateFriendshipDto): Promise<Friendship>;
|
||||
removeFriendship(id: string): Promise<Friendship>;
|
||||
removeFriendship(id: string): Promise<Friendship[]>;
|
||||
}
|
||||
|
||||
@@ -23,45 +23,62 @@ let FriendshipService = class FriendshipService {
|
||||
this.friendshipRepository = friendshipRepository;
|
||||
this.userRepository = userRepository;
|
||||
}
|
||||
async findOne(id) {
|
||||
const friendship = await this.friendshipRepository.findOneBy({ id: +id });
|
||||
async findOneFriend(id) {
|
||||
const friendship = await this.friendshipRepository.find({ where: { id: +id, status: friendship_entity_1.FriendshipStatus.ACCEPTED } });
|
||||
if (!friendship)
|
||||
throw new common_1.HttpException(`The requested friendship not found.`, common_1.HttpStatus.NOT_FOUND);
|
||||
throw new common_1.HttpException(`The requested friend not found.`, common_1.HttpStatus.NOT_FOUND);
|
||||
return friendship;
|
||||
}
|
||||
async findOneBlocked(id) {
|
||||
const friendship = await this.friendshipRepository.find({ where: { id: +id, status: friendship_entity_1.FriendshipStatus.BLOCKED } });
|
||||
if (!friendship)
|
||||
throw new common_1.HttpException(`The requested friend 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 } });
|
||||
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 } });
|
||||
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 });
|
||||
async findAllPendantRequestsForFriendship(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.REQUESTED } });
|
||||
return blocked;
|
||||
}
|
||||
async create(createFriendshipDto) {
|
||||
const requester = await this.userRepository.findOneBy({ id: +createFriendshipDto.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 });
|
||||
const addressee = await this.userRepository.findOneBy({ id: +createFriendshipDto.addresseeId });
|
||||
if (!addressee)
|
||||
throw new common_1.HttpException(`The user does not exist.`, common_1.HttpStatus.NOT_FOUND);
|
||||
if (requesterId == addresseeId)
|
||||
if (createFriendshipDto.requesterId == createFriendshipDto.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 });
|
||||
const friendship = await this.friendshipRepository.findOneBy({ requesterId: createFriendshipDto.requesterId, addresseeId: createFriendshipDto.addresseeId });
|
||||
if (friendship) {
|
||||
if (friendship.status && friendship.status === friendship_entity_1.FriendshipStatus.ACCEPTED)
|
||||
throw new common_1.HttpException(`The friendship request has already been accepted.`, common_1.HttpStatus.OK);
|
||||
else if (friendship.status && friendship.status === friendship_entity_1.FriendshipStatus.REQUESTED)
|
||||
throw new common_1.HttpException(`The friendship request has already been sent the ${friendship.date}.`, common_1.HttpStatus.OK);
|
||||
else if (friendship.status && friendship.status === friendship_entity_1.FriendshipStatus.BLOCKED)
|
||||
throw new common_1.HttpException(``, common_1.HttpStatus.OK);
|
||||
else if (friendship.status && friendship.status === friendship_entity_1.FriendshipStatus.DECLINED)
|
||||
throw new common_1.HttpException(`The request has been declined.`, common_1.HttpStatus.OK);
|
||||
}
|
||||
const newFriendship = this.friendshipRepository.create({ requesterId: createFriendshipDto.requesterId, addresseeId: createFriendshipDto.addresseeId, status: friendship_entity_1.FriendshipStatus.REQUESTED });
|
||||
const sendrquest = this.friendshipRepository.create({ requesterId: createFriendshipDto.requesterId, addresseeId: createFriendshipDto.addresseeId, status: friendship_entity_1.FriendshipStatus.REQUESTED });
|
||||
this.friendshipRepository.save(sendrquest);
|
||||
return this.friendshipRepository.save(newFriendship);
|
||||
}
|
||||
async updateFriendship(id, updateFriendshipDto) {
|
||||
@@ -71,7 +88,7 @@ let FriendshipService = class FriendshipService {
|
||||
return this.friendshipRepository.save(friendship);
|
||||
}
|
||||
async removeFriendship(id) {
|
||||
const friendship = await this.findOne(id);
|
||||
const friendship = await this.findOneFriend(id);
|
||||
if (!friendship)
|
||||
throw new common_1.HttpException(`Your friend could not be deleted.`, common_1.HttpStatus.NOT_FOUND);
|
||||
return this.friendshipRepository.remove(friendship);
|
||||
|
||||
@@ -1 +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;IAE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CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,EAAU;QAChC,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;QAChD,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;AA9FY,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,CA8F7B;AA9FY,8CAAiB"}
|
||||
2
srcs/requirements/nestjs/api_back/dist/routes/routes.d.ts
vendored
Normal file
2
srcs/requirements/nestjs/api_back/dist/routes/routes.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Routes } from "@nestjs/core";
|
||||
export declare const routesForUsers: Routes;
|
||||
18
srcs/requirements/nestjs/api_back/dist/routes/routes.js
vendored
Normal file
18
srcs/requirements/nestjs/api_back/dist/routes/routes.js
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.routesForUsers = void 0;
|
||||
const friendships_module_1 = require("../friendship/friendships.module");
|
||||
const users_module_1 = require("../users/users.module");
|
||||
exports.routesForUsers = [
|
||||
{
|
||||
path: '/users',
|
||||
module: users_module_1.UsersModule,
|
||||
children: [
|
||||
{
|
||||
path: '/:userId/mycontacts',
|
||||
module: friendships_module_1.FriendshipsModule,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
//# sourceMappingURL=routes.js.map
|
||||
1
srcs/requirements/nestjs/api_back/dist/routes/routes.js.map
vendored
Normal file
1
srcs/requirements/nestjs/api_back/dist/routes/routes.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../../src/routes/routes.ts"],"names":[],"mappings":";;;AACA,yEAAsE;AACtE,wDAAqD;AAExC,QAAA,cAAc,GAAW;IACrC;QACC,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,0BAAW;QACnB,QAAQ,EAAE;YACT;gBACC,IAAI,EAAE,qBAAqB;gBAC3B,MAAM,EAAE,sCAAiB;aACzB;SACD;KACD;CACD,CAAC"}
|
||||
File diff suppressed because one or more lines are too long
@@ -8,4 +8,5 @@ export declare class User {
|
||||
status: [string];
|
||||
requesterId: Friendship[];
|
||||
addresseeId: Friendship[];
|
||||
friendships: Friendship[];
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"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,GAAE;;kCACI;AAEb;IAAC,IAAA,gBAAM,GAAE;;sCACQ;AAGjB;IAAC,IAAA,gBAAM,GAAE;;mCACK;AAId;IAAC,IAAA,gBAAM,GAAE;;sCACQ;AAEjB;IAAC,IAAA,gBAAM,EAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;oCAClB;AAEjB;IAAC,IAAA,mBAAS,GAAE;IACX,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,8BAAU,EAAG,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC;;yCAC7C;AAE1B;IAAC,IAAA,mBAAS,GAAE;IACX,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,8BAAU,EAAG,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC;;yCAC7C;AA7Bd,IAAI;IADhB,IAAA,gBAAM,EAAC,OAAO,CAAC;GACH,IAAI,CA8BhB;AA9BY,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;CAgChB,CAAA;AA9BA;IAAC,IAAA,gCAAsB,GAAE;;gCACd;AAEX;IAAC,IAAA,gBAAM,GAAE;;kCACI;AAEb;IAAC,IAAA,gBAAM,GAAE;;sCACQ;AAGjB;IAAC,IAAA,gBAAM,GAAE;;mCACK;AAId;IAAC,IAAA,gBAAM,GAAE;;sCACQ;AAEjB;IAAC,IAAA,gBAAM,EAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;oCAClB;AAEjB;IAAC,IAAA,mBAAS,GAAE;IACX,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,8BAAU,EAAG,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC;;yCAC7C;AAE1B;IAAC,IAAA,mBAAS,GAAE;IACX,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,8BAAU,EAAG,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC;;yCAC7C;AA7Bd,IAAI;IADhB,IAAA,gBAAM,EAAC,OAAO,CAAC;GACH,IAAI,CAgChB;AAhCY,oBAAI"}
|
||||
@@ -38,7 +38,7 @@ let UsersController = class UsersController {
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
(0, common_1.Get)(),
|
||||
(0, common_1.Get)('all'),
|
||||
__param(0, (0, common_1.Query)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
@@ -75,7 +75,7 @@ __decorate([
|
||||
__metadata("design:returntype", void 0)
|
||||
], UsersController.prototype, "remove", null);
|
||||
UsersController = __decorate([
|
||||
(0, common_1.Controller)('users'),
|
||||
(0, common_1.Controller)('/'),
|
||||
__metadata("design:paramtypes", [users_service_1.UsersService])
|
||||
], UsersController);
|
||||
exports.UsersController = UsersController;
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"users.controller.js","sourceRoot":"","sources":["../../src/users/users.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAGwB;AACxB,6DAAwD;AACxD,6DAAwD;AAExD,mDAA+C;AAIxC,IAAM,eAAe,GAArB,MAAM,eAAe;IAC3B,YAA6B,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;IAAG,CAAC;IAG3D,OAAO,CAAU,KAAK;QAErB,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;IACpC,CAAC;IAGD,OAAO,CAAc,EAAU;QAC9B,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,mB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AA1BA;IAAC,IAAA,YAAG,EAAC,KAAK,CAAC;IACF,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;AA7BW,eAAe;IAD3B,IAAA,mBAAU,EAAC,GAAG,CAAC;qCAE4B,4BAAY;GAD3C,eAAe,CA8B3B;AA9BY,0CAAe"}
|
||||
@@ -18,12 +18,15 @@ 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");
|
||||
const class_validator_1 = require("class-validator");
|
||||
let UsersService = class UsersService {
|
||||
constructor(userRepository, friendshipRepository) {
|
||||
this.userRepository = userRepository;
|
||||
this.friendshipRepository = friendshipRepository;
|
||||
}
|
||||
async findOne(id) {
|
||||
if (!(0, class_validator_1.isNumberString)(id))
|
||||
throw new common_1.HttpException(`The requested user not found.`, common_1.HttpStatus.NOT_FOUND);
|
||||
const user = await this.userRepository.findOneBy({ id: +id });
|
||||
if (!user)
|
||||
throw new common_1.NotFoundException(`The requested user not found.`);
|
||||
@@ -32,7 +35,9 @@ let UsersService = class UsersService {
|
||||
findAll() {
|
||||
return this.userRepository.find();
|
||||
}
|
||||
create(createUserDto) {
|
||||
async create(createUserDto) {
|
||||
if (await this.userRepository.findOneBy({ email: createUserDto.email }))
|
||||
throw new common_1.HttpException(`The user already exists.`, common_1.HttpStatus.CONFLICT);
|
||||
const user = this.userRepository.create(createUserDto);
|
||||
if (!user)
|
||||
throw new common_1.HttpException(`The user could not be created.`, common_1.HttpStatus.NOT_FOUND);
|
||||
|
||||
@@ -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;AAGrC,gFAAsE;AAI/D,IAAM,YAAY,GAAlB,MAAM,YAAY;IAExB,YAEiB,cAAgC,EAEhC,oBAA4C;QAF5C,mBAAc,GAAd,cAAc,CAAkB;QAEhC,yBAAoB,GAApB,oBAAoB,CAAwB;IAC1D,CAAC;IAEJ,KAAK,CAAC,OAAO,CAAC,EAAU;QACvB,MAAM,IAAI,GAAI,MAAM,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,EAAC,EAAE,EAAE,CAAC,EAAE,EAAC,CAAC,CAAC;QAC7D,IAAI,CAAC,IAAI;YACR,MAAM,IAAI,0BAAiB,CAAC,+BAA+B,CAAC,CAAC;QAC9D,OAAO,IAAI,CAAC;IACb,CAAC;IAED,OAAO;QACN,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC;IACnC,CAAC;IAED,MAAM,CAAC,aAA6B;QACnC,MAAM,IAAI,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;QACvD,IAAI,CAAC,IAAI;YACR,MAAM,IAAI,sBAAa,CAAC,gCAAgC,EAAC,mBAAU,CAAC,SAAS,CAAC,CAAC;QAChF,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IAED,KAAK,CAAC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C,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;AA9CY,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,CA8CxB;AA9CY,oCAAY"}
|
||||
5
srcs/requirements/nestjs/api_back/node_modules/.package-lock.json
generated
vendored
5
srcs/requirements/nestjs/api_back/node_modules/.package-lock.json
generated
vendored
@@ -6347,6 +6347,11 @@
|
||||
"integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/nest-router": {
|
||||
"version": "1.0.9",
|
||||
"resolved": "https://registry.npmjs.org/nest-router/-/nest-router-1.0.9.tgz",
|
||||
"integrity": "sha512-ZyRdSVs9GczI+39B7tNXsxfBXQOYnEF6l/q2aLYG8wSEvRHRDXAlzZ1SIosDibM02pLahGkDNLFC+nZ8uzJGDQ=="
|
||||
},
|
||||
"node_modules/node-abort-controller": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/node-abort-controller/-/node-abort-controller-3.0.1.tgz",
|
||||
|
||||
142
srcs/requirements/nestjs/api_back/node_modules/nest-router/README.md
generated
vendored
Normal file
142
srcs/requirements/nestjs/api_back/node_modules/nest-router/README.md
generated
vendored
Normal file
@@ -0,0 +1,142 @@
|
||||
# Nest Router :vertical_traffic_light:
|
||||
|
||||
[](https://greenkeeper.io/) [](https://travis-ci.org/shekohex/nest-router) [](Https://www.npmjs.com/package/nest-router) [](https://coveralls.io/github/shekohex/nest-router?branch=master)
|
||||
|
||||
Router Module For [Nestjs](https://github.com/nestjs/nest) Framework
|
||||
|
||||
## Quick Overview
|
||||
|
||||
`RouterModule` helps you organize your routes and lets you create a routes tree.
|
||||
|
||||
### How ?
|
||||
|
||||
Every module could have a path property. That path will be a prefix for all controllers in this module. If that module has a parent, it will be a child of it and again all controllers in this child module will be prefixed by `parent module prefix` + `this module prefix`
|
||||
|
||||
> see issue [#255](https://github.com/nestjs/nest/issues/255) .
|
||||
|
||||
## Install
|
||||
|
||||
IMPORTANT: you need Nest > v4.5.10+
|
||||
|
||||
```bash
|
||||
npm install nest-router --save
|
||||
```
|
||||
|
||||
OR
|
||||
|
||||
```bash
|
||||
yarn add nest-router
|
||||
```
|
||||
|
||||
## Setup
|
||||
|
||||
See how easy it is to set up.
|
||||
|
||||
```ts
|
||||
... //imports
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: '/ninja',
|
||||
module: NinjaModule,
|
||||
children: [
|
||||
{
|
||||
path: '/cats',
|
||||
module: CatsModule,
|
||||
},
|
||||
{
|
||||
path: '/dogs',
|
||||
module: DogsModule,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
RouterModule.forRoutes(routes), // setup the routes
|
||||
CatsModule,
|
||||
DogsModule,
|
||||
NinjaModule
|
||||
], // as usual, nothing new
|
||||
})
|
||||
export class ApplicationModule {}
|
||||
```
|
||||
|
||||
> :+1: TIP: Keep all of your routes in a separate file like `routes.ts`
|
||||
|
||||
In this example, all the controllers in `NinjaModule` will be prefixed by `/ninja` and it
|
||||
has two childs, `CatsModule` and `DogsModule`.
|
||||
|
||||
Will the controllers of `CatsModule` be prefixed by `/cats`? NO!! :open_mouth:
|
||||
The `CatsModule` is a child of `NinjaModule` so it will be prefixed by `/ninja/cats/` instead.
|
||||
And so will `DogsModule`.
|
||||
|
||||
> See examples folder for more information.
|
||||
|
||||
#### Example Folder Project Structure
|
||||
|
||||
```bash
|
||||
.
|
||||
├── app.module.ts
|
||||
├── cats
|
||||
│ ├── cats.controller.ts
|
||||
│ ├── cats.module.ts
|
||||
│ └── ketty.controller.ts
|
||||
├── dogs
|
||||
│ ├── dogs.controller.ts
|
||||
│ ├── dogs.module.ts
|
||||
│ └── puppy.controller.ts
|
||||
├── main.ts
|
||||
└── ninja
|
||||
├── katana.controller.ts
|
||||
├── ninja.controller.ts
|
||||
└── ninja.module.ts
|
||||
```
|
||||
|
||||
And here is a simple, nice route tree of `example` folder:
|
||||
|
||||
```bash
|
||||
ninja
|
||||
├── /
|
||||
├── /katana
|
||||
├── cats
|
||||
│ ├── /
|
||||
│ └── /ketty
|
||||
├── dogs
|
||||
├── /
|
||||
└── /puppy
|
||||
```
|
||||
|
||||
Nice!
|
||||
|
||||
#### Resolve Full Controller Path:
|
||||
Nestjs dosen't resolve or take into account `MODULE_PATH` metadata when it is coming to resolve Controller path in Middlewear resolver for example, so that i introduced a new fancy method `RouterModule#resolvePath` that will resolve the full path of any controller so instead of doing so:
|
||||
|
||||
```ts
|
||||
consumer.apply(someMiddleware).forRoutes(SomeController);
|
||||
```
|
||||
you should do
|
||||
|
||||
```ts
|
||||
consumer.apply(someMiddleware).forRoutes(RouterModule.resolvePath(SomeController));
|
||||
```
|
||||
|
||||
see [#32](https://github.com/shekohex/nest-router/pull/32) for more information about this.
|
||||
|
||||
## CHANGELOG
|
||||
|
||||
See [CHANGELOG](CHANGELOG.md) for more information.
|
||||
|
||||
## Contributing
|
||||
|
||||
You are welcome to contribute to this project, just open a PR.
|
||||
|
||||
## Authors
|
||||
|
||||
* **Shady Khalifa** - _Initial work_
|
||||
|
||||
See also the list of [contributors](https://github.com/shekohex/nest-router/contributors) who participated in this project.
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.
|
||||
2
srcs/requirements/nestjs/api_back/node_modules/nest-router/index.d.ts
generated
vendored
Normal file
2
srcs/requirements/nestjs/api_back/node_modules/nest-router/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './router.module';
|
||||
export * from './routes.interface';
|
||||
7
srcs/requirements/nestjs/api_back/node_modules/nest-router/index.js
generated
vendored
Normal file
7
srcs/requirements/nestjs/api_back/node_modules/nest-router/index.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__export(require("./router.module"));
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
srcs/requirements/nestjs/api_back/node_modules/nest-router/index.js.map
generated
vendored
Normal file
1
srcs/requirements/nestjs/api_back/node_modules/nest-router/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,qCAAgC"}
|
||||
42
srcs/requirements/nestjs/api_back/node_modules/nest-router/package.json
generated
vendored
Normal file
42
srcs/requirements/nestjs/api_back/node_modules/nest-router/package.json
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "nest-router",
|
||||
"version": "1.0.9",
|
||||
"description": "Router Module For Nestjs Framework",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "jest --notify --config=jest.json",
|
||||
"test:watch": "jest --watch --config=jest.json",
|
||||
"test:coverage": "jest --config=jest.json --coverage --coverageDirectory=coverage",
|
||||
"build": "./scripts/build.sh",
|
||||
"build:andMove": "./scripts/build.sh andMove",
|
||||
"npm:publish": "cd lib && npm publish"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/shekohex/nest-router.git"
|
||||
},
|
||||
"keywords": [
|
||||
"nestjs",
|
||||
"router",
|
||||
"addons"
|
||||
],
|
||||
"author": "Shady Khalifa <shekohex@gmail.com>",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@nestjs/common": "^5.0.0",
|
||||
"@nestjs/core": "^5.0.0",
|
||||
"@nestjs/testing": "^5.3.11",
|
||||
"@types/jest": "^23.0.0",
|
||||
"@types/node": "^10.0.3",
|
||||
"coveralls": "^3.0.2",
|
||||
"jest": "^23.6.0",
|
||||
"reflect-metadata": "^0.1.12",
|
||||
"rxjs": "^6.3.0",
|
||||
"ts-jest": "^23.10.2",
|
||||
"typescript": "^3.0.0"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/shekohex/nest-router/issues"
|
||||
},
|
||||
"homepage": "https://github.com/shekohex/nest-router#readme"
|
||||
}
|
||||
24
srcs/requirements/nestjs/api_back/node_modules/nest-router/router.module.d.ts
generated
vendored
Normal file
24
srcs/requirements/nestjs/api_back/node_modules/nest-router/router.module.d.ts
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import { DynamicModule } from '@nestjs/common';
|
||||
import { ModulesContainer } from '@nestjs/core/injector/modules-container';
|
||||
import { Controller, Type } from '@nestjs/common/interfaces';
|
||||
import { Routes } from './routes.interface';
|
||||
/**
|
||||
* A utility Module to Organize your Routes,
|
||||
* it could be imported in the Root Module of you application.
|
||||
*/
|
||||
export declare class RouterModule {
|
||||
readonly modulesContainer: ModulesContainer;
|
||||
private static readonly routesContainer;
|
||||
constructor(modulesContainer: ModulesContainer);
|
||||
/**
|
||||
* takes an array of modules and organize them in hierarchy way
|
||||
* @param {Routes} routes Array of Routes
|
||||
*/
|
||||
static forRoutes(routes: Routes): DynamicModule;
|
||||
/**
|
||||
* get the controller full route path eg: (controller's module prefix + controller's path).
|
||||
* @param {Type<Controller>} controller the controller you need to get it's full path
|
||||
*/
|
||||
static resolvePath(controller: Type<Controller>): string;
|
||||
private static buildPathMap;
|
||||
}
|
||||
71
srcs/requirements/nestjs/api_back/node_modules/nest-router/router.module.js
generated
vendored
Normal file
71
srcs/requirements/nestjs/api_back/node_modules/nest-router/router.module.js
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
"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 });
|
||||
var RouterModule_1;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const constants_1 = require("@nestjs/common/constants");
|
||||
const modules_container_1 = require("@nestjs/core/injector/modules-container");
|
||||
const unknown_element_exception_1 = require("@nestjs/core/errors/exceptions/unknown-element.exception");
|
||||
const validate_path_util_1 = require("./utils/validate-path.util");
|
||||
const flat_routes_util_1 = require("./utils/flat-routes.util");
|
||||
/**
|
||||
* A utility Module to Organize your Routes,
|
||||
* it could be imported in the Root Module of you application.
|
||||
*/
|
||||
let RouterModule = RouterModule_1 = class RouterModule {
|
||||
constructor(modulesContainer) {
|
||||
this.modulesContainer = modulesContainer;
|
||||
const modules = [...modulesContainer.values()];
|
||||
for (const nestModule of modules) {
|
||||
const modulePath = Reflect.getMetadata(constants_1.MODULE_PATH, nestModule.metatype);
|
||||
for (const route of nestModule.routes.values()) {
|
||||
RouterModule_1.routesContainer.set(route.name, validate_path_util_1.validatePath(modulePath));
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* takes an array of modules and organize them in hierarchy way
|
||||
* @param {Routes} routes Array of Routes
|
||||
*/
|
||||
static forRoutes(routes) {
|
||||
RouterModule_1.buildPathMap(routes);
|
||||
return {
|
||||
module: RouterModule_1,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* get the controller full route path eg: (controller's module prefix + controller's path).
|
||||
* @param {Type<Controller>} controller the controller you need to get it's full path
|
||||
*/
|
||||
static resolvePath(controller) {
|
||||
const controllerPath = Reflect.getMetadata(constants_1.PATH_METADATA, controller);
|
||||
const modulePath = RouterModule_1.routesContainer.get(controller.name);
|
||||
if (modulePath && controllerPath) {
|
||||
return validate_path_util_1.validatePath(modulePath + validate_path_util_1.validatePath(controllerPath));
|
||||
}
|
||||
else {
|
||||
throw new unknown_element_exception_1.UnknownElementException();
|
||||
}
|
||||
}
|
||||
static buildPathMap(routes) {
|
||||
const flattenRoutes = flat_routes_util_1.flatRoutes(routes);
|
||||
flattenRoutes.forEach(route => {
|
||||
Reflect.defineMetadata(constants_1.MODULE_PATH, validate_path_util_1.validatePath(route.path), route.module);
|
||||
});
|
||||
}
|
||||
};
|
||||
RouterModule.routesContainer = new Map();
|
||||
RouterModule = RouterModule_1 = __decorate([
|
||||
common_1.Module({}),
|
||||
__metadata("design:paramtypes", [modules_container_1.ModulesContainer])
|
||||
], RouterModule);
|
||||
exports.RouterModule = RouterModule;
|
||||
//# sourceMappingURL=router.module.js.map
|
||||
1
srcs/requirements/nestjs/api_back/node_modules/nest-router/router.module.js.map
generated
vendored
Normal file
1
srcs/requirements/nestjs/api_back/node_modules/nest-router/router.module.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"router.module.js","sourceRoot":"","sources":["../src/router.module.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAuD;AACvD,wDAAsE;AACtE,+EAA2E;AAE3E,wGAAmG;AACnG,mEAA0D;AAC1D,+DAAsD;AAGtD;;;GAGG;AAEH,IAAa,Y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,iCAAY,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAC9E,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AA1CyB,4BAAe,GAAwB,IAAI,GAAG,EAAE,CAAC;AAD9D,YAAY;IADxB,eAAM,CAAC,EAAE,CAAC;qCAG8B,oCAAgB;GAF5C,YAAY,CA2CxB;AA3CY,oCAAY"}
|
||||
24
srcs/requirements/nestjs/api_back/node_modules/nest-router/routes.interface.d.ts
generated
vendored
Normal file
24
srcs/requirements/nestjs/api_back/node_modules/nest-router/routes.interface.d.ts
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import { Type } from '@nestjs/common';
|
||||
/**
|
||||
* Defines the Routes Tree
|
||||
* - `path` - a string describe the Module path which will be applied
|
||||
* to all it's controllers and childs
|
||||
* - `module` - the parent Module.
|
||||
* - `children` - an array of child Modules.
|
||||
* - `childrens` @deprecated - @see children
|
||||
*/
|
||||
export interface Route {
|
||||
path: string;
|
||||
module?: Type<any> | string;
|
||||
childrens?: Routes | Type<any>[] | string[];
|
||||
children?: Routes | Type<any>[] | string[];
|
||||
}
|
||||
/**
|
||||
* Defines the Routes Tree
|
||||
* - `path` - a string describe the Module path which will be applied
|
||||
* to all it's controllers and childs
|
||||
* - `module` - the parent Module.
|
||||
* - `children` - an array of child Modules.
|
||||
* - `childrens` @deprecated - @see children
|
||||
*/
|
||||
export declare type Routes = Route[];
|
||||
3
srcs/requirements/nestjs/api_back/node_modules/nest-router/routes.interface.js
generated
vendored
Normal file
3
srcs/requirements/nestjs/api_back/node_modules/nest-router/routes.interface.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=routes.interface.js.map
|
||||
1
srcs/requirements/nestjs/api_back/node_modules/nest-router/routes.interface.js.map
generated
vendored
Normal file
1
srcs/requirements/nestjs/api_back/node_modules/nest-router/routes.interface.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"routes.interface.js","sourceRoot":"","sources":["../src/routes.interface.ts"],"names":[],"mappings":""}
|
||||
2
srcs/requirements/nestjs/api_back/node_modules/nest-router/utils/flat-routes.util.d.ts
generated
vendored
Normal file
2
srcs/requirements/nestjs/api_back/node_modules/nest-router/utils/flat-routes.util.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Routes } from '../routes.interface';
|
||||
export declare function flatRoutes(routes: Routes): any[];
|
||||
35
srcs/requirements/nestjs/api_back/node_modules/nest-router/utils/flat-routes.util.js
generated
vendored
Normal file
35
srcs/requirements/nestjs/api_back/node_modules/nest-router/utils/flat-routes.util.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const util_1 = require("util");
|
||||
const validate_path_util_1 = require("./validate-path.util");
|
||||
const result = [];
|
||||
function flatRoutes(routes) {
|
||||
routes.forEach(element => {
|
||||
if (element.module && element.path) {
|
||||
result.push(element);
|
||||
}
|
||||
// this block will be removed soon
|
||||
if (!element.children && element.childrens) {
|
||||
element.children = element.childrens;
|
||||
console.log(`\x1b[33m%s\x1b[0m`, `WARNING: 'childrens' is deprecated, use 'children' instead.`);
|
||||
}
|
||||
if (element.children) {
|
||||
const childrenRef = element.children;
|
||||
childrenRef.forEach(child => {
|
||||
if (!util_1.isString(child) && child.path) {
|
||||
child.path = validate_path_util_1.validatePath(validate_path_util_1.validatePath(element.path) + validate_path_util_1.validatePath(child.path));
|
||||
}
|
||||
else {
|
||||
result.push({ path: element.path, module: child });
|
||||
}
|
||||
});
|
||||
return flatRoutes(childrenRef);
|
||||
}
|
||||
});
|
||||
result.forEach(route => {
|
||||
delete route.children;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
exports.flatRoutes = flatRoutes;
|
||||
//# sourceMappingURL=flat-routes.util.js.map
|
||||
1
srcs/requirements/nestjs/api_back/node_modules/nest-router/utils/flat-routes.util.js.map
generated
vendored
Normal file
1
srcs/requirements/nestjs/api_back/node_modules/nest-router/utils/flat-routes.util.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"flat-routes.util.js","sourceRoot":"","sources":["../../src/utils/flat-routes.util.ts"],"names":[],"mappings":";;AAAA,+BAAgC;AAEhC,6DAAoD;AAEpD,MAAM,MAAM,GAAG,EAAE,CAAC;AAClB,SAAgB,UAAU,CAAC,MAAc;IACvC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QACvB,IAAI,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,IAAI,EAAE;YAClC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SACtB;QACD,kCAAkC;QAClC,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,SAAS,EAAE;YAC1C,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC;YACrC,OAAO,CAAC,GAAG,CACT,mBAAmB,EACnB,6DAA6D,CAC9D,CAAC;SACH;QACD,IAAI,OAAO,CAAC,QAAQ,EAAE;YACpB,MAAM,WAAW,GAAG,OAAO,CAAC,QAAkB,CAAC;YAC/C,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;gBAC1B,IAAI,CAAC,eAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,EAAE;oBAClC,KAAK,CAAC,IAAI,GAAG,iCAAY,CAAC,iCAAY,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,iCAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;iBAClF;qBAAM;oBACL,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;iBACpD;YACH,CAAC,CAAC,CAAC;YACH,OAAO,UAAU,CAAC,WAAW,CAAC,CAAC;SAChC;IACH,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACrB,OAAO,KAAK,CAAC,QAAQ,CAAC;IACxB,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC;AA7BD,gCA6BC"}
|
||||
1
srcs/requirements/nestjs/api_back/node_modules/nest-router/utils/validate-path.util.d.ts
generated
vendored
Normal file
1
srcs/requirements/nestjs/api_back/node_modules/nest-router/utils/validate-path.util.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare const validatePath: (path: string) => string;
|
||||
8
srcs/requirements/nestjs/api_back/node_modules/nest-router/utils/validate-path.util.js
generated
vendored
Normal file
8
srcs/requirements/nestjs/api_back/node_modules/nest-router/utils/validate-path.util.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.validatePath = (path) => path
|
||||
? path.startsWith('/')
|
||||
? ('/' + path.replace(/\/+$/, '')).replace(/\/+/g, '/')
|
||||
: '/' + path.replace(/\/+$/, '')
|
||||
: '/';
|
||||
//# sourceMappingURL=validate-path.util.js.map
|
||||
1
srcs/requirements/nestjs/api_back/node_modules/nest-router/utils/validate-path.util.js.map
generated
vendored
Normal file
1
srcs/requirements/nestjs/api_back/node_modules/nest-router/utils/validate-path.util.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"validate-path.util.js","sourceRoot":"","sources":["../../src/utils/validate-path.util.ts"],"names":[],"mappings":";;AAAa,QAAA,YAAY,GAAG,CAAC,IAAY,EAAU,EAAE,CACnD,IAAI;IACF,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;QACpB,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;QACvD,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;IAClC,CAAC,CAAC,GAAG,CAAC"}
|
||||
11
srcs/requirements/nestjs/api_back/package-lock.json
generated
11
srcs/requirements/nestjs/api_back/package-lock.json
generated
@@ -19,6 +19,7 @@
|
||||
"@types/validator": "^13.7.9",
|
||||
"class-transformer": "^0.5.1",
|
||||
"class-validator": "^0.13.2",
|
||||
"nest-router": "^1.0.9",
|
||||
"passport": "^0.6.0",
|
||||
"passport-local": "^1.0.0",
|
||||
"pg": "^8.8.0",
|
||||
@@ -6409,6 +6410,11 @@
|
||||
"integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/nest-router": {
|
||||
"version": "1.0.9",
|
||||
"resolved": "https://registry.npmjs.org/nest-router/-/nest-router-1.0.9.tgz",
|
||||
"integrity": "sha512-ZyRdSVs9GczI+39B7tNXsxfBXQOYnEF6l/q2aLYG8wSEvRHRDXAlzZ1SIosDibM02pLahGkDNLFC+nZ8uzJGDQ=="
|
||||
},
|
||||
"node_modules/node-abort-controller": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/node-abort-controller/-/node-abort-controller-3.0.1.tgz",
|
||||
@@ -13823,6 +13829,11 @@
|
||||
"integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==",
|
||||
"dev": true
|
||||
},
|
||||
"nest-router": {
|
||||
"version": "1.0.9",
|
||||
"resolved": "https://registry.npmjs.org/nest-router/-/nest-router-1.0.9.tgz",
|
||||
"integrity": "sha512-ZyRdSVs9GczI+39B7tNXsxfBXQOYnEF6l/q2aLYG8wSEvRHRDXAlzZ1SIosDibM02pLahGkDNLFC+nZ8uzJGDQ=="
|
||||
},
|
||||
"node-abort-controller": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/node-abort-controller/-/node-abort-controller-3.0.1.tgz",
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
"@types/validator": "^13.7.9",
|
||||
"class-transformer": "^0.5.1",
|
||||
"class-validator": "^0.13.2",
|
||||
"nest-router": "^1.0.9",
|
||||
"passport": "^0.6.0",
|
||||
"passport-local": "^1.0.0",
|
||||
"pg": "^8.8.0",
|
||||
|
||||
@@ -4,13 +4,14 @@ 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';
|
||||
|
||||
import { FriendshipsModule } from './friendship/friendships.module';
|
||||
import { RouterModule } from '@nestjs/core';
|
||||
import { routesForUsers } from './routes/routes';
|
||||
|
||||
@Module({
|
||||
imports: [UsersModule,
|
||||
FriendshipsModule,
|
||||
RouterModule.register(routesForUsers),
|
||||
ConfigModule.forRoot(),
|
||||
TypeOrmModule.forRoot({
|
||||
type: 'postgres',
|
||||
@@ -24,10 +25,8 @@ import { Module } from './friendship/.module';
|
||||
//avec une classe pour le module
|
||||
synchronize: true,
|
||||
}),
|
||||
FriendshipstatusesModule,
|
||||
Module,
|
||||
],
|
||||
controllers: [AppController, FriendshipController],
|
||||
controllers: [AppController],
|
||||
providers: [AppService],
|
||||
})
|
||||
export class AppModule {}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { IsEnum, IsInt } from 'class-validator';
|
||||
import { IsEnum, IsInt, IsNumber, IsOptional, IsPositive, IsString } from 'class-validator';
|
||||
import { FriendshipStatus } from '../entities/friendship.entity';
|
||||
|
||||
export class CreateFriendshipDto {
|
||||
@IsInt()
|
||||
readonly requesterId: number;
|
||||
@IsInt()
|
||||
readonly addresseeId: number;
|
||||
@IsString()
|
||||
readonly requesterId: string;
|
||||
@IsString()
|
||||
readonly addresseeId: string;
|
||||
@IsEnum(FriendshipStatus)
|
||||
@IsOptional()
|
||||
readonly status: FriendshipStatus;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Column, CreateDateColumn, Entity, ManyToOne, OneToMany, PrimaryColumn, PrimaryGeneratedColumn } from "typeorm";
|
||||
import { IsOptional } from "class-validator";
|
||||
import { Column, CreateDateColumn, Entity, JoinTable, ManyToOne, OneToMany, PrimaryColumn, PrimaryGeneratedColumn } from "typeorm";
|
||||
import { User } from "../../users/entities/user.entity";
|
||||
|
||||
export enum FriendshipStatus {
|
||||
@@ -16,14 +17,16 @@ export class Friendship {
|
||||
@CreateDateColumn()
|
||||
date : Date;
|
||||
|
||||
|
||||
@Column()
|
||||
@ManyToOne(type => User, user => user.requesterId)
|
||||
requesterId: number;
|
||||
requesterId: string;
|
||||
|
||||
@Column()
|
||||
@ManyToOne(type => User, user => user.addresseeId)
|
||||
addresseeId: number;
|
||||
addresseeId: string;
|
||||
|
||||
@Column({ type: 'enum', enum: FriendshipStatus, default: FriendshipStatus.REQUESTED })
|
||||
|
||||
@Column({ type: 'enum', enum: FriendshipStatus, default: FriendshipStatus.REQUESTED})
|
||||
status: FriendshipStatus;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,51 @@
|
||||
import { Controller } from '@nestjs/common';
|
||||
import { Body, Controller, Delete, Get, HttpCode, HttpException, HttpStatus, Param, Patch, Post } from '@nestjs/common';
|
||||
import { CreateUsersDto } from 'src/users/dto/create-users.dto';
|
||||
import { CreateFriendshipDto } from './dto/create-friendship.dto';
|
||||
import { UpdateFriendshipDto } from './dto/update-friendship.dto';
|
||||
import { FriendshipStatus } from './entities/friendship.entity';
|
||||
import { FriendshipService } from './friendship.service';
|
||||
|
||||
@Controller('friendship')
|
||||
export class FriendshipController {}
|
||||
@Controller()
|
||||
export class FriendshipController {
|
||||
constructor(private readonly friendshipService: FriendshipService) {}
|
||||
|
||||
@Get()
|
||||
findEmpty(@Param('userId') userId: string) {
|
||||
return this.friendshipService.findAllFriends(userId);
|
||||
}
|
||||
@Get('friends')
|
||||
findAllFriends(@Param('userId') userId: string) {
|
||||
return this.friendshipService.findAllFriends(userId);
|
||||
}
|
||||
|
||||
@Get('blocked')
|
||||
findAllBlocked(@Param('userId') userId: string) {
|
||||
return this.friendshipService.findAllBlockedFriends(userId);
|
||||
}
|
||||
|
||||
@Get('pendant')
|
||||
findAllPendant(@Param('userId') userId: string) {
|
||||
return this.friendshipService.findAllPendantRequestsForFriendship(userId);
|
||||
}
|
||||
|
||||
@Get('friends/:friendId')
|
||||
findOneFriend(@Param('friendId') friendId: string) {
|
||||
return this.friendshipService.findOneFriend(friendId);
|
||||
}
|
||||
|
||||
@Post()
|
||||
@HttpCode(HttpStatus.CREATED)
|
||||
create(@Body() createFriendshipDto: CreateFriendshipDto) {
|
||||
return this.friendshipService.create(createFriendshipDto);
|
||||
}
|
||||
|
||||
@Patch(':friendId')
|
||||
update(@Param('friendId') friendId: string, @Body() friendshipUpdateDto: UpdateFriendshipDto) {
|
||||
return this.friendshipService.updateFriendship(friendId, friendshipUpdateDto);
|
||||
}
|
||||
|
||||
@Delete(':userId/:friendId')
|
||||
remove(@Param('friendId') friendId: string) {
|
||||
return this.friendshipService.removeFriendship(friendId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
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 { Any, Repository } from 'typeorm';
|
||||
import { CreateFriendshipDto } from './dto/create-friendship.dto';
|
||||
import { UpdateFriendshipDto } from './dto/update-friendship.dto';
|
||||
import { Friendship, FriendshipStatus } from './entities/friendship.entity';
|
||||
@@ -17,10 +17,17 @@ export class FriendshipService {
|
||||
) {}
|
||||
|
||||
|
||||
async findOne(id: string) {
|
||||
const friendship = await this.friendshipRepository.findOneBy({id: +id});
|
||||
async findOneFriend(id: string) {
|
||||
const friendship = await this.friendshipRepository.find({where: {id: +id, status: FriendshipStatus.ACCEPTED}});
|
||||
if (!friendship)
|
||||
throw new HttpException(`The requested friendship not found.`,HttpStatus.NOT_FOUND);
|
||||
throw new HttpException(`The requested friend not found.`,HttpStatus.NOT_FOUND);
|
||||
return friendship;
|
||||
}
|
||||
|
||||
async findOneBlocked(id: string) {
|
||||
const friendship = await this.friendshipRepository.find({where: {id: +id, status: FriendshipStatus.BLOCKED}});
|
||||
if (!friendship)
|
||||
throw new HttpException(`The requested friend not found.`,HttpStatus.NOT_FOUND);
|
||||
return friendship;
|
||||
}
|
||||
|
||||
@@ -28,7 +35,8 @@ export class FriendshipService {
|
||||
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}});
|
||||
const friends = await this.friendshipRepository.find(
|
||||
{where: {requesterId: id, status: FriendshipStatus.ACCEPTED}});
|
||||
return friends;
|
||||
}
|
||||
|
||||
@@ -36,29 +44,45 @@ export class FriendshipService {
|
||||
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}});
|
||||
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});
|
||||
async findAllPendantRequestsForFriendship(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.REQUESTED}});
|
||||
return blocked;
|
||||
}
|
||||
|
||||
async create(createFriendshipDto: CreateFriendshipDto) {
|
||||
const requester = await this.userRepository.findOneBy({id : +createFriendshipDto.requesterId});
|
||||
if (!requester)
|
||||
throw new HttpException(`The user does not exist.`,HttpStatus.NOT_FOUND);
|
||||
const addressee = await this.userRepository.findOneBy({id: +addresseeId});
|
||||
const addressee = await this.userRepository.findOneBy({id: +createFriendshipDto.addresseeId});
|
||||
if (!addressee)
|
||||
throw new HttpException(`The user does not exist.`,HttpStatus.NOT_FOUND);
|
||||
if (requesterId == addresseeId)
|
||||
if (createFriendshipDto.requesterId == createFriendshipDto.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});
|
||||
const friendship = await this.friendshipRepository.findOneBy({requesterId: createFriendshipDto.requesterId, addresseeId: createFriendshipDto.addresseeId});
|
||||
if (friendship) {
|
||||
if (friendship.status && friendship.status === FriendshipStatus.ACCEPTED)
|
||||
throw new HttpException(`The friendship request has already been accepted.`,HttpStatus.OK);
|
||||
else if (friendship.status && friendship.status === FriendshipStatus.REQUESTED)
|
||||
throw new HttpException(`The friendship request has already been sent the ${friendship.date}.`,HttpStatus.OK);
|
||||
else if (friendship.status && friendship.status === FriendshipStatus.BLOCKED)
|
||||
throw new HttpException(``,HttpStatus.OK);
|
||||
else if (friendship.status && friendship.status === FriendshipStatus.DECLINED)
|
||||
throw new HttpException(`The request has been declined.`,HttpStatus.OK);
|
||||
}
|
||||
const newFriendship = this.friendshipRepository.create(
|
||||
{requesterId: createFriendshipDto.requesterId, addresseeId: createFriendshipDto.addresseeId, status: FriendshipStatus.REQUESTED});
|
||||
const sendrquest = this.friendshipRepository.create(
|
||||
{requesterId: createFriendshipDto.requesterId, addresseeId: createFriendshipDto.addresseeId, status: FriendshipStatus.REQUESTED});
|
||||
this.friendshipRepository.save(sendrquest);
|
||||
return this.friendshipRepository.save(newFriendship);
|
||||
}
|
||||
|
||||
@@ -72,7 +96,7 @@ export class FriendshipService {
|
||||
}
|
||||
|
||||
async removeFriendship(id: string) {
|
||||
const friendship = await this.findOne(id);
|
||||
const friendship = await this.findOneFriend(id);
|
||||
if (!friendship)
|
||||
throw new HttpException(`Your friend could not be deleted.`,HttpStatus.NOT_FOUND);
|
||||
return this.friendshipRepository.remove(friendship);
|
||||
|
||||
16
srcs/requirements/nestjs/api_back/src/routes/routes.ts
Normal file
16
srcs/requirements/nestjs/api_back/src/routes/routes.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { Routes } from "@nestjs/core";
|
||||
import { FriendshipsModule } from "src/friendship/friendships.module";
|
||||
import { UsersModule } from "src/users/users.module";
|
||||
|
||||
export const routesForUsers: Routes = [
|
||||
{
|
||||
path: '/users',
|
||||
module: UsersModule,
|
||||
children: [
|
||||
{
|
||||
path: '/:userId/mycontacts',
|
||||
module: FriendshipsModule,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -34,4 +34,6 @@ export class User {
|
||||
@JoinTable()
|
||||
@OneToMany(type => Friendship , (friendship) => friendship.addresseeId)
|
||||
addresseeId: Friendship[];
|
||||
|
||||
friendships: Friendship[];
|
||||
}
|
||||
|
||||
@@ -8,11 +8,12 @@ import { UpdateUsersDto } from './dto/update-users.dto';
|
||||
import { UsersService } from './users.service';
|
||||
|
||||
|
||||
@Controller('users')
|
||||
@Controller('/')
|
||||
export class UsersController {
|
||||
constructor(private readonly usersService: UsersService) {}
|
||||
// par exemple dans postamn ou insomnia http://localhost:3000/users?limit=10&offset=20
|
||||
@Get()
|
||||
|
||||
@Get('all')
|
||||
findAll(@Query() query) {
|
||||
//const { limit, offset } = query;
|
||||
return this.usersService.findAll();
|
||||
|
||||
@@ -2,12 +2,14 @@ import { HttpCode, HttpException, HttpStatus, Injectable, NotFoundException, }
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { NotFoundError } from 'rxjs';
|
||||
import { User } from './entities/user.entity';
|
||||
import { Repository } from 'typeorm';
|
||||
import { ConnectionOptionsReader, Repository } from 'typeorm';
|
||||
import { CreateUsersDto } from './dto/create-users.dto';
|
||||
import { UpdateUsersDto } from './dto/update-users.dto';
|
||||
import { Friendship } from '../friendship/entities/friendship.entity';
|
||||
import { isNumberString } from 'class-validator';
|
||||
|
||||
|
||||
// On va devoir sûrement trouver un moyen plus simple pour passer l'id, sûrement via des pipes
|
||||
// ou des interceptors, mais pour l'instant on va faire comme ça.
|
||||
@Injectable()
|
||||
export class UsersService {
|
||||
|
||||
@@ -19,6 +21,8 @@ export class UsersService {
|
||||
) {}
|
||||
|
||||
async findOne(id: string) {
|
||||
if (!isNumberString(id))
|
||||
throw new HttpException(`The requested user not found.`,HttpStatus.NOT_FOUND);
|
||||
const user = await this.userRepository.findOneBy({id: +id});
|
||||
if (!user)
|
||||
throw new NotFoundException(`The requested user not found.`);
|
||||
@@ -29,7 +33,9 @@ export class UsersService {
|
||||
return this.userRepository.find();
|
||||
}
|
||||
|
||||
create(createUserDto: CreateUsersDto) {
|
||||
async create(createUserDto: CreateUsersDto) {
|
||||
if (await this.userRepository.findOneBy({email: createUserDto.email}))
|
||||
throw new HttpException(`The user already exists.`,HttpStatus.CONFLICT);
|
||||
const user = this.userRepository.create(createUserDto);
|
||||
if (!user)
|
||||
throw new HttpException(`The user could not be created.`,HttpStatus.NOT_FOUND);
|
||||
|
||||
Reference in New Issue
Block a user