create admins endpoint

This commit is contained in:
Errormacr
2023-11-18 20:41:14 +03:00
parent 6bf6886826
commit 5c0b94e09e
59 changed files with 704 additions and 3 deletions

2
backend/dist/config/datasource.d.ts vendored Normal file
View File

@@ -0,0 +1,2 @@
import { DataSource } from "typeorm";
export declare const db: DataSource;

17
backend/dist/config/datasource.js vendored Normal file
View File

@@ -0,0 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.db = void 0;
const typeorm_1 = require("typeorm");
exports.db = new typeorm_1.DataSource({
type: 'postgres',
host: process.env.DATABASE_HOST || 'localhost',
port: +process.env.DATABASE_PORT || 5432,
username: process.env.DATABASE_USERNAME || 'postgres',
password: process.env.DATABASE_PASSWORD || '',
database: process.env.DATABASE_DB || 'bot_db',
synchronize: true,
logging: false,
entities: ['/libs/database/*.ts'],
migrations: ['/libs/migrations/*.ts']
});
//# sourceMappingURL=datasource.js.map

1
backend/dist/config/datasource.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"datasource.js","sourceRoot":"","sources":["../../config/datasource.ts"],"names":[],"mappings":";;;AAAA,qCAAqC;AACxB,QAAA,EAAE,GAAG,IAAI,oBAAU,CAAC;IAC7B,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,WAAW;IAC9C,IAAI,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,IAAI;IACxC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,UAAU;IACrD,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,EAAE;IAC7C,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,QAAQ;IAC7C,WAAW,EAAE,IAAI;IACjB,OAAO,EAAE,KAAK;IACd,QAAQ,EAAE,CAAC,qBAAqB,CAAC;IACjC,UAAU,EAAE,CAAC,uBAAuB,CAAC;CACxC,CAAC,CAAC"}

16
backend/dist/config/index.d.ts vendored Normal file
View File

@@ -0,0 +1,16 @@
export declare const config: {
database: {
type: string;
host: string;
port: number;
username: string;
password: string;
database: string;
synchronize: boolean;
logging: boolean;
autoLoadEntities: boolean;
};
server: {
port: number;
};
};

22
backend/dist/config/index.js vendored Normal file
View File

@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.config = void 0;
const dotenv_1 = require("dotenv");
(0, dotenv_1.config)();
exports.config = {
database: {
type: 'postgres',
host: process.env.DATABASE_HOST || 'localhost',
port: +process.env.DATABASE_PORT || 5432,
username: process.env.DATABASE_USERNAME || 'postgres',
password: process.env.DATABASE_PASSWORD || '',
database: process.env.DATABASE_DB || 'bot_db',
synchronize: true,
logging: false,
autoLoadEntities: true,
},
server: {
port: +process.env.SERVER_PORT || 8080,
},
};
//# sourceMappingURL=index.js.map

1
backend/dist/config/index.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../config/index.ts"],"names":[],"mappings":";;;AAAA,mCAA8C;AAE9C,IAAA,eAAU,GAAE,CAAC;AAEA,QAAA,MAAM,GAAG;IAClB,QAAQ,EAAE;QACN,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,WAAW;QAC9C,IAAI,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,IAAI;QACxC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,UAAU;QACrD,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,EAAE;QAC7C,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,QAAQ;QAC7C,WAAW,EAAE,IAAI;QACjB,OAAO,EAAE,KAAK;QACd,gBAAgB,EAAE,IAAI;KACzB;IACD,MAAM,EAAE;QACJ,IAAI,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,IAAI;KACzC;CACJ,CAAC"}

View File

@@ -0,0 +1,4 @@
export declare class Admin {
constructor(props?: Partial<Admin>);
id: string;
}

View File

@@ -0,0 +1,28 @@
"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.Admin = void 0;
const typeorm_1 = require("typeorm");
let Admin = class Admin {
constructor(props) {
Object.assign(this, props);
}
};
exports.Admin = Admin;
__decorate([
(0, typeorm_1.PrimaryColumn)(),
__metadata("design:type", String)
], Admin.prototype, "id", void 0);
exports.Admin = Admin = __decorate([
(0, typeorm_1.Entity)(),
__metadata("design:paramtypes", [Object])
], Admin);
//# sourceMappingURL=admin.entity.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"admin.entity.js","sourceRoot":"","sources":["../../../libs/database/admin.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAwD;AAGjD,IAAM,KAAK,GAAX,MAAM,KAAK;IACd,YAAY,KAAsB;QAC9B,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC/B,CAAC;CAKJ,CAAA;AARY,sBAAK;AAMP;IADN,IAAA,uBAAa,GAAE;;iCACG;gBANV,KAAK;IADjB,IAAA,gBAAM,GAAE;;GACI,KAAK,CAQjB"}

