Add Auth
This commit is contained in:
8
src/users/users.module.ts
Normal file
8
src/users/users.module.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { UsersService } from './users.service';
|
||||
|
||||
@Module({
|
||||
providers: [UsersService],
|
||||
exports: [UsersService]
|
||||
})
|
||||
export class UsersModule {}
|
20
src/users/users.service.ts
Normal file
20
src/users/users.service.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
require('dotenv').config()
|
||||
|
||||
// This should be a real class/interface representing a user entity
|
||||
export type User = any;
|
||||
|
||||
@Injectable()
|
||||
export class UsersService {
|
||||
private readonly users = [
|
||||
{
|
||||
userId: 1,
|
||||
username: 'admin',
|
||||
password: process.env.ADMIN_PASS,
|
||||
},
|
||||
];
|
||||
|
||||
async findOne(username: string): Promise<User | undefined> {
|
||||
return this.users.find((user) => user.username === username);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user