diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index aab2425..be3f4e7 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -1,22 +1,25 @@ -name: Docker Image CI +name: Nestjs-Template-CI on: push: - branches: [ master ] + branches: [master] jobs: - build: - runs-on: ubuntu-latest steps: - - - name: Clone repo - uses: actions/checkout@v2 - - - name: Check docker-compose - run: docker -v && docker-compose -v - - - name: Build the Docker images - run: docker-compose up -d --build + - name: Clone repo + uses: actions/checkout@v2 + + - name: Check docker-compose + run: docker -v && docker-compose -v + + - name: Up Docker-Compose containers + run: docker-compose up -d --build + + - name: Run e2e + run: yarn test:e2e + + - name: Down Docker-Compose containers + run: docker-compose down diff --git a/README.md b/README.md index a66b582..4f92f7b 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,9 @@ # Template for the [Node.js](http://nodejs.org) applications based on the [Nest.js](http://nestjs.org) framework for building efficient and scalable server-side applications. +### Status of Last Deployment: +![Last Deployment](https://github.com/cyber-eternal/nestjs-template/workflows/build/badge.svg?branch=master) + ## Description The template is based on Nest.js(v 8.4.1) and TypeScript. Also has an implementation for the TypeORM to work with the Database, and RabbitMQ for the messaging(the RabbitMQ implementation can be easily removed if you are not using it). The template dockerized as well diff --git a/config/database.ts b/config/database.ts index 46b7aff..17c7883 100644 --- a/config/database.ts +++ b/config/database.ts @@ -2,8 +2,8 @@ export default { name: 'default', type: process.env.TYPEORM_TYPE || 'mariadb', host: process.env.TYPEORM_HOST || 'localhost', - username: process.env.TYPEORM_USERNAME || 'root', - password: process.env.TYPEORM_PASSWORD || 'password', + username: process.env.TYPEORM_USERNAME || 'guest', + password: process.env.TYPEORM_PASSWORD || 'guest', database: process.env.TYPEORM_DATABASE || 'core', port: parseInt(process.env.TYPEORM_PORT, 10) || 3306, logging: process.env.TYPEORM_LOGGING === 'true', diff --git a/config/schema/amqp.ts b/config/schema/amqp.ts index 6db0229..f4cff33 100644 --- a/config/schema/amqp.ts +++ b/config/schema/amqp.ts @@ -1,10 +1,10 @@ import * as Joi from 'joi'; export default { - AMQP_HOST: Joi.string().required(), + AMQP_HOST: Joi.string(), AMQP_PORT: Joi.number(), - AMQP_USERNAME: Joi.string().required(), - AMQP_PASSWORD: Joi.string().required(), + AMQP_USERNAME: Joi.string(), + AMQP_PASSWORD: Joi.string(), AMQP_VHOST: Joi.string().uri(), AMQP_QUEUE_PREFIX: Joi.string(), AMQP_SEND_EMAIL_QUEUE: Joi.string(), diff --git a/config/schema/database.ts b/config/schema/database.ts index 768a08e..a92405d 100644 --- a/config/schema/database.ts +++ b/config/schema/database.ts @@ -2,9 +2,9 @@ import * as Joi from 'joi'; export default { TYPEORM_TYPE: Joi.string().default('mariadb'), - TYPEORM_HOST: Joi.string().required(), - TYPEORM_USERNAME: Joi.string().required(), - TYPEORM_PASSWORD: Joi.string().required(), + TYPEORM_HOST: Joi.string(), + TYPEORM_USERNAME: Joi.string(), + TYPEORM_PASSWORD: Joi.string(), TYPEORM_DATABASE: Joi.string().default('core'), TYPEORM_PORT: Joi.number().default(3306), TYPEORM_LOGGING: Joi.string().default('false'), diff --git a/config/schema/redis.ts b/config/schema/redis.ts index 2bce699..45c9570 100644 --- a/config/schema/redis.ts +++ b/config/schema/redis.ts @@ -1,10 +1,10 @@ import * as Joi from 'joi'; export default { - REDIS_HOST: Joi.string().required(), + REDIS_HOST: Joi.string(), REDIS_PORT: Joi.number(), REDIS_DB: Joi.number(), - REDIS_PASSWORD: Joi.string().required(), + REDIS_PASSWORD: Joi.string(), REDIS_KEY_S3: Joi.string(), REDIS_KEY_SP: Joi.string(), REDIS_PREFIX: Joi.string(), diff --git a/package.json b/package.json index 9cc63cf..944e3e5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nestjs-template", - "version": "3.0.0", - "template-version": "3.0.0", + "version": "3.0.1", + "template-version": "3.0.1", "description": "Nest.js based template", "author": "cyber-eternal", "license": "MIT", diff --git a/src/modules/ping/ping.controller.ts b/src/modules/ping/ping.controller.ts index 7b8ee37..dec4599 100644 --- a/src/modules/ping/ping.controller.ts +++ b/src/modules/ping/ping.controller.ts @@ -13,6 +13,8 @@ export class PingController { @ApiOperation({ summary: 'Ping' }) @ApiOkResponse({ status: HttpStatus.OK, type: PingDto }) public ping(): PingDto { - return new PingDto(this.configService.get('app.version')); + const dto = new PingDto(this.configService.get('app.version')); + console.log('PingDto: ', dto); + return dto; } } diff --git a/test/app.e2e-spec.ts b/test/app.e2e-spec.ts index 993e2b2..78a15f8 100644 --- a/test/app.e2e-spec.ts +++ b/test/app.e2e-spec.ts @@ -1,6 +1,7 @@ import { Test, TestingModule } from '@nestjs/testing'; import * as request from 'supertest'; -import { AppModule } from '../src/modules/app/app.module'; +import { AppModule } from '../src/app.module'; +import { Connection } from 'typeorm/index'; describe('AppController (e2e)', () => { let app; @@ -14,10 +15,12 @@ describe('AppController (e2e)', () => { await app.init(); }); - it('/ (GET)', () => { - return request(app.getHttpServer()) - .get('/') - .expect(200) - .expect('Hello World!'); + it('/ping (GET)', () => { + return request(app.getHttpServer()).get('/ping').expect(200); + }); + + afterAll(async () => { + const conn = app.get(Connection); + await conn.close(); }); }); diff --git a/test/jest-e2e.json b/test/jest-e2e.json index e9d912f..e00b0e5 100644 --- a/test/jest-e2e.json +++ b/test/jest-e2e.json @@ -1,9 +1,17 @@ { - "moduleFileExtensions": ["js", "json", "ts"], + "moduleFileExtensions": [ + "js", + "json", + "ts" + ], "rootDir": ".", "testEnvironment": "node", "testRegex": ".e2e-spec.ts$", "transform": { "^.+\\.(t|j)s$": "ts-jest" + }, + "moduleNameMapper": { + "^@root/(.*)$": "../$1", + "^@app/(.*)$": "../src/$1" } -} +} \ No newline at end of file