@ -0,0 +1,3 @@ | |||||
node_modules | |||||
combined.log | |||||
error.log |
@ -0,0 +1,9 @@ | |||||
JWT_SECRET=sajdhgjhasdhgads | |||||
EMAIL_HOST=smtp.gmail.com | |||||
EMAIL_PORT=587 | |||||
EMAIL_USERNAME=krish@sentientgeeks.com | |||||
EMAIL_PASSWORD=123456 | |||||
PORT=3000 | |||||
# MONGO_URI_TESTS=mongodb://localhost:27017/sg-node-express-rest-api | |||||
MONGO_URI=mongodb://mongo:27017/sg-node-express-rest-api | |||||
JWT_EXPIRATION_MINUTES=300 |
@ -0,0 +1,9 @@ | |||||
JWT_SECRET=sajdhgjhasdhgads | |||||
EMAIL_HOST=smtp.gmail.com | |||||
EMAIL_PORT=587 | |||||
EMAIL_USERNAME=krish@sentientgeeks.com | |||||
EMAIL_PASSWORD=123456 | |||||
PORT=3000 | |||||
# MONGO_URI_TESTS=mongodb://localhost:27017/sg-node-express-rest-api | |||||
MONGO_URI=mongodb://mongo:27017/sg-node-express-rest-api | |||||
JWT_EXPIRATION_MINUTES=300 |
@ -0,0 +1,13 @@ | |||||
FROM node:latest | |||||
WORKDIR /app | |||||
COPY package.json package-lock.json ./ | |||||
RUN npm install | |||||
COPY . . | |||||
RUN npm run build | |||||
CMD ["npm", "start"] | |||||
@ -0,0 +1,29 @@ | |||||
version: '3' | |||||
services: | |||||
node: | |||||
container_name: nodejs-api | |||||
build: | |||||
context: . | |||||
dockerfile: Dockerfile | |||||
ports: | |||||
- "3000:3000" | |||||
environment: | |||||
- NODE_ENV=development | |||||
volumes: | |||||
- .:/app | |||||
depends_on: | |||||
- mongo | |||||
restart: always | |||||
mongo: | |||||
container_name: mongodb | |||||
image: mongo:latest | |||||
ports: | |||||
- "27017:27017" | |||||
volumes: | |||||
- mongo_data:/data/db | |||||
restart: always | |||||
volumes: | |||||
mongo_data: |
@ -0,0 +1,30 @@ | |||||
version: '3' | |||||
services: | |||||
node: | |||||
container_name: nodejs-api | |||||
build: | |||||
context: . | |||||
dockerfile: Dockerfile | |||||
ports: | |||||
- "3000:3000" | |||||
environment: | |||||
- NODE_ENV=production | |||||
volumes: | |||||
- .:/app | |||||
depends_on: | |||||
- mongo | |||||
restart: always | |||||
mongo: | |||||
container_name: mongodb | |||||
image: mongo:latest | |||||
ports: | |||||
- "27017:27017" | |||||
volumes: | |||||
- mongo_data:/data/db | |||||
restart: always | |||||
volumes: | |||||
mongo_data: |
@ -1,4 +1,8 @@ | |||||
{ | { | ||||
"$schema": "https://json.schemastore.org/nest-cli", | |||||
"collection": "@nestjs/schematics", | "collection": "@nestjs/schematics", | ||||
"sourceRoot": "src" | |||||
"sourceRoot": "src", | |||||
"compilerOptions": { | |||||
"deleteOutDir": true | |||||
} | |||||
} | } |
@ -1,12 +1,10 @@ | |||||
import { Module } from '@nestjs/common'; | import { Module } from '@nestjs/common'; | ||||
import { AppController } from './app.controller'; | import { AppController } from './app.controller'; | ||||
import { AppService } from './app.service'; | import { AppService } from './app.service'; | ||||
import { UserModule } from './user/user.module'; | |||||
import { SchoolModule } from './school/school.module'; | |||||
import { MongooseModule } from '@nestjs/mongoose'; | |||||
import { AuthModule } from './auth/auth.module'; | |||||
@Module({ | @Module({ | ||||
imports: [UserModule, SchoolModule,MongooseModule.forRoot('mongodb://localhost/classpoint')], | |||||
imports: [AuthModule], | |||||
controllers: [AppController], | controllers: [AppController], | ||||
providers: [AppService], | providers: [AppService], | ||||
}) | }) | ||||
@ -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(); | |||||
}); | |||||
}); |
@ -0,0 +1,4 @@ | |||||
import { Controller } from '@nestjs/common'; | |||||
@Controller('auth') | |||||
export class AuthController {} |
@ -0,0 +1,9 @@ | |||||
import { Module } from '@nestjs/common'; | |||||
import { AuthController } from './auth.controller'; | |||||
import { AuthService } from './auth.service'; | |||||
@Module({ | |||||
controllers: [AuthController], | |||||
providers: [AuthService] | |||||
}) | |||||
export class AuthModule {} |
@ -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(); | |||||
}); | |||||
}); |
@ -0,0 +1,4 @@ | |||||
import { Injectable } from '@nestjs/common'; | |||||
@Injectable() | |||||
export class AuthService {} |
@ -0,0 +1,4 @@ | |||||
export class AuthDto { | |||||
username: string; | |||||
password: string; | |||||
} |
@ -0,0 +1,13 @@ | |||||
@injectable() | |||||
export default class AccessTokenStrategy extends PassportStrategy( | |||||
Strategy, | |||||
'access-token', | |||||
) { | |||||
constructor(private readonly authService: AuthService) { | |||||
super(); | |||||
} | |||||
async validate(payload: any) { | |||||
return this.authService.validateAccessToken(payload); | |||||
} | |||||
} |
@ -0,0 +1,13 @@ | |||||
@injectable() | |||||
export default class RefreshTokenStrategy extends PassportStrategy( | |||||
Strategy, | |||||
'refresh-token', | |||||
) { | |||||
constructor(private readonly authService: AuthService) { | |||||
super(); | |||||
} | |||||
async validate(payload: any) { | |||||
return this.authService.validateRefreshToken(payload); | |||||
} | |||||
} |
@ -0,0 +1,7 @@ | |||||
expect const mail = { | |||||
from: ' ', | |||||
to: ' ', | |||||
subject: ' ', | |||||
text: ' ', | |||||
html: ' ', | |||||
}; |
@ -0,0 +1,5 @@ | |||||
export class AccessToken extends AuthGuard('access-token') {} | |||||
function AuthGuard(arg0: string) { | |||||
throw new Error("Function not implemented."); | |||||
} |
@ -0,0 +1,5 @@ | |||||
export class RefreshTokenGuard extends AuthGuard('refresh-token') {} | |||||
function AuthGuard(arg0: string) { | |||||
throw new Error("Function not implemented."); | |||||
} |