Commit 29483f95 authored by rockyl's avatar rockyl

回复imagemin模块

parent 55c2ab53
......@@ -7,6 +7,9 @@ var Eurekaclient = _interopDefault(require('eureka-client-ts'));
var log4js = require('log4js');
var path = _interopDefault(require('path'));
var fs = _interopDefault(require('fs-extra'));
var imagemin = _interopDefault(require('imagemin'));
var imageminJpegtran = _interopDefault(require('imagemin-jpegtran'));
var imageminPngquant = _interopDefault(require('imagemin-pngquant'));
/**
* Created by rockyl on 2020-02-13.
......@@ -54,6 +57,8 @@ async function getEurekaClient(port) {
* Created by rockyl on 2020-02-13.
*/
const acceptTypes = ['image/png', 'image/jpeg'];
function applyApi(server){
server.get('/info', function (req, res, next) {
res.sendRaw('Tiny image serve is running.');
......@@ -66,7 +71,7 @@ function applyApi(server){
});
server.post('/tinify', async function (req, res, next) {
/*let file = req.files.file;
let file = req.files.file;
if(file){
if(acceptTypes.includes(file.type)){
......@@ -102,7 +107,7 @@ function applyApi(server){
code: 1,
msg: 'file not exists'
});
}*/
}
return next();
});
......
This diff is collapsed.
This diff is collapsed.
......@@ -6,6 +6,9 @@
"dependencies": {
"eureka-client-ts": "^0.2.10",
"fs-extra": "^8.1.0",
"imagemin": "^7.0.1",
"imagemin-jpegtran": "^6.0.0",
"imagemin-pngquant": "^8.0.0",
"log4js": "^6.1.2",
"restify": "^8.5.1"
},
......
......@@ -3,9 +3,9 @@
*/
import logger from "./logger";
/*import imagemin from "imagemin";
import imagemin from "imagemin";
import imageminJpegtran from "imagemin-jpegtran";
import imageminPngquant from "imagemin-pngquant";*/
import imageminPngquant from "imagemin-pngquant";
const acceptTypes = ['image/png', 'image/jpeg'];
......@@ -21,7 +21,7 @@ export default function applyApi(server){
});
server.post('/tinify', async function (req, res, next) {
/*let file = req.files.file;
let file = req.files.file;
if(file){
if(acceptTypes.includes(file.type)){
......@@ -57,7 +57,7 @@ export default function applyApi(server){
code: 1,
msg: 'file not exists'
});
}*/
}
return next();
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment