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-05-13 05:08:39 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
08155d09264f8c80fc947053818daca4283abbc9
08155d09
1 parent
712e6549
Fix semi colon
Hide whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
203 additions
and
129 deletions
project/packages/api/.eslintrc.js
project/packages/api/.prettierrc
project/packages/api/database.db
project/packages/api/src/app.controller.spec.ts
project/packages/api/src/app.controller.ts
project/packages/api/src/app.module.ts
project/packages/api/src/app.service.ts
project/packages/api/src/comment/comment.module.ts
project/packages/api/src/comment/comment.resolver.spec.ts
project/packages/api/src/comment/comment.resolver.ts
project/packages/api/src/comment/comment.service.spec.ts
project/packages/api/src/comment/comment.service.ts
project/packages/api/src/likeable/likeable.module.ts
project/packages/api/src/likeable/likeable.resolver.spec.ts
project/packages/api/src/likeable/likeable.resolver.ts
project/packages/api/src/likeable/likeable.service.ts
project/packages/api/src/post/dto/post.input.ts
project/packages/api/src/post/post.entity.ts → project/packages/api/src/post/model/post.entity.ts
project/packages/api/src/post/post.module.ts
project/packages/api/src/post/post.resolver.spec.ts
project/packages/api/src/post/post.resolver.ts
project/packages/api/src/post/post.service.spec.ts
project/packages/api/src/post/post.service.ts
project/packages/api/src/user/user.module.ts
project/packages/api/src/user/user.resolver.spec.ts
project/packages/api/src/user/user.resolver.ts
project/packages/api/src/user/user.service.spec.ts
project/packages/api/src/user/user.service.ts
project/packages/api/.eslintrc.js
View file @
08155d0
...
...
@@ -22,5 +22,12 @@ module.exports = {
'@typescript-eslint/explicit-module-boundary-types'
:
'off'
,
'@typescript-eslint/no-explicit-any'
:
'off'
,
'@typescript-eslint/no-unused-vars'
:
'off'
,
semi
:
[
2
,
'never'
],
'prettier/prettier'
:
[
'error'
,
{
semi
:
false
,
},
],
},
}
;
}
...
...
project/packages/api/.prettierrc
View file @
08155d0
{
"singleQuote"
:
true
,
"trailingComma"
:
"all"
"trailingComma"
:
"all"
,
"semi"
:
false
}
\ No newline at end of file
...
...
project/packages/api/database.db
View file @
08155d0
No preview for this file type
project/packages/api/src/app.controller.spec.ts
View file @
08155d0
import
{
Test
,
TestingModule
}
from
'@nestjs/testing'
;
import
{
AppController
}
from
'./app.controller'
;
import
{
AppService
}
from
'./app.service'
;
import
{
Test
,
TestingModule
}
from
'@nestjs/testing'
import
{
AppController
}
from
'./app.controller'
import
{
AppService
}
from
'./app.service'
describe
(
'AppController'
,
()
=>
{
let
appController
:
AppController
;
let
appController
:
AppController
beforeEach
(
async
()
=>
{
const
app
:
TestingModule
=
await
Test
.
createTestingModule
({
controllers
:
[
AppController
],
providers
:
[
AppService
],
}).
compile
()
;
}).
compile
()
appController
=
app
.
get
<
AppController
>
(
AppController
)
;
})
;
appController
=
app
.
get
<
AppController
>
(
AppController
)
})
describe
(
'root'
,
()
=>
{
it
(
'should return "Hello World!"'
,
()
=>
{
expect
(
appController
.
getHello
()).
toBe
(
'Hello World!'
)
;
})
;
})
;
})
;
expect
(
appController
.
getHello
()).
toBe
(
'Hello World!'
)
})
})
})
...
...
project/packages/api/src/app.controller.ts
View file @
08155d0
import
{
Controller
,
Get
}
from
'@nestjs/common'
;
import
{
AppService
}
from
'./app.service'
;
import
{
Controller
,
Get
}
from
'@nestjs/common'
import
{
AppService
}
from
'./app.service'
@
Controller
()
export
class
AppController
{
...
...
@@ -7,6 +7,6 @@ export class AppController {
@
Get
()
getHello
():
string
{
return
this
.
appService
.
getHello
()
;
return
this
.
appService
.
getHello
()
}
}
...
...
project/packages/api/src/app.module.ts
View file @
08155d0
import
{
Module
}
from
'@nestjs/common'
;
import
{
GraphQLModule
}
from
'@nestjs/graphql'
;
import
{
TypeOrmModule
}
from
'@nestjs/typeorm'
;
import
{
join
}
from
'path'
;
import
{
AppController
}
from
'./app.controller'
;
import
{
AppService
}
from
'./app.service'
;
import
{
MypageModule
}
from
'./mypage/mypage.module'
;
import
{
PostModule
}
from
'./post/post.module'
;
import
{
CommentModule
}
from
'./comment/comment.module'
;
import
{
UserModule
}
from
'./user/user.module'
;
import
{
LikeableService
}
from
'./likeable/likeable.service'
;
import
{
LikeableModule
}
from
'./likeable/likeable.module'
;
import
{
Module
}
from
'@nestjs/common'
import
{
GraphQLModule
}
from
'@nestjs/graphql'
import
{
TypeOrmModule
}
from
'@nestjs/typeorm'
import
{
join
}
from
'path'
import
{
AppController
}
from
'./app.controller'
import
{
AppService
}
from
'./app.service'
import
{
MypageModule
}
from
'./mypage/mypage.module'
import
{
PostModule
}
from
'./post/post.module'
import
{
CommentModule
}
from
'./comment/comment.module'
import
{
UserModule
}
from
'./user/user.module'
import
{
LikeableService
}
from
'./likeable/likeable.service'
import
{
LikeableModule
}
from
'./likeable/likeable.module'
@
Module
({
imports
:
[
...
...
project/packages/api/src/app.service.ts
View file @
08155d0
import
{
Injectable
}
from
'@nestjs/common'
;
import
{
Injectable
}
from
'@nestjs/common'
@
Injectable
()
export
class
AppService
{
getHello
():
string
{
return
'Hello World!'
;
return
'Hello World!'
}
}
...
...
project/packages/api/src/comment/comment.module.ts
View file @
08155d0
import
{
Module
}
from
'@nestjs/common'
;
import
{
CommentService
}
from
'./comment.service'
;
import
{
CommentResolver
}
from
'./comment.resolver'
;
import
{
Module
}
from
'@nestjs/common'
import
{
CommentService
}
from
'./comment.service'
import
{
CommentResolver
}
from
'./comment.resolver'
@
Module
({
providers
:
[
CommentService
,
CommentResolver
],
...
...
project/packages/api/src/comment/comment.resolver.spec.ts
View file @
08155d0
import
{
Test
,
TestingModule
}
from
'@nestjs/testing'
;
import
{
CommentResolver
}
from
'./comment.resolver'
;
import
{
Test
,
TestingModule
}
from
'@nestjs/testing'
import
{
CommentResolver
}
from
'./comment.resolver'
describe
(
'CommentResolver'
,
()
=>
{
let
resolver
:
CommentResolver
;
let
resolver
:
CommentResolver
beforeEach
(
async
()
=>
{
const
module
:
TestingModule
=
await
Test
.
createTestingModule
({
providers
:
[
CommentResolver
],
}).
compile
()
;
}).
compile
()
resolver
=
module
.
get
<
CommentResolver
>
(
CommentResolver
)
;
})
;
resolver
=
module
.
get
<
CommentResolver
>
(
CommentResolver
)
})
it
(
'should be defined'
,
()
=>
{
expect
(
resolver
).
toBeDefined
()
;
})
;
})
;
expect
(
resolver
).
toBeDefined
()
})
})
...
...
project/packages/api/src/comment/comment.resolver.ts
View file @
08155d0
import
{
Resolver
}
from
'@nestjs/graphql'
;
import
{
Resolver
}
from
'@nestjs/graphql'
@
Resolver
()
export
class
CommentResolver
{}
...
...
project/packages/api/src/comment/comment.service.spec.ts
View file @
08155d0
import
{
Test
,
TestingModule
}
from
'@nestjs/testing'
;
import
{
CommentService
}
from
'./comment.service'
;
import
{
Test
,
TestingModule
}
from
'@nestjs/testing'
import
{
CommentService
}
from
'./comment.service'
describe
(
'CommentService'
,
()
=>
{
let
service
:
CommentService
;
let
service
:
CommentService
beforeEach
(
async
()
=>
{
const
module
:
TestingModule
=
await
Test
.
createTestingModule
({
providers
:
[
CommentService
],
}).
compile
()
;
}).
compile
()
service
=
module
.
get
<
CommentService
>
(
CommentService
)
;
})
;
service
=
module
.
get
<
CommentService
>
(
CommentService
)
})
it
(
'should be defined'
,
()
=>
{
expect
(
service
).
toBeDefined
()
;
})
;
})
;
expect
(
service
).
toBeDefined
()
})
})
...
...
project/packages/api/src/comment/comment.service.ts
View file @
08155d0
import
{
Injectable
}
from
'@nestjs/common'
;
import
{
Injectable
}
from
'@nestjs/common'
@
Injectable
()
export
class
CommentService
{}
...
...
project/packages/api/src/likeable/likeable.module.ts
View file @
08155d0
import
{
Module
}
from
'@nestjs/common'
;
import
{
LikeableResolver
}
from
'./likeable.resolver'
;
import
{
Module
}
from
'@nestjs/common'
import
{
LikeableResolver
}
from
'./likeable.resolver'
@
Module
({
providers
:
[
LikeableResolver
],
...
...
project/packages/api/src/likeable/likeable.resolver.spec.ts
View file @
08155d0
import
{
Test
,
TestingModule
}
from
'@nestjs/testing'
;
import
{
LikeableResolver
}
from
'./likeable.resolver'
;
import
{
Test
,
TestingModule
}
from
'@nestjs/testing'
import
{
LikeableResolver
}
from
'./likeable.resolver'
describe
(
'LikeableResolver'
,
()
=>
{
let
resolver
:
LikeableResolver
;
let
resolver
:
LikeableResolver
beforeEach
(
async
()
=>
{
const
module
:
TestingModule
=
await
Test
.
createTestingModule
({
providers
:
[
LikeableResolver
],
}).
compile
()
;
}).
compile
()
resolver
=
module
.
get
<
LikeableResolver
>
(
LikeableResolver
)
;
})
;
resolver
=
module
.
get
<
LikeableResolver
>
(
LikeableResolver
)
})
it
(
'should be defined'
,
()
=>
{
expect
(
resolver
).
toBeDefined
()
;
})
;
})
;
expect
(
resolver
).
toBeDefined
()
})
})
...
...
project/packages/api/src/likeable/likeable.resolver.ts
View file @
08155d0
import
{
Resolver
}
from
'@nestjs/graphql'
;
import
{
Resolver
}
from
'@nestjs/graphql'
@
Resolver
()
export
class
LikeableResolver
{}
...
...
project/packages/api/src/likeable/likeable.service.ts
View file @
08155d0
import
{
Injectable
}
from
'@nestjs/common'
;
import
{
Injectable
}
from
'@nestjs/common'
@
Injectable
()
export
class
LikeableService
{}
...
...
project/packages/api/src/post/dto/post.input.ts
View file @
08155d0
import
{
Field
,
InputType
}
from
'@nestjs/graphql'
;
import
{
Entity
}
from
'typeorm'
;
import
{
Field
,
InputType
,
PartialType
,
PickType
}
from
'@nestjs/graphql'
;
import
{
IsNumber
}
from
'class-validator'
;
import
{
Post
}
from
'../model/post.entity'
;
@
Entity
()
@
InputType
()
export
class
GetPostInput
{
@
Field
()
...
...
@@ -13,3 +13,17 @@ export class GetPostInput {
@
Field
({
nullable
:
true
})
category
?:
string
;
}
@
InputType
()
export
class
CreatePostInput
extends
PickType
(
Post
,
[
'category'
,
'content'
,
'title'
],
InputType
,
)
{}
@
InputType
()
export
class
UpdatePostInput
extends
PartialType
(
CreatePostInput
)
{
@
Field
()
@
IsNumber
()
id
:
number
;
}
...
...
project/packages/api/src/post/post.entity.ts
→
project/packages/api/src/post/
model/
post.entity.ts
View file @
08155d0
File moved
project/packages/api/src/post/post.module.ts
View file @
08155d0
import
{
Module
}
from
'@nestjs/common'
;
import
{
PostService
}
from
'./post.service'
;
import
{
PostResolver
}
from
'./post.resolver'
;
import
{
TypeOrmModule
}
from
'@nestjs/typeorm'
;
import
{
Post
}
from
'./
post.entity'
;
import
{
Module
}
from
'@nestjs/common'
import
{
PostService
}
from
'./post.service'
import
{
PostResolver
}
from
'./post.resolver'
import
{
TypeOrmModule
}
from
'@nestjs/typeorm'
import
{
Post
}
from
'./
model/post.entity'
@
Module
({
imports
:
[
TypeOrmModule
.
forFeature
([
Post
])],
...
...
project/packages/api/src/post/post.resolver.spec.ts
View file @
08155d0
import
{
Test
,
TestingModule
}
from
'@nestjs/testing'
;
import
{
PostResolver
}
from
'./post.resolver'
;
import
{
Test
,
TestingModule
}
from
'@nestjs/testing'
import
{
PostResolver
}
from
'./post.resolver'
describe
(
'PostResolver'
,
()
=>
{
let
resolver
:
PostResolver
;
let
resolver
:
PostResolver
beforeEach
(
async
()
=>
{
const
module
:
TestingModule
=
await
Test
.
createTestingModule
({
providers
:
[
PostResolver
],
}).
compile
()
;
}).
compile
()
resolver
=
module
.
get
<
PostResolver
>
(
PostResolver
)
;
})
;
resolver
=
module
.
get
<
PostResolver
>
(
PostResolver
)
})
it
(
'should be defined'
,
()
=>
{
expect
(
resolver
).
toBeDefined
()
;
})
;
})
;
expect
(
resolver
).
toBeDefined
()
})
})
...
...
project/packages/api/src/post/post.resolver.ts
View file @
08155d0
import
{
Args
,
Mutation
,
Query
,
Resolver
}
from
'@nestjs/graphql'
;
import
{
PostService
}
from
'./post.service'
;
import
{
Post
}
from
'./
post.entity'
;
import
{
GetPostInput
}
from
'./dto/post.input'
;
import
{
Args
,
Mutation
,
Query
,
Resolver
}
from
'@nestjs/graphql'
import
{
PostService
}
from
'./post.service'
import
{
Post
}
from
'./
model/post.entity'
import
{
GetPostInput
}
from
'./dto/post.input'
@
Resolver
((
of
)
=>
Post
)
export
class
PostResolver
{
...
...
@@ -9,11 +9,11 @@ export class PostResolver {
@
Query
((
returns
)
=>
[
Post
])
getPosts
():
Promise
<
Post
[]
>
{
return
this
.
postService
.
findAll
()
;
return
this
.
postService
.
findAll
()
}
@
Query
((
returns
)
=>
Post
)
getPost
(
@
Args
(
'id'
)
id
:
number
):
Promise
<
Post
>
{
return
this
.
postService
.
findOne
(
id
)
;
return
this
.
postService
.
findOne
(
id
)
}
}
...
...
project/packages/api/src/post/post.service.spec.ts
View file @
08155d0
import
{
Test
,
TestingModule
}
from
'@nestjs/testing'
;
import
{
PostService
}
from
'./post.service'
;
import
{
Test
,
TestingModule
}
from
'@nestjs/testing'
import
{
PostService
}
from
'./post.service'
describe
(
'PostService'
,
()
=>
{
let
service
:
PostService
;
let
service
:
PostService
beforeEach
(
async
()
=>
{
const
module
:
TestingModule
=
await
Test
.
createTestingModule
({
providers
:
[
PostService
],
}).
compile
()
;
}).
compile
()
service
=
module
.
get
<
PostService
>
(
PostService
)
;
})
;
service
=
module
.
get
<
PostService
>
(
PostService
)
})
it
(
'should be defined'
,
()
=>
{
expect
(
service
).
toBeDefined
()
;
})
;
})
;
expect
(
service
).
toBeDefined
()
})
})
...
...
project/packages/api/src/post/post.service.ts
View file @
08155d0
import
{
Injectable
}
from
'@nestjs/common'
;
import
{
InjectRepository
}
from
'@nestjs/typeorm'
;
import
{
Repository
}
from
'typeorm'
;
import
{
GetPostInput
}
from
'./dto/post.input'
;
import
{
Post
}
from
'./post.entity'
;
import
{
Injectable
}
from
'@nestjs/common'
import
{
InjectRepository
}
from
'@nestjs/typeorm'
import
{
QueryRunner
,
Repository
,
getConnection
}
from
'typeorm'
import
{
CreatePostInput
,
GetPostInput
,
UpdatePostInput
,
}
from
'./dto/post.input'
import
{
Post
}
from
'./model/post.entity'
@
Injectable
()
export
class
PostService
{
constructor
(
@
InjectRepository
(
Post
)
private
postRepository
:
Repository
<
Post
>
,
)
{}
private
connection
=
getConnection
()
async
findAll
():
Promise
<
Post
[]
>
{
return
this
.
postRepository
.
find
()
;
return
this
.
postRepository
.
find
()
}
async
findOne
(
id
:
number
):
Promise
<
Post
>
{
return
this
.
postRepository
.
findOne
(
id
);
return
this
.
postRepository
.
findOne
(
id
)
}
async
findSome
(
input
:
Partial
<
GetPostInput
>
):
Promise
<
Post
[]
>
{
return
this
.
postRepository
.
createQueryBuilder
(
'post'
)
.
where
(
'post.author like :author'
,
{
author
:
input
.
author
})
.
getMany
()
}
async
createOne
(
input
:
CreatePostInput
):
Promise
<
Post
>
{
let
result
const
queryRunner
:
QueryRunner
=
this
.
connection
.
createQueryRunner
()
await
queryRunner
.
connect
()
await
queryRunner
.
startTransaction
()
try
{
result
=
await
queryRunner
.
manager
.
save
(
this
.
postRepository
.
create
(
input
))
await
queryRunner
.
commitTransaction
()
}
catch
(
err
)
{
await
queryRunner
.
rollbackTransaction
()
throw
err
}
finally
{
await
queryRunner
.
release
()
}
return
result
}
async
updateOne
(
input
:
UpdatePostInput
):
Promise
<
Post
>
{
let
result
const
queryRunner
:
QueryRunner
=
this
.
connection
.
createQueryRunner
()
await
queryRunner
.
connect
()
await
queryRunner
.
startTransaction
()
try
{
const
before
=
await
this
.
postRepository
.
findOne
(
input
.
id
)
result
=
await
queryRunner
.
manager
.
save
(
this
.
postRepository
.
create
(
input
))
await
queryRunner
.
commitTransaction
()
}
catch
(
err
)
{
await
queryRunner
.
rollbackTransaction
()
throw
err
}
finally
{
await
queryRunner
.
release
()
}
return
result
}
}
...
...
project/packages/api/src/user/user.module.ts
View file @
08155d0
import
{
Module
}
from
'@nestjs/common'
;
import
{
UserResolver
}
from
'./user.resolver'
;
import
{
UserService
}
from
'./user.service'
;
import
{
Module
}
from
'@nestjs/common'
import
{
UserResolver
}
from
'./user.resolver'
import
{
UserService
}
from
'./user.service'
@
Module
({
providers
:
[
UserResolver
,
UserService
]
providers
:
[
UserResolver
,
UserService
]
,
})
export
class
UserModule
{}
...
...
project/packages/api/src/user/user.resolver.spec.ts
View file @
08155d0
import
{
Test
,
TestingModule
}
from
'@nestjs/testing'
;
import
{
UserResolver
}
from
'./user.resolver'
;
import
{
Test
,
TestingModule
}
from
'@nestjs/testing'
import
{
UserResolver
}
from
'./user.resolver'
describe
(
'UserResolver'
,
()
=>
{
let
resolver
:
UserResolver
;
let
resolver
:
UserResolver
beforeEach
(
async
()
=>
{
const
module
:
TestingModule
=
await
Test
.
createTestingModule
({
providers
:
[
UserResolver
],
}).
compile
()
;
}).
compile
()
resolver
=
module
.
get
<
UserResolver
>
(
UserResolver
)
;
})
;
resolver
=
module
.
get
<
UserResolver
>
(
UserResolver
)
})
it
(
'should be defined'
,
()
=>
{
expect
(
resolver
).
toBeDefined
()
;
})
;
})
;
expect
(
resolver
).
toBeDefined
()
})
})
...
...
project/packages/api/src/user/user.resolver.ts
View file @
08155d0
import
{
Resolver
}
from
'@nestjs/graphql'
;
import
{
Resolver
}
from
'@nestjs/graphql'
@
Resolver
()
export
class
UserResolver
{}
...
...
project/packages/api/src/user/user.service.spec.ts
View file @
08155d0
import
{
Test
,
TestingModule
}
from
'@nestjs/testing'
;
import
{
UserService
}
from
'./user.service'
;
import
{
Test
,
TestingModule
}
from
'@nestjs/testing'
import
{
UserService
}
from
'./user.service'
describe
(
'UserService'
,
()
=>
{
let
service
:
UserService
;
let
service
:
UserService
beforeEach
(
async
()
=>
{
const
module
:
TestingModule
=
await
Test
.
createTestingModule
({
providers
:
[
UserService
],
}).
compile
()
;
}).
compile
()
service
=
module
.
get
<
UserService
>
(
UserService
)
;
})
;
service
=
module
.
get
<
UserService
>
(
UserService
)
})
it
(
'should be defined'
,
()
=>
{
expect
(
service
).
toBeDefined
()
;
})
;
})
;
expect
(
service
).
toBeDefined
()
})
})
...
...
project/packages/api/src/user/user.service.ts
View file @
08155d0
import
{
Injectable
}
from
'@nestjs/common'
;
import
{
Injectable
}
from
'@nestjs/common'
@
Injectable
()
export
class
UserService
{}
...
...
Please
register
or
login
to post a comment