86 lines
3.3 KiB
JavaScript
86 lines
3.3 KiB
JavaScript
"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 });
|
|
const core_1 = require("@nestjs/core");
|
|
const common_1 = require("@nestjs/common");
|
|
const prisma_service_1 = require("./prisma.service");
|
|
require("dotenv/config");
|
|
let AppController = class AppController {
|
|
getHello() {
|
|
return 'Travel Planning API is running!';
|
|
}
|
|
};
|
|
__decorate([
|
|
(0, common_1.Get)(),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", []),
|
|
__metadata("design:returntype", String)
|
|
], AppController.prototype, "getHello", null);
|
|
AppController = __decorate([
|
|
(0, common_1.Controller)()
|
|
], AppController);
|
|
let TourController = class TourController {
|
|
constructor(prisma) {
|
|
this.prisma = prisma;
|
|
}
|
|
async getTourDetails(id) {
|
|
const tour = await this.prisma.tour.findUnique({
|
|
where: { id },
|
|
include: {
|
|
members: true,
|
|
photos: true,
|
|
legs: {
|
|
orderBy: { sequenceNumber: 'asc' },
|
|
include: {
|
|
places: { orderBy: { sequenceInLeg: 'asc' } },
|
|
expenses: true,
|
|
},
|
|
},
|
|
},
|
|
});
|
|
if (!tour)
|
|
throw new common_1.NotFoundException(`Không tìm thấy Tour với ID ${id}`);
|
|
return tour;
|
|
}
|
|
};
|
|
__decorate([
|
|
(0, common_1.Get)(':id'),
|
|
__param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [Number]),
|
|
__metadata("design:returntype", Promise)
|
|
], TourController.prototype, "getTourDetails", null);
|
|
TourController = __decorate([
|
|
(0, common_1.Controller)('api/v1/tours'),
|
|
__metadata("design:paramtypes", [prisma_service_1.PrismaService])
|
|
], TourController);
|
|
let AppModule = class AppModule {
|
|
};
|
|
AppModule = __decorate([
|
|
(0, common_1.Module)({
|
|
controllers: [AppController, TourController],
|
|
providers: [prisma_service_1.PrismaService],
|
|
exports: [prisma_service_1.PrismaService]
|
|
})
|
|
], AppModule);
|
|
async function bootstrap() {
|
|
const app = await core_1.NestFactory.create(AppModule);
|
|
app.enableCors();
|
|
app.setGlobalPrefix('api');
|
|
const port = process.env.PORT || 3001;
|
|
await app.listen(port);
|
|
console.log(`🚀 Server is running on: http://localhost:${port}`);
|
|
}
|
|
bootstrap();
|
|
//# sourceMappingURL=main.js.map
|