Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rest): Created rest package #200

Draft
wants to merge 36 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
dbfca70
feat(rest): Created rest package
TriPSs Nov 9, 2023
49cd3a4
refactor(rest): Linting
TriPSs Nov 9, 2023
488a39c
refactor(rest): Improved `@Field` decorator
TriPSs Dec 1, 2023
24a6196
refactor(rest): Improved `@Field` decorator
TriPSs Dec 4, 2023
8178f02
refactor(rest): Improved `@Field` and `@FilterableField` decorators
TriPSs Dec 5, 2023
4529d18
ci: Added dependabot.yml and stale.yml
TriPSs Dec 9, 2023
f16f6c6
refactor(rest): Improved `@Field` decorator
TriPSs Dec 9, 2023
612a43a
refactor(rest): Updated lint
TriPSs Dec 23, 2023
0d0b9f5
test(rest): Added basic test case for one endpoint
TriPSs Dec 23, 2023
221ca7b
refactor: Lint examples
TriPSs Dec 23, 2023
f8daf99
refactor(rest): Improved `@Field` decorator
TriPSs Jan 25, 2024
064a447
Merge branch 'master' into feature/rest
TriPSs Feb 1, 2024
49b16fd
chore: Merge dev
TriPSs Feb 1, 2024
5bd8ccb
refactor(rest): Improved controller methods swagger implementation
TriPSs Feb 8, 2024
9636397
Merge branch 'refs/heads/master' into feature/rest
TriPSs Jun 14, 2024
dc97f26
chore: Merge master
TriPSs Jun 14, 2024
887910b
fix(query-rest): Fixed paging not working when there are no additiona…
TriPSs Jun 14, 2024
3eb2454
fix(query-rest): Added `IsArray` validation to `@Field` if field is a…
TriPSs Jun 14, 2024
45932c9
feat(query-rest): Added `forceArray` option to to `@Field` decorator
TriPSs Jun 14, 2024
85393ad
fix(query-rest): Prevent non-valid options from being passed to swagg…
TriPSs Jun 14, 2024
d4d4553
Merge branch 'refs/heads/improvements' into feature/rest
TriPSs Jun 21, 2024
7245c19
chore: Updated lockfile
TriPSs Jun 21, 2024
ad5c987
feat(rest): Added support for `@FilterableField`
TriPSs Jun 21, 2024
f1ef57f
fix(rest): Fixed filterable fields always required
TriPSs Jun 21, 2024
67a9196
fix(rest): Fixed `forceArray` and `skipIsEnum` not working for `@Field`
TriPSs Jun 21, 2024
b70eacd
fix(query-rest): Add min and max validation to field decorator
TriPSs Aug 21, 2024
697e90f
feat(query-rest): Introduce `FindOneArgsType` and refactor resolvers …
TriPSs Oct 8, 2024
87b7c05
fix(query-rest): Read resolver not respecting `disabled` opt
TriPSs Oct 9, 2024
4111575
feat(query-rest): Add `idOnly` option to IDFieldOptions in id-field.d…
TriPSs Oct 9, 2024
7d46be2
fix(query-rest): Add name option to Expose decorator in field decorator
TriPSs Oct 10, 2024
ee816fb
refactor(query-rest): Update unique name values for DTO classes to in…
TriPSs Oct 10, 2024
465589a
Merge branch 'master' into feature/rest
TriPSs Oct 10, 2024
84a6b2e
chore: Updated lockfile
TriPSs Oct 10, 2024
d3cfb9f
refactor(query-rest): Simplify usage of DTOClass parameters and add A…
TriPSs Oct 10, 2024
1a33964
fix(nestjs-rest): Fix decorator metadata retrieval and class naming
TriPSs Oct 14, 2024
e2353ec
feat(query-rest): Add `IsDate` validation to field decorator
TriPSs Oct 14, 2024
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
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
15 changes: 15 additions & 0 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 7
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 3
# Only issues or pull requests with all of these labels are checked if stale. Defaults to `[]` (disabled)
onlyLabels:
- "more info needed"
# Label to use when marking an issue as stale
staleLabel: "auto closed"
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false
47 changes: 47 additions & 0 deletions examples/basic-rest/e2e/fixtures.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { Connection } from 'typeorm'

