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
Show 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
{
"version"
:
3
,
"file"
:
"index.js"
,
"sources"
:
[
"../src/logger.js"
,
"../src/eureka.js"
,
"../src/api.js"
,
"../src/index.js"
],
"sourcesContent"
:
[
"/**
\n
* Created by rockyl on 2020-02-13.
\n
*/
\n\n
import {configure, getLogger} from 'log4js';
\n
import path from
\"
path
\"
;
\n
import fs from
\"
fs-extra
\"
;
\n\n
const logPath = path.join(process.env.HOME || process.env.USERPROFILE, 'logs', 'tiny-image');
\n\n
fs.ensureDir(logPath);
\n\n
configure({\n
\t
appenders: {\n
\t\t
out: {type: 'console'},
\n\t\t
allLog: {\n
\t\t\t
type: 'dateFile',
\n\t\t\t
filename: path.join(logPath, 'log.log'),
\n\t\t
},
\n\t
},
\n\t
categories: {\n
\t\t
default: {appenders: ['out', 'allLog'], level: 'debug'},
\n\t
}
\n\n
});
\n\n
const logger = getLogger();
\n\n
export default logger;"
,
"import Eurekaclient from 'eureka-client-ts';
\n
import logger from './logger';
\n\n
const eurekaConfig = {\n appName: 'tiny-image',
\n
services: ['tiny-image'],
\n
};
\n\n
export async function getEurekaClient(port) {\n eurekaConfig.port = port;
\n
let eureka;
\n
try {\n eureka = new Eurekaclient(eurekaConfig);
\n
await eureka.start();
\n
} catch (e) {\n logger.error(e);
\n
}
\n\n
return eureka;
\n
}
\n
"
,
"/**
\n
* Created by rockyl on 2020-02-13.
\n
*/
\n\n
import logger from
\"
./logger
\"
;
\n
import imagemin from
\"
imagemin
\"
;
\n
import imageminJpegtran from
\"
imagemin-jpegtran
\"
;
\n
import imageminPngquant from
\"
imagemin-pngquant
\"
;
\n\n
const acceptTypes = ['image/png', 'image/jpeg'];
\n\n
export default function applyApi(server){\n
\t
server.get('/echo/:name', function (req, res, next) {\n
\t\t
res.send(req.params);
\n\t\t
return next();
\n\t
});
\n\n\t
server.get('/monitor/check', function (req, res, next) {\n
\t\t
res.sendRaw('ok');
\n\t\t
return next();
\n\t
});
\n\n\t
server.post('/tinify', async function (req, res, next) {\n
\t\t
logger.info('/tinify');
\n\n\t\t
let file = req.files.file;
\n\n\t\t
if(file){\n
\t\t\t
if(acceptTypes.includes(file.type)){\n
\t\t\t\t
try {\n
\t\t\t\t\t
const buffer = await imagemin([file.path], {\n
\t\t\t\t\t\t
plugins: [
\n\t\t\t\t\t\t\t
imageminJpegtran(),
\n\t\t\t\t\t\t\t
imageminPngquant({\n
\t\t\t\t\t\t\t\t
quality: [0.6, 0.8]
\n\t\t\t\t\t\t\t
})
\n\t\t\t\t\t\t
]
\n\t\t\t\t\t
});
\n\n\t\t\t\t\t
res.sendRaw(buffer[0].data, {\n
\t\t\t\t\t\t
'Content-Type': file.type,
\n\t\t\t\t\t
});
\n\t\t\t\t
}catch (e) {\n
\t\t\t\t\t
logger.error('/tinify', 'compress failed');
\n\t\t\t\t\t
res.send({\n
\t\t\t\t\t\t
code: 3,
\n\t\t\t\t\t\t
msg: 'compress failed'
\n\t\t\t\t\t
});
\n\t\t\t\t
}
\n\t\t\t
}else{\n
\t\t\t\t
logger.error('/tinify', 'type error');
\n\t\t\t\t
res.send({\n
\t\t\t\t\t
code: 2,
\n\t\t\t\t\t
msg: 'type error'
\n\t\t\t\t
});
\n\t\t\t
}
\n\t\t
}else{\n
\t\t\t
res.send({\n
\t\t\t\t
code: 1,
\n\t\t\t\t
msg: 'file not exists'
\n\t\t\t
});
\n\t\t
}
\n\n\t\t
return next();
\n\t
});
\n
}"
,
"/**
\n
* Created by rockyl on 2020-02-12.
\n
*/
\n\n
import restify from 'restify';
\n
import
{
getEurekaClient
}
from
\"
./eureka
\"
;
\n
import logger from
\"
./logger
\"
;
\n
import applyApi from
\"
./api
\"
;
\n\n
let [_, __, port = '8090'] = process.argv;
\n
let eureka;
\n
port = parseInt(port);
\n\n
const server = restify.createServer({\n
\t
name: 'tiny-image',
\n\t
version: '1.0.0'
\n
});
\n\n
server.use(restify.plugins.acceptParser(server.acceptable));
\n
server.use(restify.plugins.queryParser());
\n
server.use(restify.plugins.bodyParser());
\n\n
applyApi(server);
\n\n
process.on('uncaughtException', (err) =>
{
\n\tlogger.error(err);\n
}
);
\n\n
process.on(
\"
SIGTERM
\"
, () => {\n
\t
eureka.stop();
\n\t
setTimeout(() =>
{
\n\t\tprocess.exit(1)\n\t
}
, 6000);
\n
});
\n\n
server.listen(port, async function () {\n
\t
try {\n
\t\t
eureka = await getEurekaClient(port);
\n\t\t
logger.info('eureka register success');
\n\t
} catch (e)
{
\n\t\tlogger.error(e.name);\n\t
}
\n\t
logger.info('%s listening at %s', server.name, server.url);
\n
});
\n
"
],
"names"
:
[
"configure"
,
"getLogger"
],
"mappings"
:
";;;;;;;;;;;;;AAAA;;;AAGA,AAIA;AACA,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;;AAE7F,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;;AAEtBA,gBAAS,CAAC;CACT,SAAS,EAAE;EACV,GAAG,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC;EACtB,MAAM,EAAE;GACP,IAAI,EAAE,UAAU;GAChB,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC;GACvC;EACD;CACD,UAAU,EAAE;EACX,OAAO,EAAE,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC;EACvD;;CAED,CAAC,CAAC;;AAEH,MAAM,MAAM,GAAGC,gBAAS,EAAE,CAAC;;ACvB3B,MAAM,YAAY,GAAG;EACnB,OAAO,EAAE,YAAY;EACrB,QAAQ,EAAE,CAAC,YAAY,CAAC;CACzB,CAAC;;AAEF,AAAO,eAAe,eAAe,CAAC,IAAI,EAAE;EAC1C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CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;;AAEzC,QAAQ,CAAC,MAAM,CAAC,CAAC;;AAEjB,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,GAAG,KAAK;CACxC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;CAClB,CAAC,CAAC;;AAEH,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM;CAC3B,MAAM,CAAC,IAAI,EAAE,CAAC;CACd,UAAU,CAAC,MAAM;EAChB,OAAO,CAAC,IAAI,CAAC,CAAC,EAAC;EACf,EAAE,IAAI,CAAC,CAAC;CACT,CAAC,CAAC;;AAEH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,kBAAkB;CACrC,IAAI;EACH,MAAM,GAAG,MAAM,eAAe,CAAC,IAAI,CAAC,CAAC;EACrC,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;EACvC,CAAC,OAAO,CAAC,EAAE;EACX,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;EACrB;CACD,MAAM,CAAC,IAAI,CAAC,oBAAoB,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;CAC3D,CAAC,CAAC"
}
\ No newline at end of file
{
"version"
:
3
,
"file"
:
"index.js"
,
"sources"
:
[
"../src/logger.js"
,
"../src/eureka.js"
,
"../src/api.js"
,
"../src/index.js"
],
"sourcesContent"
:
[
"/**
\n
* Created by rockyl on 2020-02-13.
\n
*/
\n\n
import {configure, getLogger} from 'log4js';
\n
import path from
\"
path
\"
;
\n
import fs from
\"
fs-extra
\"
;
\n\n
const logPath = path.join(process.env.HOME || process.env.USERPROFILE, 'logs', 'tiny-image');
\n\n
fs.ensureDir(logPath);
\n\n
configure({\n
\t
appenders: {\n
\t\t
out: {type: 'console'},
\n\t\t
allLog: {\n
\t\t\t
type: 'dateFile',
\n\t\t\t
filename: path.join(logPath, 'log.log'),
\n\t\t
},
\n\t
},
\n\t
categories: {\n
\t\t
default: {appenders: ['out', 'allLog'], level: 'debug'},
\n\t
}
\n\n
});
\n\n
const logger = getLogger();
\n\n
export default logger;"
,
"import Eurekaclient from 'eureka-client-ts';
\n
import logger from './logger';
\n\n
const eurekaConfig = {\n appName: 'tiny-image',
\n
services: ['tiny-image'],
\n
};
\n\n
export async function getEurekaClient(port) {\n eurekaConfig.port = port;
\n
let eureka;
\n
try {\n eureka = new Eurekaclient(eurekaConfig);
\n
await eureka.start();
\n
} catch (e) {\n logger.error(e);
\n
}
\n\n
return eureka;
\n
}
\n
"
,
"/**
\n
* Created by rockyl on 2020-02-13.
\n
*/
\n\n
import logger from
\"
./logger
\"
;
\n
import imagemin from
\"
imagemin
\"
;
\n
import imageminJpegtran from
\"
imagemin-jpegtran
\"
;
\n
import imageminPngquant from
\"
imagemin-pngquant
\"
;
\n\n
const acceptTypes = ['image/png', 'image/jpeg'];
\n\n
export default function applyApi(server){\n
\t
server.get('/echo/:name', function (req, res, next) {\n
\t\t
res.send(req.params);
\n\t\t
return next();
\n\t
});
\n\n\t
server.get('/monitor/check', function (req, res, next) {\n
\t\t
res.sendRaw('ok');
\n\t\t
return next();
\n\t
});
\n\n\t
server.post('/tinify', async function (req, res, next) {\n
\t\t
let file = req.files.file;
\n\n\t\t
if(file){\n
\t\t\t
if(acceptTypes.includes(file.type)){\n
\t\t\t\t
try {\n
\t\t\t\t\t
const buffer = await imagemin([file.path], {\n
\t\t\t\t\t\t
plugins: [
\n\t\t\t\t\t\t\t
imageminJpegtran(),
\n\t\t\t\t\t\t\t
imageminPngquant({\n
\t\t\t\t\t\t\t\t
quality: [0.6, 0.8]
\n\t\t\t\t\t\t\t
})
\n\t\t\t\t\t\t
]
\n\t\t\t\t\t
});
\n\n\t\t\t\t\t
res.sendRaw(buffer[0].data, {\n
\t\t\t\t\t\t
'Content-Type': file.type,
\n\t\t\t\t\t
});
\n\t\t\t\t
}catch (e) {\n
\t\t\t\t\t
logger.error('/tinify', 'compress failed', e.message);
\n\t\t\t\t\t
res.send({\n
\t\t\t\t\t\t
code: 3,
\n\t\t\t\t\t\t
msg: 'compress failed'
\n\t\t\t\t\t
});
\n\t\t\t\t
}
\n\t\t\t
}else{\n
\t\t\t\t
logger.error('/tinify', 'type error');
\n\t\t\t\t
res.send({\n
\t\t\t\t\t
code: 2,
\n\t\t\t\t\t
msg: 'type error'
\n\t\t\t\t
});
\n\t\t\t
}
\n\t\t
}else{\n
\t\t\t
res.send({\n
\t\t\t\t
code: 1,
\n\t\t\t\t
msg: 'file not exists'
\n\t\t\t
});
\n\t\t
}
\n\n\t\t
return next();
\n\t
});
\n
}"
,
"/**
\n
* Created by rockyl on 2020-02-12.
\n
*/
\n\n
import restify from 'restify';
\n
import
{
getEurekaClient
}
from
\"
./eureka
\"
;
\n
import logger from
\"
./logger
\"
;
\n
import applyApi from
\"
./api
\"
;
\n\n
let [_, __, port = '8090'] = process.argv;
\n
let eureka;
\n
port = parseInt(port);
\n\n
const server = restify.createServer({\n
\t
name: 'tiny-image',
\n\t
version: '1.0.0'
\n
});
\n\n
const ignoreUrlLogger = ['/monitor/check'];
\n\n
server.use(restify.plugins.acceptParser(server.acceptable));
\n
server.use(restify.plugins.queryParser());
\n
server.use(restify.plugins.bodyParser());
\n
server.use(function (req, res, next) {\n
\t
if (!ignoreUrlLogger.includes(req.url))
{
\n\t\tlogger.info(req.url);\n\t
}
\n\t
return next();
\n
});
\n\n
applyApi(server);
\n\n
process.on('uncaughtException', (err) =>
{
\n\tlogger.error(err);\n
}
);
\n\n
process.on(
\"
SIGTERM
\"
, () => {\n
\t
eureka.stop();
\n\t
setTimeout(() =>
{
\n\t\tprocess.exit(1)\n\t
}
, 6000);
\n
});
\n\n
server.listen(port, async function () {\n
\t
try {\n
\t\t
eureka = await getEurekaClient(port);
\n\t\t
logger.info('eureka register success');
\n\t
} catch (e)
{
\n\t\tlogger.error(e.name);\n\t
}
\n\t
logger.info('%s listening at %s',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AC,EAAE,CAAC,mBAAmB,EAAE,CAAC,GAAG,KAAK;CACxC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;CAClB,CAAC,CAAC;;AAEH,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM;CAC3B,MAAM,CAAC,IAAI,EAAE,CAAC;CACd,UAAU,CAAC,MAAM;EAChB,OAAO,CAAC,IAAI,CAAC,CAAC,EAAC;EACf,EAAE,IAAI,CAAC,CAAC;CACT,CAAC,CAAC;;AAEH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,kBAAkB;CACrC,IAAI;EACH,MAAM,GAAG,MAAM,eAAe,CAAC,IAAI,CAAC,CAAC;EACrC,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;EACvC,CAAC,OAAO,CAAC,EAAE;EACX,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;EACrB;CACD,MAAM,CAAC,IAAI,CAAC,oBAAoB,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;CAC3D,CAAC,CAAC"
}
\ No newline at end of file
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