View File

@@ -0,0 +1,5 @@
export declare class User {
constructor(props?: Partial<User>);
id: string;
user_name: string;
}

View File

@@ -0,0 +1,32 @@
"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.User = void 0;
const typeorm_1 = require("typeorm");
let User = class User {
constructor(props) {
Object.assign(this, props);
}
};
exports.User = User;
__decorate([
(0, typeorm_1.PrimaryColumn)(),
__metadata("design:type", String)
], User.prototype, "id", void 0);
__decorate([
(0, typeorm_1.Column)({ nullable: true }),
__metadata("design:type", String)
], User.prototype, "user_name", void 0);
exports.User = User = __decorate([
(0, typeorm_1.Entity)(),
__metadata("design:paramtypes", [Object])
], User);
//# sourceMappingURL=user.entity.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"user.entity.js","sourceRoot":"","sources":["../../../libs/database/user.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAwD;AAGjD,IAAM,IAAI,GAAV,MAAM,IAAI;IACb,YAAY,KAAqB;QAC7B,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC/B,CAAC;CAOJ,CAAA;AAVY,oBAAI;AAMN;IADN,IAAA,uBAAa,GAAE;;gCACG;AAGZ;IADN,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;uCACF;eAThB,IAAI;IADhB,IAAA,gBAAM,GAAE;;GACI,IAAI,CAUhB"}

2
backend/dist/libs/libs.module.d.ts vendored Normal file
View File

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

23
backend/dist/libs/libs.module.js vendored Normal file
View File

@@ -0,0 +1,23 @@
"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.LibsModule = void 0;
const common_1 = require("@nestjs/common");
const typeorm_1 = require("@nestjs/typeorm");
const user_entity_1 = require("./database/user.entity");
const admin_entity_1 = require("./database/admin.entity");
let LibsModule = class LibsModule {
};
exports.LibsModule = LibsModule;
exports.LibsModule = LibsModule = __decorate([
(0, common_1.Module)({
imports: [typeorm_1.TypeOrmModule.forFeature([user_entity_1.User, admin_entity_1.Admin])],
exports: [typeorm_1.TypeOrmModule],
})
], LibsModule);
//# sourceMappingURL=libs.module.js.map

1
backend/dist/libs/libs.module.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"libs.module.js","sourceRoot":"","sources":["../../libs/libs.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,6CAAgD;AAChD,wDAA8C;AAC9C,0DAAgD;AAKzC,IAAM,UAAU,GAAhB,MAAM,UAAU;CAAG,CAAA;AAAb,gCAAU;qBAAV,UAAU;IAJtB,IAAA,eAAM,EAAC;QACJ,OAAO,EAAE,CAAC,uBAAa,CAAC,UAAU,CAAC,CAAC,kBAAI,EAAC,oBAAK,CAAC,CAAC,CAAC;QACjD,OAAO,EAAE,CAAC,uBAAa,CAAC;KAC3B,CAAC;GACW,UAAU,CAAG"}

View File

@@ -0,0 +1,7 @@
import { AdminService } from './admin.service';
export declare class AdminController {
private adminService;
constructor(adminService: AdminService);
getAdmin(): Promise<import("../../libs/database/admin.entity").Admin[]>;
isAdmin(id: string): Promise<boolean>;
}

View File

