Skip to content

Commit

Permalink
Merge pull request #267 from jiho-kr/feature/search-offset-pagination
Browse files Browse the repository at this point in the history
feat: support offset Pagination on search
  • Loading branch information
jiho-kr authored Aug 16, 2023
2 parents 163bf7a + 40e27b2 commit 2af262a
Show file tree
Hide file tree
Showing 96 changed files with 1,153 additions and 715 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ jobs:

- name: Coveralls
uses: coverallsapp/github-action@v2

# https://github.com/actions/typescript-action/blob/main/.github/workflows/codeql-analysis.yml

# https://github.com/actions/typescript-action/blob/main/.github/workflows/test.yml
108 changes: 54 additions & 54 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,61 +1,61 @@
name: 'CodeQL'

on:
push:
branches: [main]
pull_request:
# The branches below must be a subset of the branches above
branches: [main]
schedule:
- cron: "0 17 * * 4"
push:
branches: [main]
pull_request:
# The branches below must be a subset of the branches above
branches: [main]
schedule:
- cron: '0 17 * * 4'

permissions:
contents: read
contents: read

jobs:
analyse:
permissions:
security-events: write
name: Analyse
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2

# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
queries: +security-extended
# Override language selection by uncommenting this and choosing your languages
# with:
# languages: go, javascript, csharp, python, cpp, java

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
analyse:
permissions:
security-events: write
name: Analyse
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2

# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
queries: +security-extended
# Override language selection by uncommenting this and choosing your languages
# with:
# languages: go, javascript, csharp, python, cpp, java

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"cSpell.words": ["Denormalized", "ILIKE", "nestjs", "Pgsql", "typeorm"],
"cSpell.words": ["Denormalized", "ILIKE", "metatype", "nestjs", "Pgsql", "typeorm"],
"typescript.tsdk": "node_modules/typescript/lib"
}
9 changes: 0 additions & 9 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ services:
- --collation-server=utf8mb4_unicode_ci
ports:
- '3306:3306'
volumes:
- 'mysql_data:/var/lib/mysql'

