Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions .editorconfig

This file was deleted.

12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ jobs:
run: npm install
- name: Build Project
run: npm run build
- name: Test Project
run: npm run test:cov
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
# - name: Test Project
# run: npm run test:cov
# - name: Upload Coverage to Codecov
# uses: codecov/codecov-action@v1
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
- name: Lint Project
run: npm run lint
3 changes: 1 addition & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
"editor.quickSuggestions": {
"strings": true
}
},
"prettier.configPath": "."
}
}
14 changes: 7 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
version: "3.8"

services:
api:
# image: khushalbhardwaj-0111/notary
build:
dockerfile: Dockerfile
context: ./
mysql:
image: mysql:5
restart: always
environment:
NODE_ENV: production
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: notary-db
ports:
- "8080:8080"
- "3306:3306"
30 changes: 22 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,49 @@
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json --forceExit",
"test:staged": "jest --findRelatedTests",
"test:ci": "npm run test:cov && npm run test:e2e"
"test:ci": "npm run test:cov && npm run test:e2e",
"typeorm": "node --require ts-node/register ./node_modules/typeorm/cli.js",
"migration:generate": "npm run build && npm run typeorm migration:generate -- -n"
},
"dependencies": {
"@nestjs-modules/mailer": "^1.6.0",
"@nestjs/common": "^8.0.6",
"@nestjs/config": "^1.0.2",
"@nestjs/core": "^8.0.6",
"@nestjs/mongoose": "^9.0.0",
"@nestjs/jwt": "^8.0.0",
"@nestjs/mapped-types": "^1.0.0",
"@nestjs/passport": "^8.0.1",
"@nestjs/platform-express": "^8.0.6",
"@nestjs/throttler": "^2.0.0",
"dotenv": "^10.0.0",
"@nestjs/typeorm": "^8.0.2",
"bcrypt": "^5.0.1",
"cache-manager": "^3.4.4",
"class-transformer": "^0.4.0",
"class-validator": "^0.13.1",
"compression": "^1.7.4",
"helmet": "^4.6.0",
"mongoose": "^6.0.8",
"mysql": "^2.18.1",
"nestjs-rate-limiter": "^3.0.0",
"nodemailer": "^6.7.0",
"passport": "^0.5.0",
"passport-local": "^1.0.0",
"passport-jwt": "^4.0.0",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^7.3.0"
"rxjs": "^7.3.0",
"typeorm": "^0.2.38"
},
"devDependencies": {
"@commitlint/cli": "^13.2.1",
"@commitlint/config-conventional": "^13.2.0",
"@nestjs/cli": "^8.1.1",
"@nestjs/schematics": "^8.0.2",
"@nestjs/testing": "^8.0.6",
"@types/bcrypt": "^5.0.0",
"@types/cache-manager": "^3.4.2",
"@types/compression": "^1.7.2",
"@types/express": "^4.17.13",
"@types/jest": "^27.0.1",
"@types/node": "^16.7.1",
"@types/passport-local": "^1.0.34",
"@types/passport-jwt": "^3.0.6",
"@types/supertest": "^2.0.11",
"@typescript-eslint/eslint-plugin": "^4.29.2",
"@typescript-eslint/parser": "^4.29.2",
Expand Down
26 changes: 13 additions & 13 deletions src/app.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ import { AppController } from "./app.controller";
import { AppService } from "./app.service";

describe("AppController", () => {
let app: TestingModule;
let app: TestingModule;

beforeAll(async () => {
app = await Test.createTestingModule({
controllers: [AppController],
providers: [AppService],
}).compile();
});
beforeAll(async () => {
app = await Test.createTestingModule({
controllers: [AppController],
providers: [AppService],
}).compile();
});

describe("getHello", () => {
it('should return "Hello World!"', () => {
const appController = app.get<AppController>(AppController);
expect(appController.getHello()).toBe("Hello World!");
});
});
describe("getHello", () => {
it('should return "Hello World!"', () => {
const appController = app.get<AppController>(AppController);
expect(appController.getHello()).toBe("Hello World!");
});
});
});
10 changes: 5 additions & 5 deletions src/app.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { AppService } from "./app.service";

@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
constructor(private readonly appService: AppService) {}

@Get()
getHello(): string {
return this.appService.getHello();
}
@Get()
getHello(): string {
return this.appService.getHello();
}
}
64 changes: 40 additions & 24 deletions src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,51 @@
import { MiddlewareConsumer, Module, NestModule } from "@nestjs/common";
import { CacheInterceptor, CacheModule, MiddlewareConsumer, Module, NestModule } from "@nestjs/common";
import { AppController } from "./app.controller";
import { AppService } from "./app.service";
import { NotesModule } from "./notes/notes.module";
import { MongooseModule } from "@nestjs/mongoose";
import { RateLimiterGuard, RateLimiterModule } from "nestjs-rate-limiter";
import { AuthModule } from "./auth/auth.module";
import { UsersModule } from "./users/users.module";
import config from "./config/keys";
import { HttpLoggerMiddleWare } from "./middlewares/http-logger.middleware";
import { APP_GUARD } from "@nestjs/core";
import { rateLimiterOptions } from "./config/rate-limiter.config";
import { APP_GUARD, APP_INTERCEPTOR } from "@nestjs/core";
import { rateLimiterOptions } from "./config/rate-limiter";
import { ConfigModule } from "@nestjs/config";
import { TypeOrmModule, TypeOrmModuleOptions } from "@nestjs/typeorm";
import { MailerModule } from "@nestjs-modules/mailer";
import { mailerAsyncOptions } from "./config/mailer";
import { RegisterModule } from "./register/register.module";
import { LoginModule } from "./login/login.module";
import { ChangePasswordModule } from "./change-password/change-password.module";
import { ForgotPasswordModule } from "./forgot-password/forgot-password.module";
import { UsersModule } from "./users/users.module";
import { typeOrmDevOptions, typeOrmProdOptions } from "./config/typeorm";

const typeOrmOptions: TypeOrmModuleOptions = process.env.NODE_ENV === 'production' ? typeOrmProdOptions : typeOrmDevOptions;

@Module({
imports: [
NotesModule,
AuthModule,
imports: [
ConfigModule.forRoot({ isGlobal: true }),
RateLimiterModule.register(rateLimiterOptions),
TypeOrmModule.forRoot(typeOrmOptions),
MailerModule.forRootAsync(mailerAsyncOptions),
CacheModule.register({ isGlobal: true }),
RegisterModule,
UsersModule,
MongooseModule.forRoot(config.mongoURI),
RateLimiterModule.register(rateLimiterOptions),
],
controllers: [AppController],
providers: [
AppService,
LoginModule,
ChangePasswordModule,
ForgotPasswordModule,
],
controllers: [AppController],
providers: [
AppService,
{
provide: APP_GUARD,
useClass: RateLimiterGuard,
},
{
provide: APP_GUARD,
useClass: RateLimiterGuard,
},
],
provide: APP_INTERCEPTOR,
useClass: CacheInterceptor
}
],
})
export class AppModule implements NestModule {
configure(consumer: MiddlewareConsumer) {
consumer.apply(HttpLoggerMiddleWare).forRoutes("*");
}
configure(consumer: MiddlewareConsumer) {
consumer.apply(HttpLoggerMiddleWare).forRoutes("*");
}
}
6 changes: 3 additions & 3 deletions src/app.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Injectable } from "@nestjs/common";

@Injectable()
export class AppService {
getHello(): string {
return "Hello World!";
}
getHello(): string {
return "Hello World!";
}
}
11 changes: 0 additions & 11 deletions src/auth/auth.module.ts

This file was deleted.

32 changes: 0 additions & 32 deletions src/auth/auth.service.spec.ts

This file was deleted.

22 changes: 0 additions & 22 deletions src/auth/auth.service.ts

This file was deleted.

5 changes: 0 additions & 5 deletions src/auth/local-auth.guard.ts

This file was deleted.

22 changes: 0 additions & 22 deletions src/auth/local.strategy.ts

This file was deleted.

22 changes: 22 additions & 0 deletions src/change-password/change-password.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Test, TestingModule } from "@nestjs/testing";
import { ChangePasswordController } from "./change-password.controller";
import { ChangePasswordService } from "./change-password.service";

describe("ChangePasswordController", () => {
let controller: ChangePasswordController;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [ChangePasswordController],
providers: [ChangePasswordService],
}).compile();

controller = module.get<ChangePasswordController>(
ChangePasswordController,
);
});

it("should be defined", () => {
expect(controller).toBeDefined();
});
});
Loading