@@ -0,0 +1,53 @@
"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.AdminController = void 0;
const common_1 = require("@nestjs/common");
const swagger_1 = require("@nestjs/swagger");
const admin_service_1 = require("./admin.service");
let AdminController = class AdminController {
constructor(adminService) {
this.adminService = adminService;
}
async getAdmin() {
return await this.adminService.getAdmins();
}
async isAdmin(id) {
return await this.adminService.checkIsAdmin(id);
}
};
exports.AdminController = AdminController;
__decorate([
(0, swagger_1.ApiOperation)({
description: 'Get admins from db',
}),
(0, common_1.Get)('get'),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], AdminController.prototype, "getAdmin", null);
__decorate([
(0, swagger_1.ApiOperation)({ description: 'Check admin is or not' }),
(0, common_1.Get)('is_admin/:id'),
__param(0, (0, common_1.Param)('id')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:returntype", Promise)
], AdminController.prototype, "isAdmin", null);
exports.AdminController = AdminController = __decorate([
(0, swagger_1.ApiTags)('Admin'),
(0, common_1.Controller)('Admin'),
__metadata("design:paramtypes", [admin_service_1.AdminService])
], AdminController);
//# sourceMappingURL=admin.controller.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"admin.controller.js","sourceRoot":"","sources":["../../../src/admin/admin.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAwD;AACxD,6CAAwD;AACxD,mDAA+C;AAIxC,IAAM,eAAe,GAArB,MAAM,eAAe;IACxB,YAAoB,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;IAAG,CAAC;IAM5C,AAAN,KAAK,CAAC,QAAQ;QACV,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,CAAC;IAC/C,CAAC;IAGK,AAAN,KAAK,CAAC,OAAO,CAAc,EAAU;QACjC,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;IACpD,CAAC;CACJ,CAAA;AAfY,0CAAe;AAOlB;IAJL,IAAA,sBAAY,EAAC;QACV,WAAW,EAAE,oBAAoB;KACpC,CAAC;IACD,IAAA,YAAG,EAAC,KAAK,CAAC;;;;+CAGV;AAGK;IAFL,IAAA,sBAAY,EAAC,EAAE,WAAW,EAAE,uBAAuB,EAAE,CAAC;IACtD,IAAA,YAAG,EAAC,cAAc,CAAC;IACL,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;;;;8CAEzB;0BAdQ,eAAe;IAF3B,IAAA,iBAAO,EAAC,OAAO,CAAC;IAChB,IAAA,mBAAU,EAAC,OAAO,CAAC;qCAEkB,4BAAY;GADrC,eAAe,CAe3B"}

3
backend/dist/src/admin/admin.dto.d.ts vendored Normal file
View File

@@ -0,0 +1,3 @@
export declare class IGetAdmin {
readonly id: string;
}

21
backend/dist/src/admin/admin.dto.js vendored Normal file
View File

@@ -0,0 +1,21 @@
"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.IGetAdmin = void 0;
const swagger_1 = require("@nestjs/swagger");
class IGetAdmin {
}
exports.IGetAdmin = IGetAdmin;
__decorate([
(0, swagger_1.ApiProperty)({ description: 'telegram id', example: '123456' }),
__metadata("design:type", String)
], IGetAdmin.prototype, "id", void 0);
//# sourceMappingURL=admin.dto.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"admin.dto.js","sourceRoot":"","sources":["../../../src/admin/admin.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA8C;AAE9C,MAAa,SAAS;CAErB;AAFD,8BAEC;AAD4E;IAAxE,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,aAAa,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;;qCAAqB"}

View File

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

24
backend/dist/src/admin/admin.module.js vendored Normal file
View File

@@ -0,0 +1,24 @@
"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.AdminModule = void 0;
const common_1 = require("@nestjs/common");
const libs_module_1 = require("../../libs/libs.module");
const admin_controller_1 = require("./admin.controller");
const admin_service_1 = require("./admin.service");
let AdminModule = class AdminModule {
};
exports.AdminModule = AdminModule;
exports.AdminModule = AdminModule = __decorate([
(0, common_1.Module)({
imports: [libs_module_1.LibsModule],
controllers: [admin_controller_1.AdminController],
providers: [admin_service_1.AdminService],
})
], AdminModule);
//# sourceMappingURL=admin.module.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"admin.module.js","sourceRoot":"","sources":["../../../src/admin/admin.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,wDAA8C;AAC9C,yDAAqD;AACrD,mDAA+C;AAOxC,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,kCAAW;sBAAX,WAAW;IALvB,IAAA,eAAM,EAAC;QACJ,OAAO,EAAE,CAAC,wBAAU,CAAC;QACrB,WAAW,EAAE,CAAC,kCAAe,CAAC;QAC9B,SAAS,EAAE,CAAC,4BAAY,CAAC;KAC5B,CAAC;GACW,WAAW,CAAG"}

View File

@@ -0,0 +1,9 @@
import { Repository } from 'typeorm';
import { Admin } from 'libs/database/admin.entity';
export declare class AdminService {
private adminRepository;
private readonly logger;
constructor(adminRepository: Repository<Admin>);
getAdmins(): Promise<Admin[]>;
checkIsAdmin(id: string): Promise<boolean>;
}

58
backend/dist/src/admin/admin.service.js vendored Normal file
View File

@@ -0,0 +1,58 @@
"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); }
};
var AdminService_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AdminService = void 0;
const common_1 = require("@nestjs/common");
const typeorm_1 = require("@nestjs/typeorm");
const typeorm_2 = require("typeorm");
const admin_entity_1 = require("../../libs/database/admin.entity");
let AdminService = AdminService_1 = class AdminService {
constructor(adminRepository) {
this.adminRepository = adminRepository;
this.logger = new common_1.Logger(AdminService_1.name);
}
async getAdmins() {
try {
this.logger.debug(`[admin.getAdmins]`);
let admins = await this.adminRepository.find();
return admins;
}
catch (error) {
this.logger.log(`[getAdmin] ${JSON.stringify({ error })}`);
}
}
async checkIsAdmin(id) {
try {
this.logger.debug(`[admin.checkIsAdmin]`);
let admins = await this.adminRepository.findOne({
where: { id: id },
});
if (!admins) {
return false;
}
return true;
}
catch (error) {
this.logger.log(`[checkIsAdmin] ${JSON.stringify({ error })}`);
}
}
};
exports.AdminService = AdminService;
exports.AdminService = AdminService = AdminService_1 = __decorate([
(0, common_1.Injectable)(),
__param(0, (0, typeorm_1.InjectRepository)(admin_entity_1.Admin)),
__metadata("design:paramtypes", [typeorm_2.Repository])
], AdminService);
//# sourceMappingURL=admin.service.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"admin.service.js","sourceRoot":"","sources":["../../../src/admin/admin.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,6CAAmD;AACnD,qCAAqC;AACrC,mEAAmD;AAG5C,IAAM,YAAY,oBAAlB,MAAM,YAAY;IAErB,YAAqC,eAA0C;QAAlC,oBAAe,GAAf,eAAe,CAAmB;QAD9D,WAAM,GAAW,IAAI,eAAM,CAAC,cAAY,CAAC,IAAI,CAAC,CAAC;IACkB,CAAC;IAEnF,KAAK,CAAC,SAAS;QACX,IAAI;YACA,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;YACvC,IAAI,MAAM,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;YAC/C,OAAO,MAAM,CAAC;SACjB;QAAC,OAAO,KAAK,EAAE;YACZ,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,cAAc,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;SAC9D;IACL,CAAC;IACD,KAAK,CAAC,YAAY,CAAC,EAAU;QACzB,IAAI;YACA,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC;YAC1C,IAAI,MAAM,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC;gBAC5C,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;aACpB,CAAC,CAAC;YACH,IAAI,CAAC,MAAM,EAAE;gBACT,OAAO,KAAK,CAAA;aACf;YACD,OAAO,IAAI,CAAC;SACf;QAAC,OAAO,KAAK,EAAE;YACZ,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,kBAAkB,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;SAClE;IACL,CAAC;CACJ,CAAA;AA3BY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,mBAAU,GAAE;IAGI,WAAA,IAAA,0BAAgB,EAAC,oBAAK,CAAC,CAAA;qCAA0B,oBAAU;GAF/D,YAAY,CA2BxB"}

