Merge pull request #1 from IT-Lab-KubSU/feature/initial-agw-setup

Feature/initial agw setup
main
Artem-Darius Weber 2 years ago committed by GitHub
commit 6e97c98add
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,5 @@
PGADMIN_DEFAULT_EMAIL: placeholder@example.com
PGADMIN_DEFAULT_PASSWORD: fakepassword123!
POSTGRES_USER=root
POSTGRES_PASSWORD=root
POSTGRES_DB=root

@ -25,6 +25,14 @@
To start the development server run `nx serve frontend`. Open your browser and navigate to http://localhost:4200/. Happy coding!
Run all services:
```
nx run-many --parallel --target=serve --projects=agw,frontend
```
<a style="padding: 10px; background: black; color: white; border-radius: 25px;" href="https://l.djft.ru/r/72/p/itlabplatform1/a/p/a/">
Deploy on SCOS
</a>
## Структура репозитория
Репозиторий содержит следующие основные каталоги и файлы:
@ -33,6 +41,13 @@ To start the development server run `nx serve frontend`. Open your browser and n
- `tools` - Nx workspaces tools
- `docs` - документация
```mermaid
graph TD;
agw-e2w-->agw;
frontend-e2e-->frontend;
frontend-->agw;
```
## Generate code
If you happen to use Nx plugins, you can leverage code generators that might come with it.
@ -70,3 +85,19 @@ Have a look at the [Nx Console extensions](https://nx.dev/nx-console). It provid
## Ready to deploy?
Just run `nx build demoapp` to build the application. The build artifacts will be stored in the `dist/` directory, ready to be deployed.
# Стиль кода
## Коммиты
Используемые префиксы:
- **feat:** (от "feature") - новая функциональность или добавление нового компонента.
- **fix:** - исправление ошибок или дефектов.
- **docs:** - изменения, связанные с документацией, например, обновление README или документации в коде.
- **style:** - изменения внешнего вида кода, форматирование, пробелы, отступы и т.д., которые не влияют на его поведение.
- **refactor:** - рефакторинг кода без исправления ошибок или добавления новых функций.
- **test:** - добавление или исправление тестов.
- **chore:** - изменения в сборочных скриптах, настройках инструментов, обновление зависимостей и т.д.
- **perf:** - изменения, связанные с оптимизацией производительности.
- **revert:** - отмена предыдущего коммита.
- **merge:** - коммит, созданный при слиянии веток.
- **release:** - коммит, связанный с выпуском новой версии.
- **require:** - коммит, связанный с установкой новой библиотеки

@ -0,0 +1,10 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
}
]
}

@ -0,0 +1,19 @@
/* eslint-disable */
export default {
displayName: 'agw-e2e',
preset: '../../jest.preset.js',
globalSetup: '<rootDir>/src/support/global-setup.ts',
globalTeardown: '<rootDir>/src/support/global-teardown.ts',
setupFiles: ['<rootDir>/src/support/test-setup.ts'],
testEnvironment: 'node',
transform: {
'^.+\\.[tj]s$': [
'ts-jest',
{
tsconfig: '<rootDir>/tsconfig.spec.json',
},
],
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/agw-e2e',
};

@ -0,0 +1,22 @@
{
"name": "agw-e2e",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"implicitDependencies": ["agw"],
"targets": {
"e2e": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{e2eProjectRoot}"],
"options": {
"jestConfig": "apps/agw-e2e/jest.config.ts",
"passWithNoTests": true
}
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/agw-e2e/**/*.{js,ts}"]
}
}
}
}

@ -0,0 +1,10 @@
import axios from 'axios';
describe('GET /api', () => {
it('should return a message', async () => {
const res = await axios.get(`/api`);
expect(res.status).toBe(200);
expect(res.data).toEqual({ message: 'Hello API' });
});
});

@ -0,0 +1,10 @@
/* eslint-disable */
var __TEARDOWN_MESSAGE__: string;
module.exports = async function () {
// Start services that that the app needs to run (e.g. database, docker-compose, etc.).
console.log('\nSetting up...\n');
// Hint: Use `globalThis` to pass variables to global teardown.
globalThis.__TEARDOWN_MESSAGE__ = '\nTearing down...\n';
};

