feat: als and prisma
This commit is contained in:
18
src/auth/auth.controller.spec.ts
Normal file
18
src/auth/auth.controller.spec.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { AuthController } from './auth.controller';
|
||||
|
||||
describe('AuthController', () => {
|
||||
let controller: AuthController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
controllers: [AuthController],
|
||||
}).compile();
|
||||
|
||||
controller = module.get<AuthController>(AuthController);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(controller).toBeDefined();
|
||||
});
|
||||
});
|
||||
4
src/auth/auth.controller.ts
Normal file
4
src/auth/auth.controller.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import { Controller } from '@nestjs/common';
|
||||
|
||||
@Controller('auth')
|
||||
export class AuthController {}
|
||||
9
src/auth/auth.module.ts
Normal file
9
src/auth/auth.module.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { AuthService } from './auth.service';
|
||||
import { AuthController } from './auth.controller';
|
||||
|
||||
@Module({
|
||||
providers: [AuthService],
|
||||
controllers: [AuthController]
|
||||
})
|
||||
export class AuthModule {}
|
||||
18
src/auth/auth.service.spec.ts
Normal file
18
src/auth/auth.service.spec.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { AuthService } from './auth.service';
|
||||
|
||||
describe('AuthService', () => {
|
||||
let service: AuthService;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [AuthService],
|
||||
}).compile();
|
||||
|
||||
service = module.get<AuthService>(AuthService);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(service).toBeDefined();
|
||||
});
|
||||
});
|
||||
4
src/auth/auth.service.ts
Normal file
4
src/auth/auth.service.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class AuthService {}
|
||||
1
src/auth/types/index.ts
Normal file
1
src/auth/types/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './jwt';
|
||||
26
src/auth/types/jwt.ts
Normal file
26
src/auth/types/jwt.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
export interface UserPayload {
|
||||
iat?: number;
|
||||
exp?: number;
|
||||
userId: string;
|
||||
email: string;
|
||||
role: 'user';
|
||||
}
|
||||
|
||||
// For restaurant owners, also resId
|
||||
export interface StaffPayload {
|
||||
iat?: number;
|
||||
exp?: number;
|
||||
userId: string;
|
||||
email: string;
|
||||
role: 'staff';
|
||||
}
|
||||
|
||||
export interface AdminPayload {
|
||||
iat?: number;
|
||||
exp?: number;
|
||||
userId: string;
|
||||
email: string;
|
||||
role: 'admin';
|
||||
}
|
||||
|
||||
export type AuthPayload = UserPayload | StaffPayload | AdminPayload;
|
||||
Reference in New Issue
Block a user