2
backend/dist/src/app.module.d.ts vendored Normal file
View File

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

27
backend/dist/src/app.module.js vendored Normal file
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.AppModule = void 0;
const common_1 = require("@nestjs/common");
const typeorm_1 = require("@nestjs/typeorm");
const config_1 = require("../config");
const libs_module_1 = require("../libs/libs.module");
const app_init_service_1 = require("./modules/initialization/app.init.service");
const user_module_1 = require("./modules/user/user.module");
const admin_module_1 = require("./admin/admin.module");
let AppModule = class AppModule {
};
exports.AppModule = AppModule;
exports.AppModule = AppModule = __decorate([
(0, common_1.Module)({
imports: [libs_module_1.LibsModule, user_module_1.UserModule, admin_module_1.AdminModule, typeorm_1.TypeOrmModule.forRoot(config_1.config.database)],
controllers: [],
providers: [app_init_service_1.AppInitService],
})
], AppModule);
//# sourceMappingURL=app.module.js.map

1
backend/dist/src/app.module.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../../src/app.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,6CAAsE;AACtE,sCAAgC;AAChC,qDAA8C;AAC9C,gFAA2E;AAC3E,4DAAwD;AACxD,uDAAmD;AAO5C,IAAM,SAAS,GAAf,MAAM,SAAS;CAAG,CAAA;AAAZ,8BAAS;oBAAT,SAAS;IALrB,IAAA,eAAM,EAAC;QACJ,OAAO,EAAE,CAAC,wBAAU,EAAE,wBAAU,EAAE,0BAAW,EAAE,uBAAa,CAAC,OAAO,CAAuB,eAAM,CAAC,QAAQ,CAAC,CAAC;QAC5G,WAAW,EAAE,EAAE;QACf,SAAS,EAAE,CAAC,iCAAc,CAAC;KAC9B,CAAC;GACW,SAAS,CAAG"}

