feat: als and prisma

This commit is contained in:
sauravdhakal12
2026-02-10 17:19:53 +05:45
parent 65480c4f8c
commit 9561693cb4
32 changed files with 2124 additions and 35 deletions

View 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();
});
});

View File

@@ -0,0 +1,4 @@
import { Controller } from '@nestjs/common';
@Controller('auth')
export class AuthController {}

9
src/auth/auth.module.ts Normal file
View 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 {}

View 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
View File

@@ -0,0 +1,4 @@
import { Injectable } from '@nestjs/common';
@Injectable()
export class AuthService {}

1
src/auth/types/index.ts Normal file
View File

@@ -0,0 +1 @@
export * from './jwt';

26
src/auth/types/jwt.ts Normal file
View 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;