Skip to content

Commit 4b5d7f5

Browse files
committed
feat: account scope
1 parent e6dc98c commit 4b5d7f5

File tree

112 files changed

+9411
-920
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+9411
-920
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

.eslintrc.json

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"root": true,
3+
"ignorePatterns": ["**/*"],
4+
"plugins": ["@nx"],
5+
"overrides": [
6+
{
7+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
8+
"rules": {
9+
"@nx/enforce-module-boundaries": [
10+
"error",
11+
{
12+
"enforceBuildableLibDependency": true,
13+
"allow": [],
14+
"depConstraints": [
15+
{
16+
"sourceTag": "*",
17+
"onlyDependOnLibsWithTags": ["*"]
18+
}
19+
]
20+
}
21+
]
22+
}
23+
},
24+
{
25+
"files": ["*.ts", "*.tsx"],
26+
"extends": ["plugin:@nx/typescript"],
27+
"rules": {}
28+
},
29+
{
30+
"files": ["*.js", "*.jsx"],
31+
"extends": ["plugin:@nx/javascript"],
32+
"rules": {}
33+
},
34+
{
35+
"files": ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"],
36+
"env": {
37+
"jest": true
38+
},
39+
"rules": {}
40+
}
41+
]
42+
}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@ Thumbs.db
4040

4141
.nx/cache
4242
.nx/workspace-data
43+
.env

.prettierignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Add files here to ignore them from prettier formatting
2+
/dist
3+
/coverage
4+
/.nx/cache
5+
/.nx/workspace-data

.prettierrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"singleQuote": true
3+
}

.vscode/extensions.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"recommendations": [
3-
43
"nrwl.angular-console",
5-
"esbenp.prettier-vscode"
4+
"esbenp.prettier-vscode",
5+
"firsttris.vscode-jest-runner"
66
]
77
}

apps/server/.eslintrc.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"extends": ["../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
7+
"rules": {}
8+
},
9+
{
10+
"files": ["*.ts", "*.tsx"],
11+
"rules": {}
12+
},
13+
{
14+
"files": ["*.js", "*.jsx"],
15+
"rules": {}
16+
}
17+
]
18+
}

apps/server/jest.config.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* eslint-disable */
2+
export default {
3+
displayName: 'server',
4+
preset: '../../jest.preset.js',
5+
testEnvironment: 'node',
6+
transform: {
7+
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
8+
},
9+
moduleFileExtensions: ['ts', 'js', 'html'],
10+
coverageDirectory: '../../coverage/apps/server',
11+
};

apps/server/project.json

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "server",
3+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "apps/server/src",
5+
"projectType": "application",
6+
"tags": [],
7+
"targets": {
8+
"serve": {
9+
"executor": "@nx/js:node",
10+
"defaultConfiguration": "development",
11+
"dependsOn": ["build"],
12+
"options": {
13+
"buildTarget": "server:build",
14+
"runBuildTargetDependencies": false
15+
},
16+
"configurations": {
17+
"development": {
18+
"buildTarget": "server:build:development"
19+
},
20+
"production": {
21+
"buildTarget": "server:build:production"
22+
}
23+
}
24+
}
25+
}
26+
}
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Test, TestingModule } from '@nestjs/testing';
2+
3+
import { AppController } from './app.controller';
4+
import { AppService } from './app.service';
5+
6+
describe('AppController', () => {
7+
let app: TestingModule;
8+
9+
beforeAll(async () => {
10+
app = await Test.createTestingModule({
11+
controllers: [AppController],
12+
providers: [AppService],
13+
}).compile();
14+
});
15+
16+
describe('getData', () => {
17+
it('should return "Hello API"', () => {
18+
const appController = app.get<AppController>(AppController);
19+
expect(appController.getData()).toEqual({ message: 'Hello API' });
20+
});
21+
});
22+
});

apps/server/src/app/app.controller.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Controller, Get } from '@nestjs/common';
2+
3+
import { AppService } from './app.service';
4+
5+
@Controller()
6+
export class AppController {
7+
constructor(private readonly appService: AppService) {}
8+
9+
@Get()
10+
getData() {
11+
return this.appService.getData();
12+
}
13+
}