1
backend/dist/src/main.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
export {};

16
backend/dist/src/main.js vendored Normal file
View File

@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const common_1 = require("@nestjs/common");
const core_1 = require("@nestjs/core");
const config_1 = require("../config");
const app_module_1 = require("./app.module");
const swagger_1 = require("./swagger");
async function bootstrap() {
const app = await core_1.NestFactory.create(app_module_1.AppModule, {
logger: ['log', 'debug', 'error', 'warn', 'verbose'],
});
(0, swagger_1.swagger)(app);
await app.listen(config_1.config.server.port, () => common_1.Logger.log(`Server started on port ${config_1.config.server.port}`));
}
bootstrap();
//# sourceMappingURL=main.js.map

1
backend/dist/src/main.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":";;AAAA,2CAAwC;AACxC,uCAA2C;AAC3C,sCAAgC;AAChC,6CAAyC;AACzC,uCAAoC;AAEpC,KAAK,UAAU,SAAS;IACpB,MAAM,GAAG,GAAG,MAAM,kBAAW,CAAC,MAAM,CAAC,sBAAS,EAAE;QAC5C,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC;KACvD,CAAC,CAAC;IACH,IAAA,iBAAO,EAAC,GAAG,CAAC,CAAC;IACb,MAAM,GAAG,CAAC,MAAM,CAAC,eAAM,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,eAAM,CAAC,GAAG,CAAC,0BAA0B,eAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AAC3G,CAAC;AACD,SAAS,EAAE,CAAC"}

View File

@@ -0,0 +1,10 @@
import { OnModuleInit } from '@nestjs/common';
import { Admin } from 'libs/database/admin.entity';
import { User } from 'libs/database/user.entity';
import { Repository } from 'typeorm';
export declare class AppInitService implements OnModuleInit {
private userRepository;
private adminRepository;
constructor(userRepository: Repository<User>, adminRepository: Repository<Admin>);
onModuleInit(): Promise<void>;
}

View File

@@ -0,0 +1,36 @@
"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.AppInitService = void 0;
const common_1 = require("@nestjs/common");
const typeorm_1 = require("@nestjs/typeorm");
const admin_entity_1 = require("../../../libs/database/admin.entity");
const user_entity_1 = require("../../../libs/database/user.entity");
const typeorm_2 = require("typeorm");
let AppInitService = class AppInitService {
constructor(userRepository, adminRepository) {
this.userRepository = userRepository;
this.adminRepository = adminRepository;
}
async onModuleInit() { }
};
exports.AppInitService = AppInitService;
exports.AppInitService = AppInitService = __decorate([
(0, common_1.Injectable)(),
__param(0, (0, typeorm_1.InjectRepository)(user_entity_1.User)),
__param(1, (0, typeorm_1.InjectRepository)(admin_entity_1.Admin)),
__metadata("design:paramtypes", [typeorm_2.Repository,
typeorm_2.Repository])
], AppInitService);
//# sourceMappingURL=app.init.service.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"app.init.service.js","sourceRoot":"","sources":["../../../../src/modules/initialization/app.init.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA0D;AAC1D,6CAAmD;AACnD,sEAAmD;AACnD,oEAAiD;AACjD,qCAAqC;AAG9B,IAAM,cAAc,GAApB,MAAM,cAAc;IACvB,YACoC,cAAgC,EAC/B,eAAkC;QADnC,mBAAc,GAAd,cAAc,CAAkB;QAC/B,oBAAe,GAAf,eAAe,CAAmB;IACpE,CAAC;IAEJ,KAAK,CAAC,YAAY,KAAI,CAAC;CAC1B,CAAA;AAPY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;IAGJ,WAAA,IAAA,0BAAgB,EAAC,kBAAI,CAAC,CAAA;IACtB,WAAA,IAAA,0BAAgB,EAAC,oBAAK,CAAC,CAAA;qCADwB,oBAAU;QACR,oBAAU;GAHvD,cAAc,CAO1B"}

