Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2021-1-capstone-design2
/
2015104215
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
장재혁
2021-04-26 03:14:21 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
65b87f071820ff147d0a3bb9e3709a734b6d3773
65b87f07
1 parent
2ba08dfb
Add typeorm ,graphql settings for api testings
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
0 deletions
project/packages/api/src/mypage/dto/create-mypage.input.ts
project/packages/api/src/mypage/mypage.resolver.ts
project/packages/api/src/mypage/mypage.service.spec.ts
project/packages/api/src/mypage/mypage.service.ts
project/packages/api/src/mypage/dto/create-mypage.input.ts
0 → 100644
View file @
65b87f0
import
{
Field
,
InputType
}
from
'@nestjs/graphql'
;
import
{
IsAlpha
}
from
'class-validator'
;
import
{
Entity
}
from
'typeorm'
;
@
Entity
()
@
InputType
()
export
class
CreateMyInput
{
@
IsAlpha
()
@
Field
()
name
:
string
;
@
Field
({
nullable
:
true
})
type
?:
string
;
}
project/packages/api/src/mypage/mypage.resolver.ts
0 → 100644
View file @
65b87f0
import
{
Args
,
Mutation
,
Query
,
Resolver
}
from
'@nestjs/graphql'
;
import
{
MypageService
}
from
'./mypage.service'
;
import
{
MyPage
}
from
'./mypage.entity'
;
import
{
CreateMyInput
}
from
'./dto/create-mypage.input'
;
@
Resolver
((
of
)
=>
MyPage
)
export
class
MypageResolver
{
constructor
(
private
myPageService
:
MypageService
)
{}
@
Query
((
returns
)
=>
[
MyPage
])
myPage
():
Promise
<
MyPage
[]
>
{
return
this
.
myPageService
.
findAll
();
}
@
Mutation
((
returns
)
=>
MyPage
)
createMyPage
(
@
Args
(
'createMyInput'
)
createMyPage
:
CreateMyInput
,
):
Promise
<
MyPage
>
{
return
this
.
myPageService
.
createMy
(
createMyPage
);
}
}
project/packages/api/src/mypage/mypage.service.spec.ts
0 → 100644
View file @
65b87f0
import
{
Test
,
TestingModule
}
from
'@nestjs/testing'
;
import
{
MypageService
}
from
'./mypage.service'
;
describe
(
'MypageService'
,
()
=>
{
let
service
:
MypageService
;
beforeEach
(
async
()
=>
{
const
module
:
TestingModule
=
await
Test
.
createTestingModule
({
providers
:
[
MypageService
],
}).
compile
();
service
=
module
.
get
<
MypageService
>
(
MypageService
);
});
it
(
'should be defined'
,
()
=>
{
expect
(
service
).
toBeDefined
();
});
});
project/packages/api/src/mypage/mypage.service.ts
0 → 100644
View file @
65b87f0
import
{
Injectable
}
from
'@nestjs/common'
;
import
{
InjectRepository
}
from
'@nestjs/typeorm'
;
import
{
Repository
}
from
'typeorm'
;
import
{
CreateMyInput
}
from
'./dto/create-mypage.input'
;
import
{
MyPage
}
from
'./mypage.entity'
;
@
Injectable
()
export
class
MypageService
{
constructor
(
@
InjectRepository
(
MyPage
)
private
myPageRepository
:
Repository
<
MyPage
>
,
)
{}
async
createMy
(
createMyInput
:
CreateMyInput
):
Promise
<
MyPage
>
{
const
newPage
=
this
.
myPageRepository
.
create
(
createMyInput
);
return
this
.
myPageRepository
.
save
(
newPage
);
}
async
findAll
():
Promise
<
MyPage
[]
>
{
return
this
.
myPageRepository
.
find
();
}
}
Please
register
or
login
to post a comment