Skip to content

Commit

Permalink
chore: add ci
Browse files Browse the repository at this point in the history
  • Loading branch information
cyber-eternal committed Mar 23, 2022
1 parent 83230ee commit a7facf3
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 34 deletions.
29 changes: 16 additions & 13 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions config/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
6 changes: 3 additions & 3 deletions config/schema/amqp.ts
Original file line number Diff line number Diff line change
@@ -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(),
Expand Down
6 changes: 3 additions & 3 deletions config/schema/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
4 changes: 2 additions & 2 deletions config/schema/redis.ts
Original file line number Diff line number Diff line change
@@ -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(),
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 3 additions & 1 deletion src/modules/ping/ping.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>('app.version'));
const dto = new PingDto(this.configService.get<string>('app.version'));
console.log('PingDto: ', dto);
return dto;
}
}
15 changes: 9 additions & 6 deletions test/app.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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();
});
});
12 changes: 10 additions & 2 deletions test/jest-e2e.json
Original file line number Diff line number Diff line change
@@ -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/(.*)$": "<rootDir>../$1",
"^@app/(.*)$": "<rootDir>../src/$1"
}
}
}

0 comments on commit a7facf3

Please sign in to comment.