View File

@@ -0,0 +1,7 @@
import { IGetUser } from './user.dto';
import { UserService } from './user.service';
export declare class UserController {
private adminService;
constructor(adminService: UserService);
getUser(data: IGetUser): Promise<import("../../../libs/database/user.entity").User>;
}

View File

@@ -0,0 +1,44 @@
"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.UserController = void 0;
const common_1 = require("@nestjs/common");
const swagger_1 = require("@nestjs/swagger");
const user_dto_1 = require("./user.dto");
const user_service_1 = require("./user.service");
let UserController = class UserController {
constructor(adminService) {
this.adminService = adminService;
}
async getUser(data) {
return await this.adminService.getUser(data);
}
};
exports.UserController = UserController;
__decorate([
(0, swagger_1.ApiOperation)({
description: 'Create or get user from db',
}),
(0, common_1.Post)('get'),
__param(0, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [user_dto_1.IGetUser]),
__metadata("design:returntype", Promise)
], UserController.prototype, "getUser", null);
exports.UserController = UserController = __decorate([
(0, swagger_1.ApiTags)('User'),
(0, common_1.Controller)('user'),
__metadata("design:paramtypes", [user_service_1.UserService])
], UserController);
//# sourceMappingURL=user.controller.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"user.controller.js","sourceRoot":"","sources":["../../../../src/modules/user/user.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAwD;AACxD,6CAAwD;AACxD,yCAAsC;AACtC,iDAA6C;AAItC,IAAM,cAAc,GAApB,MAAM,cAAc;IACvB,YAAoB,YAAyB;QAAzB,iBAAY,GAAZ,YAAY,CAAa;IAAG,CAAC;IAM3C,AAAN,KAAK,CAAC,OAAO,CAAS,IAAc;QAChC,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;CACJ,CAAA;AAVY,wCAAc;AAOjB;IAJL,IAAA,sBAAY,EAAC;QACV,WAAW,EAAE,4BAA4B;KAC5C,CAAC;IACD,IAAA,aAAI,EAAC,KAAK,CAAC;IACG,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAO,mBAAQ;;6CAEnC;yBATQ,cAAc;IAF1B,IAAA,iBAAO,EAAC,MAAM,CAAC;IACf,IAAA,mBAAU,EAAC,MAAM,CAAC;qCAEmB,0BAAW;GADpC,cAAc,CAU1B"}

View File

@@ -0,0 +1,4 @@
export declare class IGetUser {
readonly id: string;
readonly username?: string;
}

View File

@@ -0,0 +1,25 @@
"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.IGetUser = void 0;
const swagger_1 = require("@nestjs/swagger");
class IGetUser {
}
exports.IGetUser = IGetUser;
__decorate([
(0, swagger_1.ApiProperty)({ description: 'telegram id', example: '123456' }),
__metadata("design:type", String)
], IGetUser.prototype, "id", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ description: 'telegram username', example: 'durov' }),
__metadata("design:type", String)
], IGetUser.prototype, "username", void 0);
//# sourceMappingURL=user.dto.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"user.dto.js","sourceRoot":"","sources":["../../../../src/modules/user/user.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA8C;AAE9C,MAAa,QAAQ;CAGpB;AAHD,4BAGC;AAF4E;IAAxE,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,aAAa,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;;oCAAqB;AACN;IAA7E,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,mBAAmB,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;;0CAA4B"}

View File

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

View File