apps/server/src/app/app.module.ts

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { Module } from '@nestjs/common';
2+
import { TypeOrmModule } from '@nestjs/typeorm';
3+
import { ResourceAccountModule } from '@platform/resource-account';
4+
import { UserEntity } from '@platform/data-source-account';
5+
import { AppController } from './app.controller';
6+
import { AppService } from './app.service';
7+
import { env } from '../envs/env';
8+
9+
@Module({
10+
imports: [
11+
TypeOrmModule.forRoot({
12+
type: 'mysql',
13+
host: 'localhost',
14+
port: 3306,
15+
username: 'root',
16+
password: env.db.password,
17+
database: env.db.name,
18+
entities: [UserEntity],
19+
synchronize: true,
20+
}),
21+
ResourceAccountModule,
22+
],
23+
controllers: [AppController],
24+
providers: [AppService],
25+
})
26+
export class AppModule {}
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { Test } from '@nestjs/testing';
2+
3+
import { AppService } from './app.service';
4+
5+
describe('AppService', () => {
6+
let service: AppService;
7+
8+
beforeAll(async () => {
9+
const app = await Test.createTestingModule({
10+
providers: [AppService],
11+
}).compile();
12+
13+
service = app.get<AppService>(AppService);
14+
});
15+
16+
describe('getData', () => {
17+
it('should return "Hello API"', () => {
18+
expect(service.getData()).toEqual({ message: 'Hello API' });
19+
});
20+
});
21+
});

apps/server/src/app/app.service.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { Injectable } from '@nestjs/common';
2+
3+
@Injectable()
4+
export class AppService {
5+
getData(): { message: string } {
6+
return { message: 'Hello API' };
7+
}
8+
}

apps/server/src/assets/.gitkeep

Whitespace-only changes.

apps/server/src/envs/env.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
export const env = {
3+
db: {
4+
name: process.env.DB_NAME,
5+
password: process.env.DB_PASSWORD,
6+
}
7+
}

apps/server/src/main.ts

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* This is not a production server yet!
3+
* This is only a minimal backend to get started.
4+
*/
5+
6+
import { Logger } from '@nestjs/common';
7+
import { NestFactory } from '@nestjs/core';
8+
9+
import { AppModule } from './app/app.module';
10+
11+
async function bootstrap() {
12+
const app = await NestFactory.create(AppModule);
13+
const globalPrefix = 'api';
14+
app.setGlobalPrefix(globalPrefix);
15+
const port = process.env.PORT || 3000;
16+
await app.listen(port);
17+
Logger.log(
18+
`🚀 Application is running on: http://localhost:${port}/${globalPrefix}`
19+
);
20+
}
21+
22+
bootstrap();

apps/server/tsconfig.app.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../../dist/out-tsc",
5+
"module": "commonjs",
6+
"types": ["node"],
7+
"emitDecoratorMetadata": true,
8+
"target": "es2021",
9+
"strictNullChecks": true,
10+
"noImplicitAny": true,
11+
"strictBindCallApply": true,
12+
"forceConsistentCasingInFileNames": true,
13+
"noFallthroughCasesInSwitch": true
14+
},
15+
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"],
16+
"include": ["src/**/*.ts"]
17+
}

apps/server/tsconfig.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"files": [],
4+
"include": [],
5+
"references": [
6+
{
7+
"path": "./tsconfig.app.json"
8+
},
9+
{
10+
"path": "./tsconfig.spec.json"
11+
}
12+
],
13+
"compilerOptions": {
14+
"esModuleInterop": true
15+
}
16+
}

apps/server/tsconfig.spec.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../../dist/out-tsc",
5+
"module": "commonjs",
6+
"types": ["jest", "node"]
7+
},
8+
"include": [
9+
"jest.config.ts",
10+
"src/**/*.test.ts",
11+
"src/**/*.spec.ts",
12+
"src/**/*.d.ts"
13+
]
14+
}

apps/server/webpack.config.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const { NxAppWebpackPlugin } = require('@nx/webpack/app-plugin');
2+
const { join } = require('path');
3+
4+
module.exports = {
5+
output: {
6+
path: join(__dirname, '../../dist/apps/server'),
7+
},
8+
plugins: [
9+
new NxAppWebpackPlugin({
10+
target: 'node',
11+
compiler: 'tsc',
12+
main: './src/main.ts',
13+
tsConfig: './tsconfig.app.json',
14+
assets: ['./src/assets'],
15+
optimization: false,
16+
outputHashing: 'none',
17+
generatePackageJson: true,
18+
}),
19+
],
20+
};

docker-compose.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: "3"
2+
3+
services:
4+
mysql:
5+
image: mysql:8
6+
restart: always
7+
environment:
8+
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
9+
MYSQL_DATABASE: ${DB_NAME}
10+
ports:
11+
- "3306:3306"

jest.config.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { getJestProjectsAsync } from '@nx/jest';
2+
3+
export default async () => ({
4+
projects: await getJestProjectsAsync(),
5+
});

jest.preset.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const nxPreset = require('@nx/jest/preset').default;
2+
3+
module.exports = { ...nxPreset };

0 commit comments

Comments
 (0)