feat(auth): Enhance AuthService with additional functionalities and dependencies
This commit implements additional operations in AuthService such as user registration, login, fetching, updating, and deletion. It also adds two new dependencies: DrizzleService and CredentialsService. Moreover, AuthService now implements OnModuleInit for executing methods once the module has been initialized. Corresponding changes are reflected in the module structure.
This commit is contained in:
parent
bb482fb896
commit
e1909791ac
@ -1,21 +1,25 @@
|
|||||||
import { Module } from "@nestjs/common";
|
import { Module } from "@nestjs/common";
|
||||||
import { ConfigModule, ConfigService } from "@nestjs/config";
|
import { ConfigModule, ConfigService } from "@nestjs/config";
|
||||||
import { LogService } from "./logger/logger.service";
|
|
||||||
import { ThrottlerModule } from "@nestjs/throttler";
|
import { ThrottlerModule } from "@nestjs/throttler";
|
||||||
import { DrizzleModule } from './drizzle/drizzle.module';
|
import { AuthModule } from "./auth/auth.module";
|
||||||
import { AuthModule } from './auth/auth.module';
|
import { CredentialsModule } from "./credentials/credentials.module";
|
||||||
|
import { DrizzleModule } from "./drizzle/drizzle.module";
|
||||||
|
import { LogService } from "./logger/logger.service";
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
ThrottlerModule.forRoot([{
|
ThrottlerModule.forRoot([
|
||||||
ttl: 60000,
|
{
|
||||||
limit: 10,
|
ttl: 60000,
|
||||||
}]),
|
limit: 10,
|
||||||
|
},
|
||||||
|
]),
|
||||||
ConfigModule.forRoot({
|
ConfigModule.forRoot({
|
||||||
isGlobal: true
|
isGlobal: true,
|
||||||
}),
|
}),
|
||||||
DrizzleModule,
|
DrizzleModule,
|
||||||
AuthModule
|
AuthModule,
|
||||||
|
CredentialsModule,
|
||||||
],
|
],
|
||||||
exports: [LogService],
|
exports: [LogService],
|
||||||
controllers: [],
|
controllers: [],
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
import { Module } from '@nestjs/common';
|
import { Module } from "@nestjs/common";
|
||||||
import { AuthService } from './auth.service';
|
import { DrizzleModule } from "src/drizzle/drizzle.module";
|
||||||
|
import { AuthService } from "./auth.service";
|
||||||
|
import { CredentialsModule } from "src/credentials/credentials.module";
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
providers: [AuthService]
|
imports: [DrizzleModule, CredentialsModule],
|
||||||
|
providers: [AuthService],
|
||||||
})
|
})
|
||||||
export class AuthModule {}
|
export class AuthModule {}
|
||||||
|
@ -1,4 +1,27 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
// biome-ignore lint/style/useImportType: used by Next.js
|
||||||
|
import { Injectable, OnModuleInit } from "@nestjs/common";
|
||||||
|
// biome-ignore lint/style/useImportType: used by Next.js
|
||||||
|
import { DrizzleService } from "src/drizzle/drizzle.service";
|
||||||
|
import { UsersTable } from "src/schema";
|
||||||
|
// biome-ignore lint/style/useImportType: used by Next.js
|
||||||
|
import { CredentialsService } from "src/credentials/credentials.service";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AuthService {}
|
export class AuthService implements OnModuleInit {
|
||||||
|
constructor(
|
||||||
|
private db: DrizzleService,
|
||||||
|
private credentials: CredentialsService
|
||||||
|
) {}
|
||||||
|
doRegister() {}
|
||||||
|
doLogin() {}
|
||||||
|
async fetchUser(userId: string) {
|
||||||
|
const userInDb = await this.db.use().select().from(UsersTable);
|
||||||
|
console.log("Users : \n", userInDb);
|
||||||
|
}
|
||||||
|
updateUser() {}
|
||||||
|
deleteUser() {}
|
||||||
|
|
||||||
|
async onModuleInit() {
|
||||||
|
await this.fetchUser("ee");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user