@@ -0,0 +1,24 @@
"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.UserModule = void 0;
const common_1 = require("@nestjs/common");
const libs_module_1 = require("../../../libs/libs.module");
const user_controller_1 = require("./user.controller");
const user_service_1 = require("./user.service");
let UserModule = class UserModule {
};
exports.UserModule = UserModule;
exports.UserModule = UserModule = __decorate([
(0, common_1.Module)({
imports: [libs_module_1.LibsModule],
controllers: [user_controller_1.UserController],
providers: [user_service_1.UserService],
})
], UserModule);
//# sourceMappingURL=user.module.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"user.module.js","sourceRoot":"","sources":["../../../../src/modules/user/user.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,2DAA8C;AAC9C,uDAAmD;AACnD,iDAA6C;AAOtC,IAAM,UAAU,GAAhB,MAAM,UAAU;CAAG,CAAA;AAAb,gCAAU;qBAAV,UAAU;IALtB,IAAA,eAAM,EAAC;QACJ,OAAO,EAAE,CAAC,wBAAU,CAAC;QACrB,WAAW,EAAE,CAAC,gCAAc,CAAC;QAC7B,SAAS,EAAE,CAAC,0BAAW,CAAC;KAC3B,CAAC;GACW,UAAU,CAAG"}

View File

@@ -0,0 +1,9 @@
import { User } from 'libs/database/user.entity';
import { Repository } from 'typeorm';
import { IGetUser } from './user.dto';
export declare class UserService {
private userRepository;
private readonly logger;
constructor(userRepository: Repository<User>);
getUser(data: IGetUser): Promise<User>;
}

View File

@@ -0,0 +1,49 @@
"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); }
};
var UserService_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.UserService = void 0;
const common_1 = require("@nestjs/common");
const typeorm_1 = require("@nestjs/typeorm");
const user_entity_1 = require("../../../libs/database/user.entity");
const typeorm_2 = require("typeorm");
let UserService = UserService_1 = class UserService {
constructor(userRepository) {
this.userRepository = userRepository;
this.logger = new common_1.Logger(UserService_1.name);
}
async getUser(data) {
try {
this.logger.debug(`[admin.getUser] data: ${JSON.stringify(data)}`);
let user = await this.userRepository.findOne({
where: { id: data.id },
});
if (!user) {
user = await this.userRepository.save({ id: data.id, user_name: data.username });
this.logger.log(`User ${data.id} created`);
}
return user;
}
catch (error) {
this.logger.log(`[getUser] ${JSON.stringify({ error })}`);
}
}
};
exports.UserService = UserService;
exports.UserService = UserService = UserService_1 = __decorate([
(0, common_1.Injectable)(),
__param(0, (0, typeorm_1.InjectRepository)(user_entity_1.User)),
__metadata("design:paramtypes", [typeorm_2.Repository])
], UserService);
//# sourceMappingURL=user.service.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"user.service.js","sourceRoot":"","sources":["../../../../src/modules/user/user.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,6CAAmD;AACnD,oEAAiD;AACjD,qCAAqC;AAI9B,IAAM,WAAW,mBAAjB,MAAM,WAAW;IAEpB,YAAoC,cAAwC;QAAhC,mBAAc,GAAd,cAAc,CAAkB;QAD3D,WAAM,GAAW,IAAI,eAAM,CAAC,aAAW,CAAC,IAAI,CAAC,CAAC;IACgB,CAAC;IAEhF,KAAK,CAAC,OAAO,CAAC,IAAc;QACxB,IAAI;YACA,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,yBAAyB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACnE,IAAI,IAAI,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;gBACzC,KAAK,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE;aACzB,CAAC,CAAC;YACH,IAAI,CAAC,IAAI,EAAE;gBACP,IAAI,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;gBACjF,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,IAAI,CAAC,EAAE,UAAU,CAAC,CAAC;aAC9C;YACD,OAAO,IAAI,CAAC;SACf;QAAC,OAAO,KAAK,EAAE;YACZ,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,aAAa,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;SAC7D;IACL,CAAC;CACJ,CAAA;AAnBY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;IAGI,WAAA,IAAA,0BAAgB,EAAC,kBAAI,CAAC,CAAA;qCAAyB,oBAAU;GAF7D,WAAW,CAmBvB"}

2
backend/dist/src/swagger.d.ts vendored Normal file
View File

@@ -0,0 +1,2 @@
import { INestApplication } from '@nestjs/common';
export declare function swagger(app: INestApplication): INestApplication;

12
backend/dist/src/swagger.js vendored Normal file
View File

@@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.swagger = void 0;
const swagger_1 = require("@nestjs/swagger");
function swagger(app) {
const config = new swagger_1.DocumentBuilder().setTitle('Neuro website').setDescription('Some description').setVersion('0.1').build();
const document = swagger_1.SwaggerModule.createDocument(app, config);
swagger_1.SwaggerModule.setup('api', app, document);
return app;
}
exports.swagger = swagger;
//# sourceMappingURL=swagger.js.map