@ -0,0 +1,7 @@
/* eslint-disable */
module.exports = async function () {
// Put clean up logic here (e.g. stopping services, docker-compose, etc.).
// Hint: `globalThis` is shared between setup and teardown.
console.log(globalThis.__TEARDOWN_MESSAGE__);
};

@ -0,0 +1,10 @@
/* eslint-disable */
import axios from 'axios';
module.exports = async function () {
// Configure axios for tests to use.
const host = process.env.HOST ?? 'localhost';
const port = process.env.PORT ?? '3000';
axios.defaults.baseURL = `http://${host}:${port}`;
};

@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.spec.json"
}
],
"compilerOptions": {
"esModuleInterop": true
}
}

@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": ["jest.config.ts", "src/**/*.ts"]
}

@ -0,0 +1,18 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}

@ -0,0 +1,11 @@
/* eslint-disable */
export default {
displayName: 'agw',
preset: '../../jest.preset.js',
testEnvironment: 'node',
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/apps/agw',
};

@ -0,0 +1,64 @@
{
"name": "agw",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/agw/src",
"projectType": "application",
"targets": {
"build": {
"executor": "@nx/webpack:webpack",
"outputs": ["{options.outputPath}"],
"defaultConfiguration": "production",
"options": {
"target": "node",
"compiler": "tsc",
"outputPath": "dist/apps/agw",
"main": "apps/agw/src/main.ts",
"tsConfig": "apps/agw/tsconfig.app.json",
"assets": ["apps/agw/src/assets"],
"isolatedConfig": true,
"webpackConfig": "apps/agw/webpack.config.js"
},
"configurations": {
"development": {},
"production": {}
}
},
"serve": {
"executor": "@nx/js:node",
"defaultConfiguration": "development",
"options": {
"buildTarget": "agw:build"
},
"configurations": {
"development": {
"buildTarget": "agw:build:development"
},
"production": {
"buildTarget": "agw:build:production"
}
}
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/agw/**/*.ts"]
}
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "apps/agw/jest.config.ts",
"passWithNoTests": true
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
}
}
},
"tags": []
}

@ -0,0 +1,15 @@
import { Module } from '@nestjs/common';
import { GraphQLModule } from '@nestjs/graphql';
import { ApolloDriver, ApolloDriverConfig } from '@nestjs/apollo';
@Module({
imports: [
GraphQLModule.forRoot<ApolloDriverConfig>({
driver: ApolloDriver,
typePaths: ['./**/*.gql'],
context: ({ req }) => ({ req }),
playground: true,
}),
],
})
export class ApiGatewayModule {}

@ -0,0 +1,22 @@
import { Test, TestingModule } from '@nestjs/testing';
import { AppController } from './app.controller';
import { AppService } from './app.service';
describe('AppController', () => {
let app: TestingModule;
beforeAll(async () => {
app = await Test.createTestingModule({
controllers: [AppController],
providers: [AppService],
}).compile();
});
describe('getData', () => {
it('should return "Hello API"', () => {
const appController = app.get<AppController>(AppController);
expect(appController.getData()).toEqual({ message: 'Hello API' });
});
});
});

@ -0,0 +1,13 @@
import { Controller, Get } from '@nestjs/common';
import { AppService } from './app.service';
@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
@Get()
getData() {
return this.appService.getData();
}
}

