build: add TypeScript configuration and generate declaration files
- Add tsconfig.json for TypeScript compilation with declaration and source map generation - Generate .d.ts declaration files for all modules, services, controllers, and models - Update package.json with NestJS dependencies and TypeScript development tools - Include database files in the distribution output for persistence
This commit is contained in:
120
dist/app.controller.js
vendored
Normal file
120
dist/app.controller.js
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
"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.AppController = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const local_auth_guard_1 = require("./auth/guards/local-auth.guard");
|
||||
const users_service_1 = require("./users/users.service");
|
||||
let AppController = class AppController {
|
||||
constructor(usersService) {
|
||||
this.usersService = usersService;
|
||||
}
|
||||
root(req, res) {
|
||||
if (req.isAuthenticated()) {
|
||||
return res.redirect('/dashboard');
|
||||
}
|
||||
else {
|
||||
return res.redirect('/login');
|
||||
}
|
||||
}
|
||||
login() {
|
||||
return {};
|
||||
}
|
||||
loginPost(res) {
|
||||
res.redirect('/dashboard');
|
||||
}
|
||||
register() {
|
||||
return {};
|
||||
}
|
||||
async registerPost(body, res, req) {
|
||||
const { username, password, name } = body;
|
||||
try {
|
||||
const existingUser = await this.usersService.findOne(username);
|
||||
if (existingUser) {
|
||||
req.flash('error', 'Username already exists');
|
||||
return res.redirect('/register');
|
||||
}
|
||||
await this.usersService.create({ username, password, name });
|
||||
req.flash('success_msg', 'You are now registered and can log in');
|
||||
res.redirect('/login');
|
||||
}
|
||||
catch (err) {
|
||||
console.error(err);
|
||||
req.flash('error', 'Error registering user');
|
||||
res.redirect('/register');
|
||||
}
|
||||
}
|
||||
logout(req, res) {
|
||||
req.logout((err) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
}
|
||||
req.flash('success_msg', 'You are logged out');
|
||||
res.redirect('/login');
|
||||
});
|
||||
}
|
||||
};
|
||||
exports.AppController = AppController;
|
||||
__decorate([
|
||||
(0, common_1.Get)(),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__param(1, (0, common_1.Res)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object, Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AppController.prototype, "root", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('login'),
|
||||
(0, common_1.Render)('login'),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AppController.prototype, "login", null);
|
||||
__decorate([
|
||||
(0, common_1.UseGuards)(local_auth_guard_1.LocalAuthGuard),
|
||||
(0, common_1.Post)('login'),
|
||||
__param(0, (0, common_1.Res)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AppController.prototype, "loginPost", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('register'),
|
||||
(0, common_1.Render)('register'),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AppController.prototype, "register", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('register'),
|
||||
__param(0, (0, common_1.Body)()),
|
||||
__param(1, (0, common_1.Res)()),
|
||||
__param(2, (0, common_1.Req)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object, Object, Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], AppController.prototype, "registerPost", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('logout'),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__param(1, (0, common_1.Res)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object, Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AppController.prototype, "logout", null);
|
||||
exports.AppController = AppController = __decorate([
|
||||
(0, common_1.Controller)(),
|
||||
__metadata("design:paramtypes", [users_service_1.UsersService])
|
||||
], AppController);
|
||||
//# sourceMappingURL=app.controller.js.map
|
||||
Reference in New Issue
Block a user