Skip to content

Commit 9e8cb9a

Browse files
committed
Add files
1 parent 2be0c62 commit 9e8cb9a

17 files changed

+404
-74
lines changed

apps/auth/src/app/app.module.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,18 @@ import { NxWelcomeComponent } from './nx-welcome.component';
2222
TuiRootModule,
2323
TuiDialogModule,
2424
TuiAlertModule,
25-
RouterModule.forRoot([], { initialNavigation: 'enabledBlocking' }),
25+
RouterModule.forRoot(
26+
[
27+
{
28+
path: 'sign-in',
29+
loadComponent: () =>
30+
import('./sign-in/sign-in.component').then(
31+
(mod) => mod.SignInComponent
32+
),
33+
},
34+
],
35+
{ initialNavigation: 'enabledBlocking' }
36+
),
2637
],
2738
providers: [{ provide: TUI_SANITIZER, useClass: NgDompurifySanitizer }],
2839
bootstrap: [AppComponent],
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { FormControl } from '@angular/forms';
2+
3+
export interface SignInForm {
4+
email: FormControl<string>;
5+
password: FormControl<string>;
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<div class="container">
2+
<div class="tui-row">
3+
<div class="tui-col_md-6 debug4">
4+
<div size="l" tuiIsland class="card debug3">
5+
<div class="tui-island__content debug2">
6+
<div class="debug1">
7+
<h3 class="tui-island__title">Sign In</h3>
8+
<form [formGroup]="form" (ngSubmit)="onSubmit()">
9+
<div class="tui-form__row">
10+
<tui-input formControlName="email" [tuiTextfieldCleaner]="true">
11+
Enter your email
12+
<span class="tui-required"></span>
13+
14+
<input tuiTextfield type="email" />
15+
</tui-input>
16+
</div>
17+
<div class="tui-form__row">
18+
<tui-input-password
19+
formControlName="password"
20+
class="tui-space_top-2"
21+
>
22+
Enter your password
23+
<input tuiTextfield placeholder="Make it secure!" />
24+
</tui-input-password>
25+
</div>
26+
<div class="tui-form__row">
27+
<button tuiIconButton type="submit" [disabled]="form.invalid">
28+
Sign In
29+
</button>
30+
</div>
31+
</form>
32+
</div>
33+
</div>
34+
</div>
35+
</div>
36+
</div>
37+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.card {
2+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { SignInComponent } from './sign-in.component';
4+
5+
describe('SignInComponent', () => {
6+
let component: SignInComponent;
7+
let fixture: ComponentFixture<SignInComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
imports: [ SignInComponent ]
12+
})
13+
.compileComponents();
14+
15+
fixture = TestBed.createComponent(SignInComponent);
16+
component = fixture.componentInstance;
17+
fixture.detectChanges();
18+
});
19+
20+
it('should create', () => {
21+
expect(component).toBeTruthy();
22+
});
23+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
2+
import { CommonModule } from '@angular/common';
3+
import {
4+
FormBuilder,
5+
FormGroup,
6+
FormsModule,
7+
NonNullableFormBuilder,
8+
ReactiveFormsModule,
9+
Validators,
10+
} from '@angular/forms';
11+
12+
import {
13+
TuiInputModule,
14+
TuiInputPasswordModule,
15+
TuiIslandModule,
16+
} from '@taiga-ui/kit';
17+
import { TuiButtonModule, TuiTextfieldControllerModule } from '@taiga-ui/core';
18+
import { SignInForm } from './interfaces/sign-in-form.interface';
19+
20+
@Component({
21+
standalone: true,
22+
imports: [
23+
CommonModule,
24+
TuiIslandModule,
25+
TuiInputModule,
26+
FormsModule,
27+
ReactiveFormsModule,
28+
TuiTextfieldControllerModule,
29+
TuiInputPasswordModule,
30+
TuiButtonModule,
31+
],
32+
templateUrl: './sign-in.component.html',
33+
styleUrls: ['./sign-in.component.scss'],
34+
changeDetection: ChangeDetectionStrategy.OnPush,
35+
})
36+
export class SignInComponent implements OnInit {
37+
form!: FormGroup<SignInForm>;
38+
39+
constructor(private readonly fb: NonNullableFormBuilder) {}
40+
41+
ngOnInit(): void {
42+
this.form = this.fb.group({
43+
email: [
44+
'',
45+
[Validators.required, Validators.maxLength(100), Validators.email],
46+
],
47+
password: [
48+
'',
49+
[
50+
Validators.required,
51+
Validators.minLength(8),
52+
Validators.pattern(
53+
/((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/
54+
),
55+
],
56+
],
57+
});
58+
}
59+
60+
onSubmit() {
61+
console.log(this.form.value);
62+
}
63+
}

apps/auth/src/styles.scss

+20
Original file line numberDiff line numberDiff line change
@@ -1 +1,21 @@
11
/* You can add global styles to this file, and also import other style files */
2+
3+
.debug1 {
4+
border: 2px solid red;
5+
}
6+
7+
.debug2 {
8+
border: 2px solid yellow;
9+
}
10+
11+
.debug3 {
12+
border: 2px solid blueviolet;
13+
}
14+
15+
.debug4 {
16+
border: 1px solid green;
17+
}
18+
19+
.debug5 {
20+
border: 1px solid black;
21+
}

apps/main-service/src/app/@common/modules/global.module.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Module, Global, CacheModule } from '@nestjs/common';
1+
import { CacheModule, Global, Module } from '@nestjs/common';
22
import { TypeOrmModule, TypeOrmModuleOptions } from '@nestjs/typeorm';
33
import { BullModule } from '@nestjs/bull';
44
import { ScheduleModule } from '@nestjs/schedule';
@@ -10,8 +10,8 @@ import { join } from 'path';
1010
import type { ClientOpts } from 'redis';
1111
import * as redisStore from 'cache-manager-redis-store';
1212
import {
13-
ApolloServerPluginSchemaReporting,
1413
ApolloServerPluginLandingPageLocalDefault,
14+
ApolloServerPluginSchemaReporting,
1515
} from 'apollo-server-core';
1616
import { MailerModule } from '@nestjs-modules/mailer';
1717
import { HandlebarsAdapter } from '@nestjs-modules/mailer/dist/adapters/handlebars.adapter';
@@ -65,8 +65,9 @@ import { Match } from '../validators/match.validator';
6565
TypeOrmModule.forFeature([Notification]),
6666
GraphQLModule.forRoot<ApolloDriverConfig>({
6767
driver: ApolloDriver,
68-
autoSchemaFile: true,
68+
cache: 'bounded',
6969
playground: false,
70+
autoSchemaFile: true,
7071
plugins: [
7172
ApolloServerPluginSchemaReporting(),
7273
ApolloServerPluginLandingPageLocalDefault(),

apps/main-service/src/app/app.service.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { CACHE_MANAGER, Inject, Injectable, Logger } from '@nestjs/common';
22
import { InjectQueue } from '@nestjs/bull';
3-
import { Interval } from '@nestjs/schedule';
3+
// import { Interval } from '@nestjs/schedule';
44

55
import { Cache } from 'cache-manager';
66

@@ -36,7 +36,7 @@ export class AppService {
3636

3737
// @Interval('sendSms', 2000)
3838
async sendSms() {
39-
let message = (await this.cache.get('message')) ?? 'Good morning';
39+
const message = (await this.cache.get('message')) ?? 'Good morning';
4040

4141
const responses = [1, 20, 45, 83, 96, 10, 2, 67];
4242
const repeat = responses[Math.floor(Math.random() * responses.length)];

apps/main-service/src/app/profile/entities/profile.entity.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ObjectType, Field } from '@nestjs/graphql';
1+
import { Field, ID, ObjectType } from '@nestjs/graphql';
22

33
import {
44
BeforeInsert,
@@ -21,6 +21,9 @@ import { Sex } from '../../@common/enums/sex.enum';
2121
@Entity()
2222
@ObjectType()
2323
export class Profile {
24+
@Field(() => ID, {
25+
description: 'This is the ID of the user profile',
26+
})
2427
@PrimaryGeneratedColumn()
2528
id: number;
2629

apps/main-service/src/app/profile/profile.module.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import { Profile } from './entities/profile.entity';
55

66
import { ProfileService } from './profile.service';
77

8-
import { ProfileResolver } from './profile.resolver';
8+
// import { ProfileResolver } from './profile.resolver';
99

1010
@Module({
1111
imports: [TypeOrmModule.forFeature([Profile])],
12-
providers: [ProfileResolver, ProfileService],
12+
providers: [ ProfileService],
1313
exports: [TypeOrmModule, ProfileService],
1414
})
1515
export class ProfileModule {}
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
import { Resolver, ResolveField, Parent } from '@nestjs/graphql';
2-
3-
import { Profile } from './entities/profile.entity';
4-
import { User } from '../users/entities/user.entity';
5-
6-
import { ProfileService } from './profile.service';
7-
8-
@Resolver()
9-
export class ProfileResolver {
10-
// constructor(private readonly profileService: ProfileService) {}
11-
//
12-
// @ResolveField('profile', () => Profile)
13-
// profile(@Parent() user: User) {
14-
// return this.profileService.findProfileById(user.profileId);
15-
// }
16-
}
1+
// import { Resolver } from '@nestjs/graphql';
2+
//
3+
// @Resolver()
4+
// export class ProfileResolver {
5+
// // constructor(private readonly profileService: ProfileService) {}
6+
// //
7+
// // @ResolveField('profile', () => Profile)
8+
// // profile(@Parent() user: User) {
9+
// // return this.profileService.findProfileById(user.profileId);
10+
// // }
11+
// }

apps/main-service/src/app/users/dto/create-user.input.ts

-7
This file was deleted.

apps/main-service/src/app/users/dto/update-user.input.ts

-8
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
1-
import { Resolver, Query, Mutation, Args, Int } from '@nestjs/graphql';
2-
import { UsersService } from './users.service';
1+
import { Resolver, Query, Args, Int } from '@nestjs/graphql';
2+
33
import { User } from './entities/user.entity';
4-
import { CreateUserInput } from './dto/create-user.input';
5-
import { UpdateUserInput } from './dto/update-user.input';
4+
5+
import { UsersService } from './users.service';
66

77
@Resolver(() => User)
88
export class UsersResolver {
99
constructor(private readonly usersService: UsersService) {}
1010

11-
@Mutation(() => User)
12-
createUser(@Args('createUserInput') createUserInput: CreateUserInput) {
13-
return this.usersService.create(createUserInput);
14-
}
15-
1611
@Query(() => [User], { name: 'users' })
1712
findAll() {
1813
return this.usersService.findAll();
@@ -22,14 +17,4 @@ export class UsersResolver {
2217
findOne(@Args('id', { type: () => Int }) id: number) {
2318
return this.usersService.findOne(id);
2419
}
25-
26-
@Mutation(() => User)
27-
updateUser(@Args('updateUserInput') updateUserInput: UpdateUserInput) {
28-
return this.usersService.update(updateUserInput.id, updateUserInput);
29-
}
30-
31-
@Mutation(() => User)
32-
removeUser(@Args('id', { type: () => Int }) id: number) {
33-
return this.usersService.remove(id);
34-
}
3520
}

apps/main-service/src/app/users/users.service.ts

-15
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ import { Repository } from 'typeorm';
55

66
import { User } from './entities/user.entity';
77

8-
import { UpdateUserInput } from './dto/update-user.input';
9-
import { CreateUserInput } from './dto/create-user.input';
10-
118
@Injectable()
129
export class UsersService {
1310
private readonly logger: Logger;
@@ -18,10 +15,6 @@ export class UsersService {
1815
this.logger = new Logger(UsersService.name);
1916
}
2017

21-
create(createUserInput: CreateUserInput) {
22-
return 'This action adds a new user';
23-
}
24-
2518
findAll() {
2619
return `This action returns all users`;
2720
}
@@ -30,14 +23,6 @@ export class UsersService {
3023
return `This action returns a #${id} user`;
3124
}
3225

33-
update(id: number, updateUserInput: UpdateUserInput) {
34-
return `This action updates a #${id} user`;
35-
}
36-
37-
remove(id: number) {
38-
return `This action removes a #${id} user`;
39-
}
40-
4126
async findUserByEmail(email: string) {
4227
try {
4328
return await this.userRepository.findOne({

0 commit comments

Comments
 (0)