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
509d6851
Commit
509d6851
authored
Nov 05, 2020
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
0ca4f5c8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
1 deletion
+5
-1
api.js
dist/api.js
+2
-0
api.js.map
dist/api.js.map
+1
-1
api.ts
src/api.ts
+2
-0
No files found.
dist/api.js
View file @
509d6851
...
@@ -7,6 +7,7 @@ const logger_1 = require("./logger");
...
@@ -7,6 +7,7 @@ const logger_1 = require("./logger");
const
imagemin
=
require
(
"imagemin"
);
const
imagemin
=
require
(
"imagemin"
);
const
imageminJpegtran
=
require
(
"imagemin-jpegtran"
);
const
imageminJpegtran
=
require
(
"imagemin-jpegtran"
);
const
imageminPngquant
=
require
(
"imagemin-pngquant"
);
const
imageminPngquant
=
require
(
"imagemin-pngquant"
);
const
fs
=
require
(
'fs-extra'
);
const
acceptTypes
=
[
'image/png'
,
'image/jpeg'
];
const
acceptTypes
=
[
'image/png'
,
'image/jpeg'
];
function
applyApi
(
server
)
{
function
applyApi
(
server
)
{
server
.
get
(
'/info'
,
function
(
req
,
res
,
next
)
{
server
.
get
(
'/info'
,
function
(
req
,
res
,
next
)
{
...
@@ -23,6 +24,7 @@ function applyApi(server) {
...
@@ -23,6 +24,7 @@ function applyApi(server) {
if
(
acceptTypes
.
includes
(
file
.
type
))
{
if
(
acceptTypes
.
includes
(
file
.
type
))
{
try
{
try
{
console
.
log
(
`start compress!`
);
console
.
log
(
`start compress!`
);
console
.
log
(
'file exists:'
,
fs
.
existsSync
(
file
.
path
));
const
buffer
=
await
imagemin
([
file
.
path
],
{
const
buffer
=
await
imagemin
([
file
.
path
],
{
plugins
:
[
plugins
:
[
imageminJpegtran
(),
imageminJpegtran
(),
...
...
dist/api.js.map
View file @
509d6851
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAEH,qCAA8B;AAC9B,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACrC,MAAM,gBAAgB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AACtD,MAAM,gBAAgB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAEtD,MAAM,WAAW,GAAG,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;AAEhD,SAAwB,QAAQ,CAAC,MAAM;IACtC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,UAAU,GAAG,EAAE,GAAG,EAAE,IAAI;QAC3C,GAAG,CAAC,OAAO,CAAC,8BAA8B,CAAC,CAAC;QAC5C,OAAO,IAAI,EAAE,CAAC;IACf,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,GAAG,CAAC,gBAAgB,EAAE,UAAU,GAAG,EAAE,GAAG,EAAE,IAAI;QACpD,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAClB,OAAO,IAAI,EAAE,CAAC;IACf,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,WAAY,GAAG,EAAE,GAAG,EAAE,IAAI;QACrD,IAAI,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC;QAE1B,IAAG,IAAI,EAAC;YACP,IAAG,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAC;g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EAAE,CAAC,GAAG,EAAE,GAAG,CAAC;6BACnB,CAAC;yBACF;qBACD,CAAC,CAAC;oBAEH,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;oBACjC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;wBAC3B,cAAc,EAAE,IAAI,CAAC,IAAI;qBACzB,CAAC,CAAC;oBACH,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;iBACjC;gBAAA,OAAO,CAAC,EAAE;oBACV,gBAAM,CAAC,KAAK,CAAC,SAAS,EAAE,iBAAiB,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;oBACtD,GAAG,CAAC,IAAI,CAAC;wBACR,IAAI,EAAE,CAAC;wBACP,GAAG,EAAE,iBAAiB;qBACtB,CAAC,CAAC;iBACH;aACD;iBAAI;gBACJ,gBAAM,CAAC,KAAK,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;gBACtC,GAAG,CAAC,IAAI,CAAC;oBACR,IAAI,EAAE,CAAC;oBACP,GAAG,EAAE,YAAY;iBACjB,CAAC,CAAC;aACH;SACD;aAAI;YACJ,GAAG,CAAC,IAAI,CAAC;gBACR,IAAI,EAAE,CAAC;gBACP,GAAG,EAAE,iBAAiB;aACtB,CAAC,CAAC;SACH;QAED,OAAO,IAAI,EAAE,CAAC;IACf,CAAC,CAAC,CAAC;AACJ,CAAC;AAxDD,2BAwDC"}
\ No newline at end of file
\ No newline at end of file
src/api.ts
View file @
509d6851
...
@@ -6,6 +6,7 @@ import logger from "./logger";
...
@@ -6,6 +6,7 @@ import logger from "./logger";
const
imagemin
=
require
(
"imagemin"
);
const
imagemin
=
require
(
"imagemin"
);
const
imageminJpegtran
=
require
(
"imagemin-jpegtran"
);
const
imageminJpegtran
=
require
(
"imagemin-jpegtran"
);
const
imageminPngquant
=
require
(
"imagemin-pngquant"
);
const
imageminPngquant
=
require
(
"imagemin-pngquant"
);
const
fs
=
require
(
'fs-extra'
);
const
acceptTypes
=
[
'image/png'
,
'image/jpeg'
];
const
acceptTypes
=
[
'image/png'
,
'image/jpeg'
];
...
@@ -27,6 +28,7 @@ export default function applyApi(server){
...
@@ -27,6 +28,7 @@ export default function applyApi(server){
if
(
acceptTypes
.
includes
(
file
.
type
)){
if
(
acceptTypes
.
includes
(
file
.
type
)){
try
{
try
{
console
.
log
(
`start compress!`
);
console
.
log
(
`start compress!`
);
console
.
log
(
'file exists:'
,
fs
.
existsSync
(
file
.
path
));
const
buffer
=
await
imagemin
([
file
.
path
],
{
const
buffer
=
await
imagemin
([
file
.
path
],
{
plugins
:
[
plugins
:
[
imageminJpegtran
(),
imageminJpegtran
(),
...
...
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