postgresql:
image: postgres:latest
Expand All @@ -24,10 +22,3 @@ services:
POSTGRES_PASSWORD: $POSTGRESQL_DATABASE_PASSWORD
ports:
- '5432:5432'
volumes:
- postgresql_data:/var/lib/postgresql/data
volumes:
mysql_data:
driver: local
postgresql_data:
driver: local
4 changes: 2 additions & 2 deletions spec/auth-guard/auth-guard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { TestHelper } from '../test.helper';
describe('AuthGuard', () => {
let app: INestApplication;

beforeEach(async () => {
beforeAll(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AuthGuardModule, TestHelper.getTypeOrmMysqlModule([BaseEntity])],
}).compile();
Expand All @@ -19,7 +19,7 @@ describe('AuthGuard', () => {
await app.init();
});

afterEach(async () => {
afterAll(async () => {
await TestHelper.dropTypeOrmEntityTables();
await app?.close();
});
Expand Down
4 changes: 2 additions & 2 deletions spec/author/author-object.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import { TestHelper } from '../test.helper';
describe('Author - object', () => {
let app: INestApplication;

beforeEach(async () => {
beforeAll(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [TestModule, TestHelper.getTypeOrmPgsqlModule([TestEntity])],
}).compile();
app = moduleFixture.createNestApplication();
await app.init();
});

afterEach(async () => {
afterAll(async () => {
await TestHelper.dropTypeOrmEntityTables();
await app?.close();
});
Expand Down
4 changes: 2 additions & 2 deletions spec/author/author-value.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import { TestHelper } from '../test.helper';
describe('Author', () => {
let app: INestApplication;

beforeEach(async () => {
beforeAll(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [TestModule, TestHelper.getTypeOrmMysqlModule([TestEntity])],
}).compile();
app = moduleFixture.createNestApplication();
await app.init();
});

afterEach(async () => {
afterAll(async () => {
await TestHelper.dropTypeOrmEntityTables();
await app?.close();
});
Expand Down
1 change: 0 additions & 1 deletion spec/author/author.interceptor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { CallHandler, ExecutionContext, Injectable, NestInterceptor } from '@nestjs/common';
import { Request } from 'express';
import _ from 'lodash';

@Injectable()
export class AuthorInterceptor implements NestInterceptor {
Expand Down
4 changes: 2 additions & 2 deletions spec/author/author.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import { TestHelper } from '../test.helper';
describe('Author', () => {
let app: INestApplication;

beforeEach(async () => {
beforeAll(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [TestModule, TestHelper.getTypeOrmMysqlModule([TestEntity])],
}).compile();
app = moduleFixture.createNestApplication();
await app.init();
});

afterEach(async () => {
afterAll(async () => {
await TestHelper.dropTypeOrmEntityTables();
await app?.close();
});
Expand Down
13 changes: 6 additions & 7 deletions spec/base/base.controller.create.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,25 @@ import request from 'supertest';

import { BaseEntity } from './base.entity';
import { BaseModule } from './base.module';
import { BaseService } from './base.service';
import { TestHelper } from '../test.helper';

describe('BaseController', () => {
let app: INestApplication;
let service: BaseService;

beforeEach(async () => {
beforeAll(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [BaseModule, TestHelper.getTypeOrmMysqlModule([BaseEntity])],
}).compile();
app = moduleFixture.createNestApplication();

service = moduleFixture.get<BaseService>(BaseService);
await Promise.all(['name1', 'name2'].map((name: string) => service.repository.save(service.repository.create({ name }))));

await app.init();
});

afterEach(async () => {
beforeEach(async () => {
await BaseEntity.delete({});
});

afterAll(async () => {
await TestHelper.dropTypeOrmEntityTables();
await app?.close();
});
Expand Down
8 changes: 6 additions & 2 deletions spec/base/base.controller.delete.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { TestHelper } from '../test.helper';
describe('BaseController', () => {
let app: INestApplication;

beforeEach(async () => {
beforeAll(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [BaseModule, TestHelper.getTypeOrmMysqlModule([BaseEntity])],
}).compile();
Expand All @@ -18,7 +18,11 @@ describe('BaseController', () => {
await app.init();
});

afterEach(async () => {
beforeEach(async () => {
await BaseEntity.delete({});
});

afterAll(async () => {
await TestHelper.dropTypeOrmEntityTables();
await app?.close();
});
Expand Down
4 changes: 2 additions & 2 deletions spec/base/base.controller.read-many.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { TestHelper } from '../test.helper';
describe('BaseController', () => {
let app: INestApplication;

beforeEach(async () => {
beforeAll(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [BaseModule, TestHelper.getTypeOrmMysqlModule([BaseEntity])],
}).compile();
Expand All @@ -17,7 +17,7 @@ describe('BaseController', () => {
await app.init();
});

afterEach(async () => {
afterAll(async () => {
await TestHelper.dropTypeOrmEntityTables();
await app?.close();
});
Expand Down
16 changes: 8 additions & 8 deletions spec/base/base.controller.read-one.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('BaseController', () => {
let app: INestApplication;
let service: BaseService;

beforeEach(async () => {
beforeAll(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [BaseModule, TestHelper.getTypeOrmMysqlModule([BaseEntity])],
}).compile();
Expand All @@ -23,7 +23,7 @@ describe('BaseController', () => {
await app.init();
});

afterEach(async () => {
afterAll(async () => {
await TestHelper.dropTypeOrmEntityTables();
await app?.close();
});
Expand All @@ -36,14 +36,14 @@ describe('BaseController', () => {
});

it('should be returned only one entity', async () => {
const response = await request(app.getHttpServer())
const { body } = await request(app.getHttpServer())
.get(`/base/${id}`)
.query({ fields: ['id', 'name', 'createdAt'] });
.query({ fields: ['id', 'name', 'createdAt'] })
.expect(HttpStatus.OK);

expect(response.statusCode).toEqual(HttpStatus.OK);
expect(response.body.id).toEqual(id);
expect(response.body.name).toEqual(expect.any(String));
expect(response.body.lastModifiedAt).toBeUndefined();
expect(body.id).toEqual(id);
expect(body.name).toEqual(expect.any(String));
expect(body.lastModifiedAt).toBeUndefined();
});

it('should be fields feature with multiple options', async () => {
Expand Down
Loading

0 comments on commit 2af262a

Please sign in to comment.