@ -0,0 +1,12 @@
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import {ApiGatewayModule} from "../api-gateway/api-gateway.module";
@Module({
imports: [ApiGatewayModule],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}

@ -0,0 +1,21 @@
import { Test } from '@nestjs/testing';
import { AppService } from './app.service';
describe('AppService', () => {
let service: AppService;
beforeAll(async () => {
const app = await Test.createTestingModule({
providers: [AppService],
}).compile();
service = app.get<AppService>(AppService);
});
describe('getData', () => {
it('should return "Hello API"', () => {
expect(service.getData()).toEqual({ message: 'Hello API' });
});
});
});

@ -0,0 +1,8 @@
import { Injectable } from '@nestjs/common';
@Injectable()
export class AppService {
getData(): { message: string } {
return { message: 'Hello API' };
}
}

@ -0,0 +1,22 @@
/**
* This is not a production server yet!
* This is only a minimal backend to get started.
*/
import { Logger } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app/app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
const globalPrefix = 'api';
app.setGlobalPrefix(globalPrefix);
const port = process.env.PORT || 3000;
await app.listen(port);
Logger.log(
`🚀 Application is running on: http://localhost:${port}/${globalPrefix}`
);
}
bootstrap();

@ -0,0 +1,36 @@
type User {
id: ID!
name: String!
email: String!
password: String!
createdAt: String!
updatedAt: String!
}
type AuthPayload {
token: String!
user: User!
}
input SignUpInput {
name: String!
email: String!
password: String!
}
input SignInInput {
email: String!
password: String!
}
type Query {
me: User! @authenticated
}
type Mutation {
signUp(input: SignUpInput!): AuthPayload!
signIn(input: SignInInput!): AuthPayload!
signOut: Boolean! @authenticated
}
directive @authenticated on FIELD_DEFINITION

@ -0,0 +1,12 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["node"],
"emitDecoratorMetadata": true,
"target": "es2021"
},
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"],
"include": ["src/**/*.ts"]
}

@ -0,0 +1,16 @@
{
"extends": "../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.spec.json"
}
],
"compilerOptions": {
"esModuleInterop": true
}
}

@ -0,0 +1,14 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": [
"jest.config.ts",
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/**/*.d.ts"
]
}

@ -0,0 +1,8 @@
const { composePlugins, withNx } = require('@nx/webpack');
// Nx plugins for webpack.
module.exports = composePlugins(withNx(), (config) => {
// Update the webpack config as needed here.
// e.g. `config.plugins.push(new MyPlugin())`
return config;
});

@ -49,7 +49,8 @@
"defaultConfiguration": "development",
"options": {
"buildTarget": "frontend:build",
"hmr": true
"hmr": true,
"proxyConfig": "apps/frontend/proxy.conf.json"
},
"configurations": {
"development": {

@ -0,0 +1,6 @@
{
"/api": {
"target": "http://localhost:3000",
"secure": false
}
}

2146
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -5,18 +5,34 @@
"scripts": {},
"private": true,
"dependencies": {
"@apollo/server": "^4.7.5",
"@nestjs/apollo": "^12.0.3",
"@nestjs/common": "^10.0.2",
"@nestjs/core": "^10.0.2",
"@nestjs/graphql": "^12.0.3",
"@nestjs/platform-express": "^10.0.2",
"@nestjs/typeorm": "^10.0.0",
"@swc/helpers": "~0.5.0",
"axios": "^1.0.0",
"graphql": "^16.7.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.8.0",
"tslib": "^2.3.0"
},
"devDependencies": {
"@babel/preset-react": "^7.14.5",
"@nestjs/schematics": "^10.0.1",
"@nestjs/testing": "^10.0.2",
"@nrwl/nest": "^16.4.0",
"@nx/cypress": "16.4.0",
"@nx/eslint-plugin": "16.4.0",
"@nx/jest": "16.4.0",
"@nx/js": "16.4.0",
"@nx/linter": "16.4.0",
"@nx/nest": "16.4.0",
"@nx/node": "16.4.0",
"@nx/react": "16.4.0",
"@nx/webpack": "16.4.0",
"@nx/workspace": "16.4.0",
@ -42,6 +58,7 @@
"eslint-plugin-react-hooks": "4.6.0",
"jest": "^29.4.1",
"jest-environment-jsdom": "^29.4.1",
"jest-environment-node": "^29.4.1",
"nx": "16.4.0",
"nx-cloud": "latest",
"prettier": "^2.6.2",

Loading…
Cancel
Save