1
backend/dist/src/swagger.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"swagger.js","sourceRoot":"","sources":["../../src/swagger.ts"],"names":[],"mappings":";;;AACA,6CAAiE;AAEjE,SAAgB,OAAO,CAAC,GAAqB;IACzC,MAAM,MAAM,GAAG,IAAI,yBAAe,EAAE,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC;IAC5H,MAAM,QAAQ,GAAG,uBAAa,CAAC,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAC3D,uBAAa,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC1C,OAAO,GAAG,CAAC;AACf,CAAC;AALD,0BAKC"}

1
backend/dist/tsconfig.tsbuildinfo vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,12 @@
import { Column, Entity, PrimaryColumn } from 'typeorm';
@Entity()
export class Admin {
constructor(props?: Partial<Admin>) {
Object.assign(this, props);
}
@PrimaryColumn()
public id!: string;
}

View File

@@ -1,8 +1,9 @@
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { User } from './database/user.entity';
import { Admin } from './database/admin.entity';
@Module({
imports: [TypeOrmModule.forFeature([User])],
imports: [TypeOrmModule.forFeature([User,Admin])],
exports: [TypeOrmModule],
})
export class LibsModule {}

View File

@@ -0,0 +1,22 @@
import { Controller, Get, Param } from '@nestjs/common';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
import { AdminService } from './admin.service';
@ApiTags('Admin')
@Controller('Admin')
export class AdminController {
constructor(private adminService: AdminService) {}
@ApiOperation({
description: 'Get admins from db',
})
@Get('get')
async getAdmin() {
return await this.adminService.getAdmins();
}
@ApiOperation({ description: 'Check admin is or not' })
@Get('is_admin/:id')
async isAdmin(@Param('id') id: string) {
return await this.adminService.checkIsAdmin(id);
}
}

View File

@@ -0,0 +1,11 @@
import { Module } from '@nestjs/common';
import { LibsModule } from 'libs/libs.module';
import { AdminController } from './admin.controller';
import { AdminService } from './admin.service';
@Module({
imports: [LibsModule],
controllers: [AdminController],
providers: [AdminService],
})
export class AdminModule {}

View File

@@ -0,0 +1,34 @@
import { Injectable, Logger } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { Admin } from 'libs/database/admin.entity';
@Injectable()
export class AdminService {
private readonly logger: Logger = new Logger(AdminService.name);
constructor(@InjectRepository(Admin) private adminRepository: Repository<Admin>) {}
async getAdmins() {
try {
this.logger.debug(`[admin.getAdmins]`);
let admins = await this.adminRepository.find();
return admins;
} catch (error) {
this.logger.log(`[getAdmin] ${JSON.stringify({ error })}`);
}
}
async checkIsAdmin(id: string) {
try {
this.logger.debug(`[admin.checkIsAdmin]`);
let admins = await this.adminRepository.findOne({
where: { id: id },
});
if (!admins) {
return false
}
return true;
} catch (error) {
this.logger.log(`[checkIsAdmin] ${JSON.stringify({ error })}`);
}
}
}

View File

@@ -4,9 +4,10 @@ import { config } from 'config';
import { LibsModule } from 'libs/libs.module';
import { AppInitService } from './modules/initialization/app.init.service';
import { UserModule } from './modules/user/user.module';
import { AdminModule } from './admin/admin.module';
@Module({
imports: [LibsModule, UserModule, TypeOrmModule.forRoot(<TypeOrmModuleOptions>config.database)],
imports: [LibsModule, UserModule, AdminModule, TypeOrmModule.forRoot(<TypeOrmModuleOptions>config.database)],
controllers: [],
providers: [AppInitService],
})

View File

@@ -1,11 +1,15 @@
import { Injectable, OnModuleInit } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Admin } from 'libs/database/admin.entity';
import { User } from 'libs/database/user.entity';
import { Repository } from 'typeorm';
@Injectable()
export class AppInitService implements OnModuleInit {
constructor(@InjectRepository(User) private userRepository: Repository<User>) {}
constructor(
@InjectRepository(User) private userRepository: Repository<User>,
@InjectRepository(Admin) private adminRepository: Repository<Admin>,
) {}
async onModuleInit() {}
}