Toggle navigation
Toggle navigation
This project
Loading...
Sign in
엄성진
/
learn-in-web-backend
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
sungjin
2021-12-06 00:52:44 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e8107096ffd5cfb9282cba291b12196c44f28877
e8107096
1 parent
c285cee7
Remove all unused import & variable
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
13 additions
and
51 deletions
src/auth/auth.controller.ts
src/post/post.service.ts
src/prisma.service.ts
src/runner/runner.service.ts
test/app.e2e-spec.ts
test/jest-e2e.json
src/auth/auth.controller.ts
View file @
e810709
...
...
@@ -3,25 +3,25 @@ import { AuthService } from './auth.service';
@
Controller
(
'auth'
)
export
class
AuthController
{
constructor
(
private
readonly
A
uthService
:
AuthService
)
{}
constructor
(
private
readonly
a
uthService
:
AuthService
)
{}
@
Post
(
'signup'
)
signUp
(
@
Body
()
body
)
{
return
this
.
A
uthService
.
createUser
(
body
.
name
,
body
.
email
,
body
.
password
);
return
this
.
a
uthService
.
createUser
(
body
.
name
,
body
.
email
,
body
.
password
);
}
@
Post
(
'signin'
)
signIn
(
@
Body
()
body
)
{
return
this
.
A
uthService
.
login
(
body
.
email
,
body
.
password
);
return
this
.
a
uthService
.
login
(
body
.
email
,
body
.
password
);
}
@
Post
(
'refresh'
)
refresh
(
@
Body
()
body
)
{
return
this
.
A
uthService
.
refreshTokens
(
body
.
token
);
return
this
.
a
uthService
.
refreshTokens
(
body
.
token
);
}
@
Post
(
'validate'
)
validate
(
@
Body
()
body
)
{
return
this
.
A
uthService
.
getUserFromToken
(
body
.
token
);
return
this
.
a
uthService
.
getUserFromToken
(
body
.
token
);
}
}
...
...
src/post/post.service.ts
View file @
e810709
...
...
@@ -70,7 +70,7 @@ export class PostService {
}
async
getPostsByUser
(
token
:
string
,
userId
:
string
,
take
:
number
)
{
const
user
=
await
this
.
auth
.
getUserFromToken
(
token
);
await
this
.
auth
.
getUserFromToken
(
token
);
const
posts
=
await
this
.
prisma
.
post
.
findMany
({
where
:
{
authorId
:
userId
,
...
...
@@ -142,7 +142,7 @@ export class PostService {
testoutput
:
string
[],
difficulty
:
number
,
)
{
const
user
=
await
this
.
auth
.
getUserFromToken
(
token
);
await
this
.
auth
.
getUserFromToken
(
token
);
let
level
:
Level
;
if
(
difficulty
==
1
)
{
level
=
'LOW'
;
...
...
@@ -169,7 +169,7 @@ export class PostService {
}
async
deletePost
(
token
:
string
,
id
:
number
)
{
const
user
=
await
this
.
auth
.
getUserFromToken
(
token
);
await
this
.
auth
.
getUserFromToken
(
token
);
const
post
=
await
this
.
prisma
.
post
.
delete
({
where
:
{
id
:
id
,
...
...
@@ -190,7 +190,7 @@ export class PostService {
})
)
return
this
.
getPost
(
id
);
const
post
=
await
this
.
prisma
.
postLike
.
create
({
await
this
.
prisma
.
postLike
.
create
({
data
:
{
post
:
{
connect
:
{
...
...
@@ -229,7 +229,7 @@ export class PostService {
}
async
deleteComment
(
token
:
string
,
id
:
string
)
{
const
user
=
await
this
.
auth
.
getUserFromToken
(
token
);
await
this
.
auth
.
getUserFromToken
(
token
);
const
comment
=
await
this
.
prisma
.
comment
.
delete
({
where
:
{
id
:
id
,
...
...
src/prisma.service.ts
View file @
e810709
import
{
INestApplication
,
Injectable
,
OnModuleInit
,
OnModuleDestroy
,
}
from
'@nestjs/common'
;
import
{
INestApplication
,
Injectable
,
OnModuleInit
}
from
'@nestjs/common'
;
import
{
PrismaClient
}
from
'@prisma/client'
;
@
Injectable
()
...
...
src/runner/runner.service.ts
View file @
e810709
import
{
Body
,
Injectable
}
from
'@nestjs/common'
;
import
{
Injectable
}
from
'@nestjs/common'
;
import
*
as
child_process
from
'child_process'
;
import
{
AuthService
}
from
'src/auth/auth.service'
;
import
*
as
fs
from
'fs'
;
...
...
@@ -54,7 +54,7 @@ export class RunnerService {
c
(
body
:
any
,
location
:
string
)
{
const
output
:
Array
<
string
>
=
[];
if
(
body
.
input
==
''
||
body
.
input
==
undefined
)
{
c
onst
test
=
c
hild_process
.
spawnSync
(
'gcc'
,
[
location
,
'-o'
,
'tmp'
],
{
child_process
.
spawnSync
(
'gcc'
,
[
location
,
'-o'
,
'tmp'
],
{
encoding
:
'utf8'
,
shell
:
true
,
});
...
...
test/app.e2e-spec.ts
deleted
100755 → 0
View file @
c285cee
import
{
Test
,
TestingModule
}
from
'@nestjs/testing'
;
import
{
INestApplication
}
from
'@nestjs/common'
;
import
*
as
request
from
'supertest'
;
import
{
AppModule
}
from
'./../src/app.module'
;
describe
(
'AppController (e2e)'
,
()
=>
{
let
app
:
INestApplication
;
beforeEach
(
async
()
=>
{
const
moduleFixture
:
TestingModule
=
await
Test
.
createTestingModule
({
imports
:
[
AppModule
],
}).
compile
();
app
=
moduleFixture
.
createNestApplication
();
await
app
.
init
();
});
it
(
'/ (GET)'
,
()
=>
{
return
request
(
app
.
getHttpServer
())
.
get
(
'/'
)
.
expect
(
200
)
.
expect
(
'Hello World!'
);
});
});
test/jest-e2e.json
deleted
100755 → 0
View file @
c285cee
{
"moduleFileExtensions"
:
[
"js"
,
"json"
,
"ts"
],
"rootDir"
:
"."
,
"testEnvironment"
:
"node"
,
"testRegex"
:
".e2e-spec.ts$"
,
"transform"
:
{
"^.+
\\
.(t|j)s$"
:
"ts-jest"
}
}
Please
register
or
login
to post a comment