Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
duiba-tiny-image-node
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
劳工
duiba-tiny-image-node
Commits
9197b5d5
Commit
9197b5d5
authored
Feb 13, 2020
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加日志
parent
f6341219
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
7 deletions
+21
-7
index.js
dist/index.js
+9
-3
index.js.map
dist/index.js.map
+1
-1
api.js
src/api.js
+1
-3
index.js
src/index.js
+10
-0
No files found.
dist/index.js
View file @
9197b5d5
...
...
@@ -71,8 +71,6 @@ function applyApi(server){
});
server
.
post
(
'/tinify'
,
async
function
(
req
,
res
,
next
)
{
logger
.
info
(
'/tinify'
);
let
file
=
req
.
files
.
file
;
if
(
file
){
...
...
@@ -91,7 +89,7 @@ function applyApi(server){
'Content-Type'
:
file
.
type
,
});
}
catch
(
e
)
{
logger
.
error
(
'/tinify'
,
'compress failed'
);
logger
.
error
(
'/tinify'
,
'compress failed'
,
e
.
message
);
res
.
send
({
code
:
3
,
msg
:
'compress failed'
...
...
@@ -128,9 +126,17 @@ const server = restify.createServer({
version
:
'1.0.0'
});
const
ignoreUrlLogger
=
[
'/monitor/check'
];
server
.
use
(
restify
.
plugins
.
acceptParser
(
server
.
acceptable
));
server
.
use
(
restify
.
plugins
.
queryParser
());
server
.
use
(
restify
.
plugins
.
bodyParser
());
server
.
use
(
function
(
req
,
res
,
next
)
{
if
(
!
ignoreUrlLogger
.
includes
(
req
.
url
))
{
logger
.
info
(
req
.
url
);
}
return
next
();
});
applyApi
(
server
);
...
...
dist/index.js.map
View file @
9197b5d5
This diff is collapsed.
Click to expand it.
src/api.js
View file @
9197b5d5
...
...
@@ -21,8 +21,6 @@ export default function applyApi(server){
});
server
.
post
(
'/tinify'
,
async
function
(
req
,
res
,
next
)
{
logger
.
info
(
'/tinify'
);
let
file
=
req
.
files
.
file
;
if
(
file
){
...
...
@@ -41,7 +39,7 @@ export default function applyApi(server){
'Content-Type'
:
file
.
type
,
});
}
catch
(
e
)
{
logger
.
error
(
'/tinify'
,
'compress failed'
);
logger
.
error
(
'/tinify'
,
'compress failed'
,
e
.
message
);
res
.
send
({
code
:
3
,
msg
:
'compress failed'
...
...
src/index.js
View file @
9197b5d5
...
...
@@ -16,9 +16,17 @@ const server = restify.createServer({
version
:
'1.0.0'
});
const
ignoreUrlLogger
=
[
'/monitor/check'
];
server
.
use
(
restify
.
plugins
.
acceptParser
(
server
.
acceptable
));
server
.
use
(
restify
.
plugins
.
queryParser
());
server
.
use
(
restify
.
plugins
.
bodyParser
());
server
.
use
(
function
(
req
,
res
,
next
)
{
if
(
!
ignoreUrlLogger
.
includes
(
req
.
url
))
{
logger
.
info
(
req
.
url
);
}
return
next
();
});
applyApi
(
server
);
...
...
@@ -42,3 +50,5 @@ server.listen(port, async function () {
}
logger
.
info
(
'%s listening at %s'
,
server
.
name
,
server
.
url
);
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment