Skip to content

Commit 8eed85c

Browse files
committed
feat: add winston logger and setup for e2e test suite
1 parent 52e8313 commit 8eed85c

20 files changed

Lines changed: 694 additions & 47 deletions

.env.example

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
SERVER_PORT=7777
2-
DB_PASSWORD=truthy
3-
DB_USERNAME=truthy123
4-
DB_DATABASE_NAME=truthy
2+
DB_HOST=
3+
DB_PASSWORD=
4+
DB_USERNAME=
5+
DB_DATABASE_NAME=
56
DB_PORT=5432
67
REDIS_PORT=6399

.github/workflows/test.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ jobs:
1515
POSTGRES_PASSWORD: truthypwd
1616
ports:
1717
- 5432:5432
18+
redis:
19+
image: redis
20+
options: >-
21+
--health-cmd "redis-cli ping"
22+
--health-interval 10s
23+
--health-timeout 5s
24+
--health-retries 5
1825
1926
steps:
2027
- uses: actions/checkout@v2

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div align="center">
2-
<img src="./images/logo.svg" alt="Truthy Logo">
2+
<img src="./public/images/logo.svg" alt="Truthy Logo">
33
</div><br>
44
<h1 align="center">
55
Truthy CMS (NestJS Headless API)

config/default.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ db:
66
host: 'localhost'
77
type: 'postgres'
88
port: 5432
9-
database: 'truthy'
9+
username: 'postgres'
10+
password: 'root'
11+
synchronize: false
1012

1113
jwt:
1214
# expiresIn: 10
@@ -55,3 +57,11 @@ throttle:
5557

5658
twofa:
5759
authenticationAppNAme: 'truthy'
60+
61+
winston:
62+
groupName: 'truthy'
63+
streamName: 'truthy-stream'
64+
awsAccessKeyId: ''
65+
awsSecretAccessKey: ''
66+
awsRegion: ''
67+

package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020
"test:watch": "jest --config ./test/unit/jest-unit.json --watch",
2121
"test:cov": "jest --coverage",
2222
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
23-
"test:e2e": "jest --config ./test/e2e/jest-e2e.json --runInBand",
23+
"test:e2e": "jest --config ./test/e2e/jest-e2e.json",
2424
"test:unit": "jest --config ./test/unit/jest-unit.json --runInBand",
2525
"typeorm": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js --config src/config/ormconfig.ts",
2626
"orm-create": "npm run typeorm migration:create -- -n",
2727
"migrate": "npm run typeorm migration:run",
2828
"migration:rollback": "npm run typeorm migration:revert",
2929
"seed": "ts-node ./node_modules/typeorm-seeding/dist/cli.js seed -n ./src/config/ormconfig.ts",
30-
"precommit": "lint-staged && npm run lint && npm run test:unit",
31-
"prepush": "npm run test:unit",
30+
"precommit": "lint-staged && npm run lint && npm run test:unit && npm run test:e2e",
31+
"prepush": "npm run test:unit && npm run test:e2e",
3232
"prepare": "husky install"
3333
},
3434
"dependencies": {
@@ -45,6 +45,7 @@
4545
"@nestjs/throttler": "^2.0.0",
4646
"@nestjs/typeorm": "^8.0.3",
4747
"@types/cookie-parser": "^1.4.2",
48+
"aws-sdk": "^2.1092.0",
4849
"bcrypt": "^5.0.0",
4950
"bull": "^4.2.1",
5051
"class-transformer": "^0.5.1",
@@ -53,6 +54,7 @@
5354
"cookie-parser": "^1.4.6",
5455
"coveralls": "^3.1.1",
5556
"ioredis": "^4.28.3",
57+
"nest-winston": "^1.6.2",
5658
"nestjs-i18n": "^8.2.2",
5759
"nestjs-throttler-storage-redis": "^0.1.18",
5860
"nodemailer": "^6.7.2",
@@ -69,7 +71,9 @@
6971
"typeorm": "^0.2.41",
7072
"typeorm-seeding": "^1.6.1",
7173
"ua-parser-js": "^1.0.2",
72-
"uuid": "^8.3.2"
74+
"uuid": "^8.3.2",
75+
"winston": "^3.6.0",
76+
"winston-cloudwatch": "^3.1.1"
7377
},
7478
"devDependencies": {
7579
"@commitlint/cli": "^16.0.2",
File renamed without changes.

src/app.controller.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,16 @@ import { Controller, Get } from '@nestjs/common';
33
@Controller()
44
export class AppController {
55
@Get('/health')
6-
getHello() {
6+
health() {
77
return {
88
status: 200
99
};
1010
}
11+
12+
@Get('')
13+
index() {
14+
return {
15+
message: 'hello world'
16+
};
17+
}
1118
}

src/app.module.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
I18nModule,
1414
QueryResolver
1515
} from 'nestjs-i18n';
16+
import { WinstonModule } from 'nest-winston';
1617

1718
import { AuthModule } from 'src/auth/auth.module';
1819
import { RolesModule } from 'src/role/roles.module';
@@ -28,11 +29,13 @@ import { TwofaModule } from 'src/twofa/twofa.module';
2829
import { CustomThrottlerGuard } from 'src/common/guard/custom-throttle.guard';
2930
import { DashboardModule } from 'src/dashboard/dashboard.module';
3031
import { AppController } from 'src/app.controller';
32+
import winstonConfig from 'src/config/winston';
3133

3234
const appConfig = config.get('app');
3335

3436
@Module({
3537
imports: [
38+
WinstonModule.forRoot(winstonConfig),
3639
ThrottlerModule.forRootAsync({
3740
useFactory: () => throttleConfig
3841
}),
@@ -58,7 +61,7 @@ const appConfig = config.get('app');
5861
]
5962
}),
6063
ServeStaticModule.forRoot({
61-
rootPath: join(__dirname, '..', 'images'),
64+
rootPath: join(__dirname, '..', 'public'),
6265
exclude: ['/api*']
6366
}),
6467
AuthModule,

src/auth/auth.controller.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,10 @@ export class AuthController {
137137
@UseGuards(JwtTwoFactorGuard)
138138
@Put('/auth/profile')
139139
@UseInterceptors(
140-
FileInterceptor('avatar', multerOptionsHelper('images/profile', 1000000))
140+
FileInterceptor(
141+
'avatar',
142+
multerOptionsHelper('public/images/profile', 1000000)
143+
)
141144
)
142145
updateProfile(
143146
@GetUser()

0 commit comments

Comments
 (0)