import { executeTruncate } from '../../helpers'
import { SubTaskEntity } from '../src/sub-task/sub-task.entity'
import { TagEntity } from '../src/tag/tag.entity'
import { TodoItemEntity } from '../src/todo-item/todo-item.entity'

const tables = ['todo_item', 'sub_task', 'tag']
export const truncate = async (connection: Connection): Promise<void> => executeTruncate(connection, tables)

export const refresh = async (connection: Connection): Promise<void> => {
await truncate(connection)

const todoRepo = connection.getRepository(TodoItemEntity)
const subTaskRepo = connection.getRepository(SubTaskEntity)
const tagsRepo = connection.getRepository(TagEntity)

const urgentTag = await tagsRepo.save({ name: 'Urgent' })
const homeTag = await tagsRepo.save({ name: 'Home' })
const workTag = await tagsRepo.save({ name: 'Work' })
const questionTag = await tagsRepo.save({ name: 'Question' })
const blockedTag = await tagsRepo.save({ name: 'Blocked' })

const todoItems = await todoRepo.save([
{ title: 'Create Nest App', completed: true, tags: [urgentTag, homeTag] },
{ title: 'Create Entity', completed: false, tags: [urgentTag, workTag] },
{ title: 'Create Entity Service', completed: false, tags: [blockedTag, workTag] },
{ title: 'Add Todo Item Resolver', completed: false, tags: [blockedTag, homeTag] },
{
title: 'How to create item With Sub Tasks',
completed: false,
tags: [questionTag, blockedTag]
}
])

await subTaskRepo.save(
todoItems.reduce(
(subTasks, todo) => [
...subTasks,
{ completed: true, title: `${todo.title} - Sub Task 1`, todoItem: todo },
{ completed: false, title: `${todo.title} - Sub Task 2`, todoItem: todo },
{ completed: false, title: `${todo.title} - Sub Task 3`, todoItem: todo }
],
[] as Partial<SubTaskEntity>[]
)
)
}
59 changes: 59 additions & 0 deletions examples/basic-rest/e2e/tag.endpoint.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { INestApplication, ValidationPipe } from '@nestjs/common'
import { Test } from '@nestjs/testing'
import { OffsetConnectionType } from '@ptc-org/nestjs-query-rest'
import request from 'supertest'
import { Connection } from 'typeorm'

import { generateOpenapiSpec } from '../../helpers/generate-openapi-spec'
import { AppModule } from '../src/app.module'
import { TagDTO } from '../src/tag/dto/tag.dto'
import { refresh } from './fixtures'

describe('TagResolver (basic rest - e2e)', () => {
let app: INestApplication

beforeAll(async () => {
const moduleRef = await Test.createTestingModule({
imports: [AppModule]
}).compile()

app = moduleRef.createNestApplication()
app.useGlobalPipes(
new ValidationPipe({
whitelist: true,
forbidUnknownValues: false
})
)

generateOpenapiSpec(app, __dirname)

await app.init()
await refresh(app.get(Connection))
})

afterAll(() => refresh(app.get(Connection)))

const tags = [
{ id: 1, name: 'Urgent' },
{ id: 2, name: 'Home' },
{ id: 3, name: 'Work' },
{ id: 4, name: 'Question' },
{ id: 5, name: 'Blocked' }
]

describe('query', () => {
it(`should return a connection`, () =>
request(app.getHttpServer())
.get('/tag-dtos')
.expect(200)
.then(({ body }) => {
const { nodes }: OffsetConnectionType<TagDTO> = body
expect(nodes).toHaveLength(5)
expect(nodes.map((e) => e)).toMatchObject(tags)
}))
})

afterAll(async () => {
await app.close()
})
})
Loading
Loading