Initial setup
This commit is contained in:
commit
4f64a72de7
25
.eslintrc.js
Normal file
25
.eslintrc.js
Normal file
@ -0,0 +1,25 @@
|
||||
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',
|
||||
},
|
||||
};
|
38
.gitignore
vendored
Normal file
38
.gitignore
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
# compiled output
|
||||
/dist
|
||||
/node_modules
|
||||
/database
|
||||
|
||||
# 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
|
||||
|
||||
# IDE - VSCode
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
|
||||
.env*
|
4
.prettierrc
Normal file
4
.prettierrc
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"singleQuote": true,
|
||||
"trailingComma": "all"
|
||||
}
|
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"editor.formatOnSave": true
|
||||
}
|
73
README.md
Normal file
73
README.md
Normal file
@ -0,0 +1,73 @@
|
||||
<p align="center">
|
||||
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="200" alt="Nest Logo" /></a>
|
||||
</p>
|
||||
|
||||
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
|
||||
[circleci-url]: https://circleci.com/gh/nestjs/nest
|
||||
|
||||
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
||||
<p align="center">
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
|
||||
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
|
||||
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
|
||||
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
|
||||
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
|
||||
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
|
||||
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
|
||||
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
|
||||
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
|
||||
</p>
|
||||
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
|
||||
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->
|
||||
|
||||
## Description
|
||||
|
||||
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
$ npm install
|
||||
```
|
||||
|
||||
## Running the app
|
||||
|
||||
```bash
|
||||
# development
|
||||
$ npm run start
|
||||
|
||||
# watch mode
|
||||
$ npm run start:dev
|
||||
|
||||
# production mode
|
||||
$ npm run start:prod
|
||||
```
|
||||
|
||||
## Test
|
||||
|
||||
```bash
|
||||
# unit tests
|
||||
$ npm run test
|
||||
|
||||
# e2e tests
|
||||
$ npm run test:e2e
|
||||
|
||||
# test coverage
|
||||
$ npm run test:cov
|
||||
```
|
||||
|
||||
## Support
|
||||
|
||||
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
|
||||
|
||||
## Stay in touch
|
||||
|
||||
- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
|
||||
- Website - [https://nestjs.com](https://nestjs.com/)
|
||||
- Twitter - [@nestframework](https://twitter.com/nestframework)
|
||||
|
||||
## License
|
||||
|
||||
Nest is [MIT licensed](LICENSE).
|
22
apps/auth/src/auth.controller.spec.ts
Normal file
22
apps/auth/src/auth.controller.spec.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { AuthController } from './auth.controller';
|
||||
import { AuthService } from './auth.service';
|
||||
|
||||
describe('AuthController', () => {
|
||||
let authController: AuthController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const app: TestingModule = await Test.createTestingModule({
|
||||
controllers: [AuthController],
|
||||
providers: [AuthService],
|
||||
}).compile();
|
||||
|
||||
authController = app.get<AuthController>(AuthController);
|
||||
});
|
||||
|
||||
describe('root', () => {
|
||||
it('should return "Hello World!"', () => {
|
||||
expect(authController.getHello()).toBe('Hello World!');
|
||||
});
|
||||
});
|
||||
});
|
14
apps/auth/src/auth.controller.ts
Normal file
14
apps/auth/src/auth.controller.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { Controller } from '@nestjs/common';
|
||||
import { AuthService } from './auth.service';
|
||||
import { MessagePattern } from '@nestjs/microservices';
|
||||
import { LoginRequest } from './interfaces/auth.interface';
|
||||
|
||||
@Controller()
|
||||
export class AuthController {
|
||||
constructor(private readonly authService: AuthService) {}
|
||||
|
||||
@MessagePattern('auth.login')
|
||||
login({ body }: { body: LoginRequest }) {
|
||||
return this.authService.login(body);
|
||||
}
|
||||
}
|
12
apps/auth/src/auth.module.ts
Normal file
12
apps/auth/src/auth.module.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { AuthController } from './auth.controller';
|
||||
import { AuthService } from './auth.service';
|
||||
import { ClientsModule } from '@nestjs/microservices';
|
||||
import { natsClient } from '@freeblox/shared';
|
||||
|
||||
@Module({
|
||||
imports: [ClientsModule.register([natsClient('auth')])],
|
||||
controllers: [AuthController],
|
||||
providers: [AuthService],
|
||||
})
|
||||
export class AuthModule {}
|
9
apps/auth/src/auth.service.ts
Normal file
9
apps/auth/src/auth.service.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { LoginRequest } from './interfaces/auth.interface';
|
||||
|
||||
@Injectable()
|
||||
export class AuthService {
|
||||
async login(body: LoginRequest) {
|
||||
return { test: body.email };
|
||||
}
|
||||
}
|
4
apps/auth/src/interfaces/auth.interface.ts
Normal file
4
apps/auth/src/interfaces/auth.interface.ts
Normal file
@ -0,0 +1,4 @@
|
||||
export interface LoginRequest {
|
||||
email: string;
|
||||
password: string;
|
||||
}
|
18
apps/auth/src/main.ts
Normal file
18
apps/auth/src/main.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { MicroserviceOptions, Transport } from '@nestjs/microservices';
|
||||
import { AuthModule } from './auth.module';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.createMicroservice<MicroserviceOptions>(
|
||||
AuthModule,
|
||||
{
|
||||
transport: Transport.NATS,
|
||||
options: {
|
||||
servers: ['nats://localhost:4222'],
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
await app.listen();
|
||||
}
|
||||
bootstrap();
|
24
apps/auth/test/app.e2e-spec.ts
Normal file
24
apps/auth/test/app.e2e-spec.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import * as request from 'supertest';
|
||||
import { AuthModule } from './../src/auth.module';
|
||||
|
||||
describe('AuthController (e2e)', () => {
|
||||
let app: INestApplication;
|
||||
|
||||
beforeEach(async () => {
|
||||
const moduleFixture: TestingModule = await Test.createTestingModule({
|
||||
imports: [AuthModule],
|
||||
}).compile();
|
||||
|
||||
app = moduleFixture.createNestApplication();
|
||||
await app.init();
|
||||
});
|
||||
|
||||
it('/ (GET)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/')
|
||||
.expect(200)
|
||||
.expect('Hello World!');
|
||||
});
|
||||
});
|
9
apps/auth/test/jest-e2e.json
Normal file
9
apps/auth/test/jest-e2e.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"moduleFileExtensions": ["js", "json", "ts"],
|
||||
"rootDir": ".",
|
||||
"testEnvironment": "node",
|
||||
"testRegex": ".e2e-spec.ts$",
|
||||
"transform": {
|
||||
"^.+\\.(t|j)s$": "ts-jest"
|
||||
}
|
||||
}
|
9
apps/auth/tsconfig.app.json
Normal file
9
apps/auth/tsconfig.app.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"declaration": false,
|
||||
"outDir": "../../dist/apps/auth"
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist", "test", "**/*spec.ts"]
|
||||
}
|
22
apps/catalog/src/catalog.controller.spec.ts
Normal file
22
apps/catalog/src/catalog.controller.spec.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { CatalogController } from './catalog.controller';
|
||||
import { CatalogService } from './catalog.service';
|
||||
|
||||
describe('CatalogController', () => {
|
||||
let catalogController: CatalogController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const app: TestingModule = await Test.createTestingModule({
|
||||
controllers: [CatalogController],
|
||||
providers: [CatalogService],
|
||||
}).compile();
|
||||
|
||||
catalogController = app.get<CatalogController>(CatalogController);
|
||||
});
|
||||
|
||||
describe('root', () => {
|
||||
it('should return "Hello World!"', () => {
|
||||
expect(catalogController.getHello()).toBe('Hello World!');
|
||||
});
|
||||
});
|
||||
});
|
12
apps/catalog/src/catalog.controller.ts
Normal file
12
apps/catalog/src/catalog.controller.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { Controller, Get } from '@nestjs/common';
|
||||
import { CatalogService } from './catalog.service';
|
||||
|
||||
@Controller()
|
||||
export class CatalogController {
|
||||
constructor(private readonly catalogService: CatalogService) {}
|
||||
|
||||
@Get()
|
||||
getHello(): string {
|
||||
return this.catalogService.getHello();
|
||||
}
|
||||
}
|
18
apps/catalog/src/catalog.module.ts
Normal file
18
apps/catalog/src/catalog.module.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { CatalogController } from './catalog.controller';
|
||||
import { CatalogService } from './catalog.service';
|
||||
import { ClientsModule } from '@nestjs/microservices';
|
||||
import { natsClient } from '@freeblox/shared';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
ClientsModule.register([
|
||||
natsClient('catalog'),
|
||||
natsClient('auth'),
|
||||
natsClient('player'),
|
||||
]),
|
||||
],
|
||||
controllers: [CatalogController],
|
||||
providers: [CatalogService],
|
||||
})
|
||||
export class CatalogModule {}
|
8
apps/catalog/src/catalog.service.ts
Normal file
8
apps/catalog/src/catalog.service.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class CatalogService {
|
||||
getHello(): string {
|
||||
return 'Hello World!';
|
||||
}
|
||||
}
|
18
apps/catalog/src/main.ts
Normal file
18
apps/catalog/src/main.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { CatalogModule } from './catalog.module';
|
||||
import { MicroserviceOptions, Transport } from '@nestjs/microservices';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.createMicroservice<MicroserviceOptions>(
|
||||
CatalogModule,
|
||||
{
|
||||
transport: Transport.NATS,
|
||||
options: {
|
||||
servers: ['nats://localhost:4222'],
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
await app.listen();
|
||||
}
|
||||
bootstrap();
|
24
apps/catalog/test/app.e2e-spec.ts
Normal file
24
apps/catalog/test/app.e2e-spec.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import * as request from 'supertest';
|
||||
import { CatalogModule } from './../src/catalog.module';
|
||||
|
||||
describe('CatalogController (e2e)', () => {
|
||||
let app: INestApplication;
|
||||
|
||||
beforeEach(async () => {
|
||||
const moduleFixture: TestingModule = await Test.createTestingModule({
|
||||
imports: [CatalogModule],
|
||||
}).compile();
|
||||
|
||||
app = moduleFixture.createNestApplication();
|
||||
await app.init();
|
||||
});
|
||||
|
||||
it('/ (GET)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/')
|
||||
.expect(200)
|
||||
.expect('Hello World!');
|
||||
});
|
||||
});
|
9
apps/catalog/test/jest-e2e.json
Normal file
9
apps/catalog/test/jest-e2e.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"moduleFileExtensions": ["js", "json", "ts"],
|
||||
"rootDir": ".",
|
||||
"testEnvironment": "node",
|
||||
"testRegex": ".e2e-spec.ts$",
|
||||
"transform": {
|
||||
"^.+\\.(t|j)s$": "ts-jest"
|
||||
}
|
||||
}
|
9
apps/catalog/tsconfig.app.json
Normal file
9
apps/catalog/tsconfig.app.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"declaration": false,
|
||||
"outDir": "../../dist/apps/catalog"
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist", "test", "**/*spec.ts"]
|
||||
}
|
22
apps/freeblox-web-service/src/app.controller.spec.ts
Normal file
22
apps/freeblox-web-service/src/app.controller.spec.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { AppController } from './app.controller';
|
||||
import { AppService } from './app.service';
|
||||
|
||||
describe('AppController', () => {
|
||||
let appController: AppController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const app: TestingModule = await Test.createTestingModule({
|
||||
controllers: [AppController],
|
||||
providers: [AppService],
|
||||
}).compile();
|
||||
|
||||
appController = app.get<AppController>(AppController);
|
||||
});
|
||||
|
||||
describe('root', () => {
|
||||
it('should return "Hello World!"', () => {
|
||||
expect(appController.getHello()).toBe('Hello World!');
|
||||
});
|
||||
});
|
||||
});
|
12
apps/freeblox-web-service/src/app.controller.ts
Normal file
12
apps/freeblox-web-service/src/app.controller.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { Controller, Get } from '@nestjs/common';
|
||||
import { AppService } from './app.service';
|
||||
|
||||
@Controller()
|
||||
export class AppController {
|
||||
constructor(private readonly appService: AppService) {}
|
||||
|
||||
@Get()
|
||||
getHello(): string {
|
||||
return this.appService.getHello();
|
||||
}
|
||||
}
|
24
apps/freeblox-web-service/src/app.module.ts
Normal file
24
apps/freeblox-web-service/src/app.module.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { AppController } from './app.controller';
|
||||
import { AppService } from './app.service';
|
||||
import { natsClient } from '@freeblox/shared';
|
||||
import { ClientsModule } from '@nestjs/microservices';
|
||||
import { AuthModule } from './services/auth/auth.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
ClientsModule.register([
|
||||
natsClient('auth'),
|
||||
natsClient('catalog'),
|
||||
natsClient('game'),
|
||||
natsClient('session'),
|
||||
natsClient('player'),
|
||||
natsClient('server'),
|
||||
natsClient('session'),
|
||||
]),
|
||||
AuthModule,
|
||||
],
|
||||
controllers: [AppController],
|
||||
providers: [AppService],
|
||||
})
|
||||
export class AppModule {}
|
8
apps/freeblox-web-service/src/app.service.ts
Normal file
8
apps/freeblox-web-service/src/app.service.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class AppService {
|
||||
getHello(): string {
|
||||
return 'Hello World!';
|
||||
}
|
||||
}
|
18
apps/freeblox-web-service/src/main.ts
Normal file
18
apps/freeblox-web-service/src/main.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { AppModule } from './app.module';
|
||||
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
|
||||
const config = new DocumentBuilder()
|
||||
.setTitle('Freeblox Web Service')
|
||||
.setDescription('Freeblox Web Service API gateway')
|
||||
.setVersion('1.0')
|
||||
.build();
|
||||
const document = SwaggerModule.createDocument(app, config);
|
||||
SwaggerModule.setup('api', app, document);
|
||||
|
||||
await app.listen(3000);
|
||||
}
|
||||
bootstrap();
|
@ -0,0 +1,26 @@
|
||||
import {
|
||||
Body,
|
||||
ClassSerializerInterceptor,
|
||||
Controller,
|
||||
Inject,
|
||||
Post,
|
||||
UseInterceptors,
|
||||
} from '@nestjs/common';
|
||||
import { ClientProxy } from '@nestjs/microservices';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import { LoginDto } from './dtos/login.dto';
|
||||
|
||||
@Controller({
|
||||
version: '1',
|
||||
path: 'auth',
|
||||
})
|
||||
@ApiTags('Auth')
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
export class AuthController {
|
||||
constructor(@Inject('auth') private auth: ClientProxy) {}
|
||||
|
||||
@Post('login')
|
||||
async login(@Body() body: LoginDto) {
|
||||
return this.auth.send('auth.login', { body });
|
||||
}
|
||||
}
|
10
apps/freeblox-web-service/src/services/auth/auth.module.ts
Normal file
10
apps/freeblox-web-service/src/services/auth/auth.module.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import { natsClient } from '@freeblox/shared';
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ClientsModule } from '@nestjs/microservices';
|
||||
import { AuthController } from './auth.controller';
|
||||
|
||||
@Module({
|
||||
imports: [ClientsModule.register([natsClient('auth')])],
|
||||
controllers: [AuthController],
|
||||
})
|
||||
export class AuthModule {}
|
@ -0,0 +1,9 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class LoginDto {
|
||||
@ApiProperty()
|
||||
email: string;
|
||||
|
||||
@ApiProperty()
|
||||
password: string;
|
||||
}
|
24
apps/freeblox-web-service/test/app.e2e-spec.ts
Normal file
24
apps/freeblox-web-service/test/app.e2e-spec.ts
Normal file
@ -0,0 +1,24 @@
|
||||
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!');
|
||||
});
|
||||
});
|
9
apps/freeblox-web-service/test/jest-e2e.json
Normal file
9
apps/freeblox-web-service/test/jest-e2e.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"moduleFileExtensions": ["js", "json", "ts"],
|
||||
"rootDir": ".",
|
||||
"testEnvironment": "node",
|
||||
"testRegex": ".e2e-spec.ts$",
|
||||
"transform": {
|
||||
"^.+\\.(t|j)s$": "ts-jest"
|
||||
}
|
||||
}
|
9
apps/freeblox-web-service/tsconfig.app.json
Normal file
9
apps/freeblox-web-service/tsconfig.app.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"declaration": false,
|
||||
"outDir": "../../dist/apps/freeblox-web-service"
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist", "test", "**/*spec.ts"]
|
||||
}
|
22
apps/game/src/game.controller.spec.ts
Normal file
22
apps/game/src/game.controller.spec.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { GameController } from './game.controller';
|
||||
import { GameService } from './game.service';
|
||||
|
||||
describe('GameController', () => {
|
||||
let gameController: GameController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const app: TestingModule = await Test.createTestingModule({
|
||||
controllers: [GameController],
|
||||
providers: [GameService],
|
||||
}).compile();
|
||||
|
||||
gameController = app.get<GameController>(GameController);
|
||||
});
|
||||
|
||||
describe('root', () => {
|
||||
it('should return "Hello World!"', () => {
|
||||
expect(gameController.getHello()).toBe('Hello World!');
|
||||
});
|
||||
});
|
||||
});
|
12
apps/game/src/game.controller.ts
Normal file
12
apps/game/src/game.controller.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { Controller, Get } from '@nestjs/common';
|
||||
import { GameService } from './game.service';
|
||||
|
||||
@Controller()
|
||||
export class GameController {
|
||||
constructor(private readonly gameService: GameService) {}
|
||||
|
||||
@Get()
|
||||
getHello(): string {
|
||||
return this.gameService.getHello();
|
||||
}
|
||||
}
|
19
apps/game/src/game.module.ts
Normal file
19
apps/game/src/game.module.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { GameController } from './game.controller';
|
||||
import { GameService } from './game.service';
|
||||
import { ClientsModule } from '@nestjs/microservices';
|
||||
import { natsClient } from '@freeblox/shared';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
ClientsModule.register([
|
||||
natsClient('game'),
|
||||
natsClient('auth'),
|
||||
natsClient('session'),
|
||||
natsClient('player'),
|
||||
]),
|
||||
],
|
||||
controllers: [GameController],
|
||||
providers: [GameService],
|
||||
})
|
||||
export class GameModule {}
|
8
apps/game/src/game.service.ts
Normal file
8
apps/game/src/game.service.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class GameService {
|
||||
getHello(): string {
|
||||
return 'Hello World!';
|
||||
}
|
||||
}
|
18
apps/game/src/main.ts
Normal file
18
apps/game/src/main.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { GameModule } from './game.module';
|
||||
import { MicroserviceOptions, Transport } from '@nestjs/microservices';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.createMicroservice<MicroserviceOptions>(
|
||||
GameModule,
|
||||
{
|
||||
transport: Transport.NATS,
|
||||
options: {
|
||||
servers: ['nats://localhost:4222'],
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
await app.listen();
|
||||
}
|
||||
bootstrap();
|
24
apps/game/test/app.e2e-spec.ts
Normal file
24
apps/game/test/app.e2e-spec.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import * as request from 'supertest';
|
||||
import { GameModule } from './../src/game.module';
|
||||
|
||||
describe('GameController (e2e)', () => {
|
||||
let app: INestApplication;
|
||||
|
||||
beforeEach(async () => {
|
||||
const moduleFixture: TestingModule = await Test.createTestingModule({
|
||||
imports: [GameModule],
|
||||
}).compile();
|
||||
|
||||
app = moduleFixture.createNestApplication();
|
||||
await app.init();
|
||||
});
|
||||
|
||||
it('/ (GET)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/')
|
||||
.expect(200)
|
||||
.expect('Hello World!');
|
||||
});
|
||||
});
|
9
apps/game/test/jest-e2e.json
Normal file
9
apps/game/test/jest-e2e.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"moduleFileExtensions": ["js", "json", "ts"],
|
||||
"rootDir": ".",
|
||||
"testEnvironment": "node",
|
||||
"testRegex": ".e2e-spec.ts$",
|
||||
"transform": {
|
||||
"^.+\\.(t|j)s$": "ts-jest"
|
||||
}
|
||||
}
|
9
apps/game/tsconfig.app.json
Normal file
9
apps/game/tsconfig.app.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"declaration": false,
|
||||
"outDir": "../../dist/apps/game"
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist", "test", "**/*spec.ts"]
|
||||
}
|
18
apps/player/src/main.ts
Normal file
18
apps/player/src/main.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { PlayerModule } from './player.module';
|
||||
import { MicroserviceOptions, Transport } from '@nestjs/microservices';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.createMicroservice<MicroserviceOptions>(
|
||||
PlayerModule,
|
||||
{
|
||||
transport: Transport.NATS,
|
||||
options: {
|
||||
servers: ['nats://localhost:4222'],
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
await app.listen();
|
||||
}
|
||||
bootstrap();
|
22
apps/player/src/player.controller.spec.ts
Normal file
22
apps/player/src/player.controller.spec.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { PlayerController } from './player.controller';
|
||||
import { PlayerService } from './player.service';
|
||||
|
||||
describe('PlayerController', () => {
|
||||
let playerController: PlayerController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const app: TestingModule = await Test.createTestingModule({
|
||||
controllers: [PlayerController],
|
||||
providers: [PlayerService],
|
||||
}).compile();
|
||||
|
||||
playerController = app.get<PlayerController>(PlayerController);
|
||||
});
|
||||
|
||||
describe('root', () => {
|
||||
it('should return "Hello World!"', () => {
|
||||
expect(playerController.getHello()).toBe('Hello World!');
|
||||
});
|
||||
});
|
||||
});
|
12
apps/player/src/player.controller.ts
Normal file
12
apps/player/src/player.controller.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { Controller, Get } from '@nestjs/common';
|
||||
import { PlayerService } from './player.service';
|
||||
|
||||
@Controller()
|
||||
export class PlayerController {
|
||||
constructor(private readonly playerService: PlayerService) {}
|
||||
|
||||
@Get()
|
||||
getHello(): string {
|
||||
return this.playerService.getHello();
|
||||
}
|
||||
}
|
12
apps/player/src/player.module.ts
Normal file
12
apps/player/src/player.module.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { PlayerController } from './player.controller';
|
||||
import { PlayerService } from './player.service';
|
||||
import { ClientsModule } from '@nestjs/microservices';
|
||||
import { natsClient } from '@freeblox/shared';
|
||||
|
||||
@Module({
|
||||
imports: [ClientsModule.register([natsClient('player'), natsClient('auth')])],
|
||||
controllers: [PlayerController],
|
||||
providers: [PlayerService],
|
||||
})
|
||||
export class PlayerModule {}
|
8
apps/player/src/player.service.ts
Normal file
8
apps/player/src/player.service.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class PlayerService {
|
||||
getHello(): string {
|
||||
return 'Hello World!';
|
||||
}
|
||||
}
|
24
apps/player/test/app.e2e-spec.ts
Normal file
24
apps/player/test/app.e2e-spec.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import * as request from 'supertest';
|
||||
import { PlayerModule } from './../src/player.module';
|
||||
|
||||
describe('PlayerController (e2e)', () => {
|
||||
let app: INestApplication;
|
||||
|
||||
beforeEach(async () => {
|
||||
const moduleFixture: TestingModule = await Test.createTestingModule({
|
||||
imports: [PlayerModule],
|
||||
}).compile();
|
||||
|
||||
app = moduleFixture.createNestApplication();
|
||||
await app.init();
|
||||
});
|
||||
|
||||
it('/ (GET)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/')
|
||||
.expect(200)
|
||||
.expect('Hello World!');
|
||||
});
|
||||
});
|
9
apps/player/test/jest-e2e.json
Normal file
9
apps/player/test/jest-e2e.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"moduleFileExtensions": ["js", "json", "ts"],
|
||||
"rootDir": ".",
|
||||
"testEnvironment": "node",
|
||||
"testRegex": ".e2e-spec.ts$",
|
||||
"transform": {
|
||||
"^.+\\.(t|j)s$": "ts-jest"
|
||||
}
|
||||
}
|
9
apps/player/tsconfig.app.json
Normal file
9
apps/player/tsconfig.app.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"declaration": false,
|
||||
"outDir": "../../dist/apps/player"
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist", "test", "**/*spec.ts"]
|
||||
}
|
18
apps/server/src/main.ts
Normal file
18
apps/server/src/main.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { ServerModule } from './server.module';
|
||||
import { MicroserviceOptions, Transport } from '@nestjs/microservices';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.createMicroservice<MicroserviceOptions>(
|
||||
ServerModule,
|
||||
{
|
||||
transport: Transport.NATS,
|
||||
options: {
|
||||
servers: ['nats://localhost:4222'],
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
await app.listen();
|
||||
}
|
||||
bootstrap();
|
22
apps/server/src/server.controller.spec.ts
Normal file
22
apps/server/src/server.controller.spec.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { ServerController } from './server.controller';
|
||||
import { ServerService } from './server.service';
|
||||
|
||||
describe('ServerController', () => {
|
||||
let serverController: ServerController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const app: TestingModule = await Test.createTestingModule({
|
||||
controllers: [ServerController],
|
||||
providers: [ServerService],
|
||||
}).compile();
|
||||
|
||||
serverController = app.get<ServerController>(ServerController);
|
||||
});
|
||||
|
||||
describe('root', () => {
|
||||
it('should return "Hello World!"', () => {
|
||||
expect(serverController.getHello()).toBe('Hello World!');
|
||||
});
|
||||
});
|
||||
});
|
12
apps/server/src/server.controller.ts
Normal file
12
apps/server/src/server.controller.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { Controller, Get } from '@nestjs/common';
|
||||
import { ServerService } from './server.service';
|
||||
|
||||
@Controller()
|
||||
export class ServerController {
|
||||
constructor(private readonly serverService: ServerService) {}
|
||||
|
||||
@Get()
|
||||
getHello(): string {
|
||||
return this.serverService.getHello();
|
||||
}
|
||||
}
|
19
apps/server/src/server.module.ts
Normal file
19
apps/server/src/server.module.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ServerController } from './server.controller';
|
||||
import { ServerService } from './server.service';
|
||||
import { natsClient } from '@freeblox/shared';
|
||||
import { ClientsModule } from '@nestjs/microservices';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
ClientsModule.register([
|
||||
natsClient('server'),
|
||||
natsClient('auth'),
|
||||
natsClient('game'),
|
||||
natsClient('player'),
|
||||
]),
|
||||
],
|
||||
controllers: [ServerController],
|
||||
providers: [ServerService],
|
||||
})
|
||||
export class ServerModule {}
|
8
apps/server/src/server.service.ts
Normal file
8
apps/server/src/server.service.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class ServerService {
|
||||
getHello(): string {
|
||||
return 'Hello World!';
|
||||
}
|
||||
}
|
24
apps/server/test/app.e2e-spec.ts
Normal file
24
apps/server/test/app.e2e-spec.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import * as request from 'supertest';
|
||||
import { ServerModule } from './../src/server.module';
|
||||
|
||||
describe('ServerController (e2e)', () => {
|
||||
let app: INestApplication;
|
||||
|
||||
beforeEach(async () => {
|
||||
const moduleFixture: TestingModule = await Test.createTestingModule({
|
||||
imports: [ServerModule],
|
||||
}).compile();
|
||||
|
||||
app = moduleFixture.createNestApplication();
|
||||
await app.init();
|
||||
});
|
||||
|
||||
it('/ (GET)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/')
|
||||
.expect(200)
|
||||
.expect('Hello World!');
|
||||
});
|
||||
});
|
9
apps/server/test/jest-e2e.json
Normal file
9
apps/server/test/jest-e2e.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"moduleFileExtensions": ["js", "json", "ts"],
|
||||
"rootDir": ".",
|
||||
"testEnvironment": "node",
|
||||
"testRegex": ".e2e-spec.ts$",
|
||||
"transform": {
|
||||
"^.+\\.(t|j)s$": "ts-jest"
|
||||
}
|
||||
}
|
9
apps/server/tsconfig.app.json
Normal file
9
apps/server/tsconfig.app.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"declaration": false,
|
||||
"outDir": "../../dist/apps/server"
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist", "test", "**/*spec.ts"]
|
||||
}
|
18
apps/session/src/main.ts
Normal file
18
apps/session/src/main.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { SessionModule } from './session.module';
|
||||
import { MicroserviceOptions, Transport } from '@nestjs/microservices';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.createMicroservice<MicroserviceOptions>(
|
||||
SessionModule,
|
||||
{
|
||||
transport: Transport.NATS,
|
||||
options: {
|
||||
servers: ['nats://localhost:4222'],
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
await app.listen();
|
||||
}
|
||||
bootstrap();
|
22
apps/session/src/session.controller.spec.ts
Normal file
22
apps/session/src/session.controller.spec.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { SessionController } from './session.controller';
|
||||
import { SessionService } from './session.service';
|
||||
|
||||
describe('SessionController', () => {
|
||||
let sessionController: SessionController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const app: TestingModule = await Test.createTestingModule({
|
||||
controllers: [SessionController],
|
||||
providers: [SessionService],
|
||||
}).compile();
|
||||
|
||||
sessionController = app.get<SessionController>(SessionController);
|
||||
});
|
||||
|
||||
describe('root', () => {
|
||||
it('should return "Hello World!"', () => {
|
||||
expect(sessionController.getHello()).toBe('Hello World!');
|
||||
});
|
||||
});
|
||||
});
|
12
apps/session/src/session.controller.ts
Normal file
12
apps/session/src/session.controller.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { Controller, Get } from '@nestjs/common';
|
||||
import { SessionService } from './session.service';
|
||||
|
||||
@Controller()
|
||||
export class SessionController {
|
||||
constructor(private readonly sessionService: SessionService) {}
|
||||
|
||||
@Get()
|
||||
getHello(): string {
|
||||
return this.sessionService.getHello();
|
||||
}
|
||||
}
|
18
apps/session/src/session.module.ts
Normal file
18
apps/session/src/session.module.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { SessionController } from './session.controller';
|
||||
import { SessionService } from './session.service';
|
||||
import { ClientsModule } from '@nestjs/microservices';
|
||||
import { natsClient } from '@freeblox/shared';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
ClientsModule.register([
|
||||
natsClient('session'),
|
||||
natsClient('server'),
|
||||
natsClient('auth'),
|
||||
]),
|
||||
],
|
||||
controllers: [SessionController],
|
||||
providers: [SessionService],
|
||||
})
|
||||
export class SessionModule {}
|
8
apps/session/src/session.service.ts
Normal file
8
apps/session/src/session.service.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class SessionService {
|
||||
getHello(): string {
|
||||
return 'Hello World!';
|
||||
}
|
||||
}
|
24
apps/session/test/app.e2e-spec.ts
Normal file
24
apps/session/test/app.e2e-spec.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import * as request from 'supertest';
|
||||
import { SessionModule } from './../src/session.module';
|
||||
|
||||
describe('SessionController (e2e)', () => {
|
||||
let app: INestApplication;
|
||||
|
||||
beforeEach(async () => {
|
||||
const moduleFixture: TestingModule = await Test.createTestingModule({
|
||||
imports: [SessionModule],
|
||||
}).compile();
|
||||
|
||||
app = moduleFixture.createNestApplication();
|
||||
await app.init();
|
||||
});
|
||||
|
||||
it('/ (GET)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/')
|
||||
.expect(200)
|
||||
.expect('Hello World!');
|
||||
});
|
||||
});
|
9
apps/session/test/jest-e2e.json
Normal file
9
apps/session/test/jest-e2e.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"moduleFileExtensions": ["js", "json", "ts"],
|
||||
"rootDir": ".",
|
||||
"testEnvironment": "node",
|
||||
"testRegex": ".e2e-spec.ts$",
|
||||
"transform": {
|
||||
"^.+\\.(t|j)s$": "ts-jest"
|
||||
}
|
||||
}
|
9
apps/session/tsconfig.app.json
Normal file
9
apps/session/tsconfig.app.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"declaration": false,
|
||||
"outDir": "../../dist/apps/session"
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist", "test", "**/*spec.ts"]
|
||||
}
|
19
docker-compose.yml
Normal file
19
docker-compose.yml
Normal file
@ -0,0 +1,19 @@
|
||||
version: '3.8'
|
||||
services:
|
||||
nats:
|
||||
container_name: fblx-nats
|
||||
image: nats
|
||||
ports:
|
||||
- 4222:4222
|
||||
- 6222:6222
|
||||
- 8222:8222
|
||||
postgres:
|
||||
container_name: fblx-pg
|
||||
image: postgres:15-alpine
|
||||
ports:
|
||||
- 5432:5432
|
||||
environment:
|
||||
- POSTGRES_USER=freeblox
|
||||
- POSTGRES_PASSWORD=FREEBLOXDataBaseDEV@123
|
||||
volumes:
|
||||
- ./database:/var/lib/postgresql/data
|
3
libs/shared/src/index.ts
Normal file
3
libs/shared/src/index.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export * from './shared.module';
|
||||
export * from './shared.service';
|
||||
export * from './utils/nats-client';
|
8
libs/shared/src/shared.module.ts
Normal file
8
libs/shared/src/shared.module.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { SharedService } from './shared.service';
|
||||
|
||||
@Module({
|
||||
providers: [SharedService],
|
||||
exports: [SharedService],
|
||||
})
|
||||
export class SharedModule {}
|
18
libs/shared/src/shared.service.spec.ts
Normal file
18
libs/shared/src/shared.service.spec.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { SharedService } from './shared.service';
|
||||
|
||||
describe('SharedService', () => {
|
||||
let service: SharedService;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [SharedService],
|
||||
}).compile();
|
||||
|
||||
service = module.get<SharedService>(SharedService);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(service).toBeDefined();
|
||||
});
|
||||
});
|
4
libs/shared/src/shared.service.ts
Normal file
4
libs/shared/src/shared.service.ts
Normal file
@ -0,0 +1,4 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class SharedService {}
|
10
libs/shared/src/utils/nats-client.ts
Normal file
10
libs/shared/src/utils/nats-client.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import { ClientProviderOptions, Transport } from '@nestjs/microservices';
|
||||
|
||||
export const natsClient = (name: string) =>
|
||||
<ClientProviderOptions>{
|
||||
name,
|
||||
transport: Transport.NATS,
|
||||
options: {
|
||||
servers: ['nats://localhost:4222'],
|
||||
},
|
||||
};
|
9
libs/shared/tsconfig.lib.json
Normal file
9
libs/shared/tsconfig.lib.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"outDir": "../../dist/libs/shared"
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist", "test", "**/*spec.ts"]
|
||||
}
|
85
nest-cli.json
Normal file
85
nest-cli.json
Normal file
@ -0,0 +1,85 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/nest-cli",
|
||||
"collection": "@nestjs/schematics",
|
||||
"sourceRoot": "apps/freeblox-web-service/src",
|
||||
"monorepo": true,
|
||||
"root": "apps/freeblox-web-service",
|
||||
"compilerOptions": {
|
||||
"webpack": true,
|
||||
"tsConfigPath": "apps/freeblox-web-service/tsconfig.app.json"
|
||||
},
|
||||
"projects": {
|
||||
"freeblox-web-service": {
|
||||
"type": "application",
|
||||
"root": "apps/freeblox-web-service",
|
||||
"entryFile": "main",
|
||||
"sourceRoot": "apps/freeblox-web-service/src",
|
||||
"compilerOptions": {
|
||||
"tsConfigPath": "apps/freeblox-web-service/tsconfig.app.json"
|
||||
}
|
||||
},
|
||||
"auth": {
|
||||
"type": "application",
|
||||
"root": "apps/auth",
|
||||
"entryFile": "main",
|
||||
"sourceRoot": "apps/auth/src",
|
||||
"compilerOptions": {
|
||||
"tsConfigPath": "apps/auth/tsconfig.app.json"
|
||||
}
|
||||
},
|
||||
"shared": {
|
||||
"type": "library",
|
||||
"root": "libs/shared",
|
||||
"entryFile": "index",
|
||||
"sourceRoot": "libs/shared/src",
|
||||
"compilerOptions": {
|
||||
"tsConfigPath": "libs/shared/tsconfig.lib.json"
|
||||
}
|
||||
},
|
||||
"player": {
|
||||
"type": "application",
|
||||
"root": "apps/player",
|
||||
"entryFile": "main",
|
||||
"sourceRoot": "apps/player/src",
|
||||
"compilerOptions": {
|
||||
"tsConfigPath": "apps/player/tsconfig.app.json"
|
||||
}
|
||||
},
|
||||
"game": {
|
||||
"type": "application",
|
||||
"root": "apps/game",
|
||||
"entryFile": "main",
|
||||
"sourceRoot": "apps/game/src",
|
||||
"compilerOptions": {
|
||||
"tsConfigPath": "apps/game/tsconfig.app.json"
|
||||
}
|
||||
},
|
||||
"server": {
|
||||
"type": "application",
|
||||
"root": "apps/server",
|
||||
"entryFile": "main",
|
||||
"sourceRoot": "apps/server/src",
|
||||
"compilerOptions": {
|
||||
"tsConfigPath": "apps/server/tsconfig.app.json"
|
||||
}
|
||||
},
|
||||
"session": {
|
||||
"type": "application",
|
||||
"root": "apps/session",
|
||||
"entryFile": "main",
|
||||
"sourceRoot": "apps/session/src",
|
||||
"compilerOptions": {
|
||||
"tsConfigPath": "apps/session/tsconfig.app.json"
|
||||
}
|
||||
},
|
||||
"catalog": {
|
||||
"type": "application",
|
||||
"root": "apps/catalog",
|
||||
"entryFile": "main",
|
||||
"sourceRoot": "apps/catalog/src",
|
||||
"compilerOptions": {
|
||||
"tsConfigPath": "apps/catalog/tsconfig.app.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
90
package.json
Normal file
90
package.json
Normal file
@ -0,0 +1,90 @@
|
||||
{
|
||||
"name": "@freeblox/web-service",
|
||||
"version": "0.0.1",
|
||||
"description": "",
|
||||
"author": "",
|
||||
"private": true,
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"scripts": {
|
||||
"prebuild": "rimraf dist",
|
||||
"build": "nest build",
|
||||
"format": "prettier --write \"apps/**/*.ts\" \"libs/**/*.ts\"",
|
||||
"start": "nest start",
|
||||
"start:dev": "nest start --watch",
|
||||
"start:debug": "nest start --debug --watch",
|
||||
"start:prod": "node dist/main",
|
||||
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
||||
"test": "jest",
|
||||
"test:watch": "jest --watch",
|
||||
"test:cov": "jest --coverage",
|
||||
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
||||
"test:e2e": "jest --config ./apps/freeblox-web-service/test/jest-e2e.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/axios": "^3.0.0",
|
||||
"@nestjs/common": "^10.0.3",
|
||||
"@nestjs/config": "^3.0.0",
|
||||
"@nestjs/core": "^10.0.3",
|
||||
"@nestjs/microservices": "^10.0.3",
|
||||
"@nestjs/platform-express": "^10.0.3",
|
||||
"@nestjs/swagger": "^7.0.11",
|
||||
"@nestjs/typeorm": "^10.0.0",
|
||||
"axios": "^1.4.0",
|
||||
"class-transformer": "^0.5.1",
|
||||
"class-validator": "^0.14.0",
|
||||
"knex": "^2.4.2",
|
||||
"nats": "^2.15.1",
|
||||
"pg": "^8.11.1",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^5.0.1",
|
||||
"rxjs": "^7.8.1",
|
||||
"typeorm": "^0.3.17"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/cli": "^10.0.5",
|
||||
"@nestjs/schematics": "^10.0.1",
|
||||
"@nestjs/testing": "^10.0.3",
|
||||
"@types/express": "^4.17.17",
|
||||
"@types/jest": "29.5.2",
|
||||
"@types/node": "^20.3.2",
|
||||
"@types/supertest": "^2.0.12",
|
||||
"@typescript-eslint/eslint-plugin": "^5.60.1",
|
||||
"@typescript-eslint/parser": "^5.60.1",
|
||||
"eslint": "^8.43.0",
|
||||
"eslint-config-prettier": "^8.8.0",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"jest": "29.5.0",
|
||||
"prettier": "^2.8.8",
|
||||
"source-map-support": "^0.5.21",
|
||||
"supertest": "^6.3.3",
|
||||
"ts-jest": "29.1.0",
|
||||
"ts-loader": "^9.4.4",
|
||||
"ts-node": "^10.9.1",
|
||||
"tsconfig-paths": "4.2.0",
|
||||
"typescript": "^5.1.5"
|
||||
},
|
||||
"jest": {
|
||||
"moduleFileExtensions": [
|
||||
"js",
|
||||
"json",
|
||||
"ts"
|
||||
],
|
||||
"rootDir": ".",
|
||||
"testRegex": ".*\\.spec\\.ts$",
|
||||
"transform": {
|
||||
"^.+\\.(t|j)s$": "ts-jest"
|
||||
},
|
||||
"collectCoverageFrom": [
|
||||
"**/*.(t|j)s"
|
||||
],
|
||||
"coverageDirectory": "./coverage",
|
||||
"testEnvironment": "node",
|
||||
"roots": [
|
||||
"<rootDir>/apps/",
|
||||
"<rootDir>/libs/"
|
||||
],
|
||||
"moduleNameMapper": {
|
||||
"^@freeblox/shared(|/.*)$": "<rootDir>/libs/shared/src/$1"
|
||||
}
|
||||
}
|
||||
}
|
5767
pnpm-lock.yaml
generated
Normal file
5767
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
4
tsconfig.build.json
Normal file
4
tsconfig.build.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
|
||||
}
|
29
tsconfig.json
Normal file
29
tsconfig.json
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"declaration": true,
|
||||
"removeComments": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"target": "es2017",
|
||||
"sourceMap": true,
|
||||
"outDir": "./dist",
|
||||
"baseUrl": "./",
|
||||
"incremental": true,
|
||||
"skipLibCheck": true,
|
||||
"strictNullChecks": false,
|
||||
"noImplicitAny": false,
|
||||
"strictBindCallApply": false,
|
||||
"forceConsistentCasingInFileNames": false,
|
||||
"noFallthroughCasesInSwitch": false,
|
||||
"paths": {
|
||||
"@freeblox/shared": [
|
||||
"libs/shared/src"
|
||||
],
|
||||
"@freeblox/shared/*": [
|
||||
"libs/shared/src/*"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user