mirror of
https://github.com/MrSedan/neuro-reply-website.git
synced 2026-01-14 20:49:42 +03:00
Delete useless
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -1 +0,0 @@
|
|||||||
* text=auto eol=lf
|
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -4,7 +4,7 @@
|
|||||||
!.vscode/tasks.json
|
!.vscode/tasks.json
|
||||||
!.vscode/launch.json
|
!.vscode/launch.json
|
||||||
!.vscode/extensions.json
|
!.vscode/extensions.json
|
||||||
|
backend/node_modules/
|
||||||
# Env files
|
# Env files
|
||||||
**/.env
|
**/.env
|
||||||
**/.env.*
|
**/.env.*
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
parser: '@typescript-eslint/parser',
|
|
||||||
parserOptions: {
|
|
||||||
project: 'tsconfig.json',
|
|
||||||
tsconfigRootDir: __dirname,
|
|
||||||
sourceType: 'module',
|
|
||||||
},
|
|
||||||
plugins: ['@typescript-eslint/eslint-plugin'],
|
|
||||||
extends: [
|
|
||||||
'plugin:@typescript-eslint/recommended',
|
|
||||||
'plugin:prettier/recommended',
|
|
||||||
],
|
|
||||||
root: true,
|
|
||||||
env: {
|
|
||||||
node: true,
|
|
||||||
jest: true,
|
|
||||||
},
|
|
||||||
ignorePatterns: ['.eslintrc.js'],
|
|
||||||
rules: {
|
|
||||||
'@typescript-eslint/interface-name-prefix': 'off',
|
|
||||||
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
||||||
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
||||||
'@typescript-eslint/no-explicit-any': 'off',
|
|
||||||
},
|
|
||||||
};
|
|
||||||
28
backend/.gitignore
vendored
28
backend/.gitignore
vendored
@@ -1,28 +0,0 @@
|
|||||||
# compiled output
|
|
||||||
/dist
|
|
||||||
/node_modules
|
|
||||||
|
|
||||||
# Logs
|
|
||||||
logs
|
|
||||||
*.log
|
|
||||||
npm-debug.log*
|
|
||||||
pnpm-debug.log*
|
|
||||||
yarn-debug.log*
|
|
||||||
yarn-error.log*
|
|
||||||
lerna-debug.log*
|
|
||||||
|
|
||||||
# OS
|
|
||||||
.DS_Store
|
|
||||||
|
|
||||||
# Tests
|
|
||||||
/coverage
|
|
||||||
/.nyc_output
|
|
||||||
|
|
||||||
# IDEs and editors
|
|
||||||
/.idea
|
|
||||||
.project
|
|
||||||
.classpath
|
|
||||||
.c9/
|
|
||||||
*.launch
|
|
||||||
.settings/
|
|
||||||
*.sublime-workspace
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"$schema": "https://json.schemastore.org/nest-cli",
|
|
||||||
"collection": "@nestjs/schematics",
|
|
||||||
"sourceRoot": "src",
|
|
||||||
"compilerOptions": {
|
|
||||||
"deleteOutDir": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
export const userRep: string = 'USER_REPOSITORY';
|
|
||||||
export const dataSource: string = 'DATA_SOURCE';
|
|
||||||
export const adminRep: string = 'ADMIN_REPOSITORY';
|
|
||||||
export const photoRep: string = 'PHOTO_REPOSITORY';
|
|
||||||
export const postRep: string = 'POST_REPOSITORY';
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
import { v4 as UUID } from 'uuid';
|
|
||||||
import { Entity, Column, PrimaryGeneratedColumn, OneToOne, JoinColumn, CreateDateColumn, PrimaryColumn } from 'typeorm';
|
|
||||||
|
|
||||||
@Entity()
|
|
||||||
export class User {
|
|
||||||
@PrimaryGeneratedColumn()
|
|
||||||
id: number;
|
|
||||||
|
|
||||||
@Column()
|
|
||||||
user_name: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Entity()
|
|
||||||
export class Admin {
|
|
||||||
@PrimaryGeneratedColumn()
|
|
||||||
id: number;
|
|
||||||
|
|
||||||
@OneToOne(() => User)
|
|
||||||
@JoinColumn()
|
|
||||||
user: User;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Entity()
|
|
||||||
export class Post {
|
|
||||||
@PrimaryColumn('uuid')
|
|
||||||
uuid: UUID;
|
|
||||||
|
|
||||||
@Column()
|
|
||||||
posted: boolean;
|
|
||||||
|
|
||||||
@OneToOne(() => User)
|
|
||||||
@JoinColumn()
|
|
||||||
from_user: User;
|
|
||||||
|
|
||||||
@Column()
|
|
||||||
text: string;
|
|
||||||
|
|
||||||
@Column()
|
|
||||||
media_group_id: string;
|
|
||||||
|
|
||||||
@Column('int', { array: true })
|
|
||||||
images: number[];
|
|
||||||
|
|
||||||
@CreateDateColumn()
|
|
||||||
timestamp: Date;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Entity()
|
|
||||||
export class Photo {
|
|
||||||
@PrimaryGeneratedColumn()
|
|
||||||
id: number;
|
|
||||||
|
|
||||||
@OneToOne(() => Post)
|
|
||||||
@JoinColumn()
|
|
||||||
post: Post;
|
|
||||||
|
|
||||||
@Column()
|
|
||||||
text: string;
|
|
||||||
|
|
||||||
@Column()
|
|
||||||
file_id: string;
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
import { Module } from '@nestjs/common';
|
|
||||||
import { databaseProviders } from './db.providers';
|
|
||||||
|
|
||||||
@Module({
|
|
||||||
providers: [...databaseProviders],
|
|
||||||
exports: [...databaseProviders],
|
|
||||||
})
|
|
||||||
export class DatabaseModule {}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
import { DataSource } from 'typeorm';
|
|
||||||
|
|
||||||
export const databaseProviders = [
|
|
||||||
{
|
|
||||||
provide: 'DATA_SOURCE',
|
|
||||||
useFactory: async () => {
|
|
||||||
const dataSource = new DataSource({
|
|
||||||
type: 'postgres',
|
|
||||||
host: 'localhost',
|
|
||||||
port: 15432,
|
|
||||||
username: 'postgres',
|
|
||||||
password: 'postgres',
|
|
||||||
database: 'bot_db',
|
|
||||||
entities: ['db_models.ts'],
|
|
||||||
logging: true,
|
|
||||||
synchronize: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
return dataSource.initialize();
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
import { Module } from '@nestjs/common';
|
|
||||||
import { DatabaseModule } from 'src/db.modules';
|
|
||||||
import { AdminService } from 'src/db_service/admin.service';
|
|
||||||
import { adminProviders } from 'src/db_providers/admin.providers';
|
|
||||||
|
|
||||||
@Module({
|
|
||||||
imports: [DatabaseModule],
|
|
||||||
providers: [...adminProviders, AdminService],
|
|
||||||
})
|
|
||||||
export class PhotoModule {}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
import { Module } from '@nestjs/common';
|
|
||||||
import { DatabaseModule } from 'src/db.modules';
|
|
||||||
import { photoProviders } from 'src/db_providers/photo.providers';
|
|
||||||
import { PhotoService } from 'src/db_service/photo.service';
|
|
||||||
|
|
||||||
@Module({
|
|
||||||
imports: [DatabaseModule],
|
|
||||||
providers: [...photoProviders, PhotoService],
|
|
||||||
})
|
|
||||||
export class PhotoModule {}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
import { Module } from '@nestjs/common';
|
|
||||||
import { DatabaseModule } from 'src/db.modules';
|
|
||||||
import { PostService } from 'src/db_service/post.service';
|
|
||||||
import { postProviders } from 'src/db_providers/post.providers';
|
|
||||||
|
|
||||||
@Module({
|
|
||||||
imports: [DatabaseModule],
|
|
||||||
providers: [...postProviders, PostService],
|
|
||||||
})
|
|
||||||
export class PhotoModule {}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
import { Module } from '@nestjs/common';
|
|
||||||
import { DatabaseModule } from 'src/db.modules';
|
|
||||||
import { UserService } from 'src/db_service/user.service';
|
|
||||||
import { userProviders } from 'src/db_providers/user.providers';
|
|
||||||
|
|
||||||
@Module({
|
|
||||||
imports: [DatabaseModule],
|
|
||||||
providers: [...userProviders, UserService],
|
|
||||||
})
|
|
||||||
export class PhotoModule {}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import { DataSource } from 'typeorm';
|
|
||||||
import { Admin } from '../db.entity';
|
|
||||||
import { adminRep, dataSource } from '../constants';
|
|
||||||
|
|
||||||
export const adminProviders = [
|
|
||||||
{
|
|
||||||
provide: adminRep,
|
|
||||||
useFactory: (dataSource: DataSource) => dataSource.getRepository(Admin),
|
|
||||||
inject: [dataSource],
|
|
||||||
},
|
|
||||||
];
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
import { DataSource } from 'typeorm';
|
|
||||||
|
|
||||||
export const databaseProviders = [
|
|
||||||
{
|
|
||||||
provide: 'DATA_SOURCE',
|
|
||||||
useFactory: async () => {
|
|
||||||
const dataSource = new DataSource({
|
|
||||||
type: 'postgres',
|
|
||||||
host: 'localhost',
|
|
||||||
port: 15432,
|
|
||||||
username: 'postgres',
|
|
||||||
password: 'postgres',
|
|
||||||
database: 'bot_db',
|
|
||||||
entities: ['db_models.ts'],
|
|
||||||
logging: true,
|
|
||||||
synchronize: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
return dataSource.initialize();
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import { DataSource } from 'typeorm';
|
|
||||||
import { Photo } from '../db.entity';
|
|
||||||
import { photoRep, dataSource } from '../constants';
|
|
||||||
|
|
||||||
export const photoProviders = [
|
|
||||||
{
|
|
||||||
provide: photoRep,
|
|
||||||
useFactory: (dataSource: DataSource) => dataSource.getRepository(Photo),
|
|
||||||
inject: [dataSource],
|
|
||||||
},
|
|
||||||
];
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import { DataSource } from 'typeorm';
|
|
||||||
import { Post } from '../db.entity';
|
|
||||||
import { postRep, dataSource } from '../constants';
|
|
||||||
|
|
||||||
export const postProviders = [
|
|
||||||
{
|
|
||||||
provide: postRep,
|
|
||||||
useFactory: (dataSource: DataSource) => dataSource.getRepository(Post),
|
|
||||||
inject: [dataSource],
|
|
||||||
},
|
|
||||||
];
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import { DataSource } from 'typeorm';
|
|
||||||
import { User } from '../db.entity';
|
|
||||||
import { userRep, dataSource } from '../constants';
|
|
||||||
|
|
||||||
export const userProviders = [
|
|
||||||
{
|
|
||||||
provide: userRep,
|
|
||||||
useFactory: (dataSource: DataSource) => dataSource.getRepository(User),
|
|
||||||
inject: [dataSource],
|
|
||||||
},
|
|
||||||
];
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
import { Injectable, Inject } from '@nestjs/common';
|
|
||||||
import { Repository } from 'typeorm';
|
|
||||||
import { Admin } from '../db.entity';
|
|
||||||
import { adminRep } from '../constants';
|
|
||||||
@Injectable()
|
|
||||||
export class AdminService {
|
|
||||||
constructor(
|
|
||||||
@Inject(adminRep)
|
|
||||||
private photoRepository: Repository<Admin>,
|
|
||||||
) {}
|
|
||||||
|
|
||||||
async findAll(): Promise<Admin[]> {
|
|
||||||
return this.photoRepository.find();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
import { Injectable, Inject } from '@nestjs/common';
|
|
||||||
import { Repository } from 'typeorm';
|
|
||||||
import { Photo } from '../db.entity';
|
|
||||||
import { photoRep } from '../constants';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class PhotoService {
|
|
||||||
constructor(
|
|
||||||
@Inject(photoRep)
|
|
||||||
private photoRepository: Repository<Photo>,
|
|
||||||
) {}
|
|
||||||
|
|
||||||
async findAll(): Promise<Photo[]> {
|
|
||||||
return this.photoRepository.find();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
import { Injectable, Inject } from '@nestjs/common';
|
|
||||||
import { Repository } from 'typeorm';
|
|
||||||
import { Post } from '../db.entity';
|
|
||||||
import { postRep } from '../constants';
|
|
||||||
@Injectable()
|
|
||||||
export class PostService {
|
|
||||||
constructor(
|
|
||||||
@Inject(postRep)
|
|
||||||
private photoRepository: Repository<Post>,
|
|
||||||
) {}
|
|
||||||
|
|
||||||
async findAll(): Promise<Post[]> {
|
|
||||||
return this.photoRepository.find();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
import { Injectable, Inject } from '@nestjs/common';
|
|
||||||
import { Repository } from 'typeorm';
|
|
||||||
import { User } from '../db.entity';
|
|
||||||
import { userRep } from '../constants';
|
|
||||||
@Injectable()
|
|
||||||
export class UserService {
|
|
||||||
constructor(
|
|
||||||
@Inject(userRep)
|
|
||||||
private photoRepository: Repository<User>,
|
|
||||||
) {}
|
|
||||||
|
|
||||||
async findAll(): Promise<User[]> {
|
|
||||||
return this.photoRepository.find();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,134 +0,0 @@
|
|||||||
import { MigrationInterface, QueryRunner, Table, TableForeignKey } from 'typeorm';
|
|
||||||
|
|
||||||
export class Start1700312110383 implements MigrationInterface {
|
|
||||||
private userTable = new Table({
|
|
||||||
name: 'user',
|
|
||||||
columns: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
type: 'integer',
|
|
||||||
isPrimary: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'name',
|
|
||||||
type: 'varchar',
|
|
||||||
length: '255',
|
|
||||||
isUnique: true,
|
|
||||||
isNullable: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
private adminTable = new Table({
|
|
||||||
name: 'admin',
|
|
||||||
columns: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
type: 'integer',
|
|
||||||
isPrimary: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
private postTable = new Table({
|
|
||||||
name: 'post',
|
|
||||||
columns: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
type: 'uuid',
|
|
||||||
isPrimary: true,
|
|
||||||
isGenerated: true,
|
|
||||||
generationStrategy: 'uuid',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'posted',
|
|
||||||
type: 'boolean',
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'from_user_id',
|
|
||||||
type: 'integer',
|
|
||||||
isNullable: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'text',
|
|
||||||
type: 'varchar',
|
|
||||||
isNullable: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'media_group_id',
|
|
||||||
type: 'varchar',
|
|
||||||
isNullable: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'images',
|
|
||||||
type: 'integer[]',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'timestamp',
|
|
||||||
type: 'timestamptz',
|
|
||||||
default: 'now()',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
private imageTable = new Table({
|
|
||||||
name: 'photo',
|
|
||||||
columns: [
|
|
||||||
{
|
|
||||||
name: 'message_id',
|
|
||||||
type: 'integer',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'post_id',
|
|
||||||
type: 'uuid',
|
|
||||||
isNullable: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'file_id',
|
|
||||||
type: 'varchar',
|
|
||||||
isNullable: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'has_spoiler',
|
|
||||||
type: 'boolean',
|
|
||||||
isNullable: false,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
queryRunner.createTable(this.userTable);
|
|
||||||
|
|
||||||
queryRunner.createTable(this.adminTable);
|
|
||||||
|
|
||||||
queryRunner.createForeignKey(
|
|
||||||
this.adminTable,
|
|
||||||
new TableForeignKey({
|
|
||||||
columnNames: ['id'],
|
|
||||||
referencedColumnNames: ['id'],
|
|
||||||
referencedTableName: 'user',
|
|
||||||
onDelete: 'CASCADE',
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
queryRunner.createTable(this.postTable);
|
|
||||||
|
|
||||||
queryRunner.createTable(this.imageTable);
|
|
||||||
|
|
||||||
queryRunner.createForeignKey(
|
|
||||||
this.imageTable,
|
|
||||||
new TableForeignKey({
|
|
||||||
columnNames: ['post_id'],
|
|
||||||
referencedColumnNames: ['uuid'],
|
|
||||||
referencedTableName: 'post',
|
|
||||||
onDelete: 'CASCADE',
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
queryRunner.dropTable(this.imageTable);
|
|
||||||
queryRunner.dropTable(this.postTable);
|
|
||||||
queryRunner.dropTable(this.adminTable);
|
|
||||||
queryRunner.dropTable(this.userTable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
import { Test, TestingModule } from '@nestjs/testing';
|
|
||||||
import { INestApplication } from '@nestjs/common';
|
|
||||||
import * as request from 'supertest';
|
|
||||||
import { AppModule } from './../src/app.module';
|
|
||||||
|
|
||||||
describe('AppController (e2e)', () => {
|
|
||||||
let app: INestApplication;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
const moduleFixture: TestingModule = await Test.createTestingModule({
|
|
||||||
imports: [AppModule],
|
|
||||||
}).compile();
|
|
||||||
|
|
||||||
app = moduleFixture.createNestApplication();
|
|
||||||
await app.init();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('/ (GET)', () => {
|
|
||||||
return request(app.getHttpServer())
|
|
||||||
.get('/')
|
|
||||||
.expect(200)
|
|
||||||
.expect('Hello World!');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"moduleFileExtensions": ["js", "json", "ts"],
|
|
||||||
"rootDir": ".",
|
|
||||||
"testEnvironment": "node",
|
|
||||||
"testRegex": ".e2e-spec.ts$",
|
|
||||||
"transform": {
|
|
||||||
"^.+\\.(t|j)s$": "ts-jest"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": "./tsconfig.json",
|
|
||||||
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user