Commit ef6811c1 authored by rockyl's avatar rockyl

修改5

parent 6a13f1d9
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const logger_1 = require("./logger"); const logger_1 = require("./logger");
const compress_1 = require("./compress"); const compress_1 = require("./compress");
//import {uploadFile} from 'ali-oss-duiba' const ali_oss_duiba_1 = require("ali-oss-duiba");
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) {
...@@ -27,11 +27,11 @@ async function tinify(req, res, next) { ...@@ -27,11 +27,11 @@ async function tinify(req, res, next) {
try { try {
const buffer = await (0, compress_1.compressImage)(file.path, type); const buffer = await (0, compress_1.compressImage)(file.path, type);
if (cdnPath) { if (cdnPath) {
/*const name = await uploadFile(buffer, cdnPath) const name = await (0, ali_oss_duiba_1.uploadFile)(buffer, cdnPath);
res.send({ res.send({
code: 0, code: 0,
data: name data: name
})*/ });
} }
else { else {
res.sendRaw(buffer, { res.sendRaw(buffer, {
......
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAEH,qCAA6B;AAC7B,yCAAwC;AACxC,0CAA0C;AAE1C,MAAM,WAAW,GAAG,CAAC,WAAW,EAAE,YAAY,CAAC,CAAA;AAE/C,SAAwB,QAAQ,CAAC,MAAM;IACtC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,UAAU,GAAG,EAAE,GAAG,EAAE,IAAI;QAC3C,GAAG,CAAC,OAAO,CAAC,8BAA8B,CAAC,CAAA;QAC3C,OAAO,IAAI,EAAE,CAAA;IACd,CAAC,CAAC,CAAA;IAEF,MAAM,CAAC,GAAG,CAAC,gBAAgB,EAAE,UAAU,GAAG,EAAE,GAAG,EAAE,IAAI;QACpD,GAAG,CAAC,OAAO,CAAC,IAAI,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AI,EAAE,CAAC;wBACP,IAAI,EAAE,IAAI;qBACV,CAAC,CAAA;iBACF;qBAAM;oBACN,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE;wBACnB,cAAc,EAAE,IAAI,CAAC,IAAI;qBACzB,CAAC,CAAA;iBACF;aACD;YAAC,OAAO,CAAC,EAAE;gBACX,gBAAM,CAAC,KAAK,CAAC,SAAS,EAAE,iBAAiB,EAAE,CAAC,CAAC,OAAO,CAAC,CAAA;gBACrD,GAAG,CAAC,IAAI,CAAC;oBACR,IAAI,EAAE,CAAC;oBACP,GAAG,EAAE,iBAAiB;iBACtB,CAAC,CAAA;aACF;SACD;aAAM;YACN,gBAAM,CAAC,KAAK,CAAC,SAAS,EAAE,YAAY,CAAC,CAAA;YACrC,GAAG,CAAC,IAAI,CAAC;gBACR,IAAI,EAAE,CAAC;gBACP,GAAG,EAAE,YAAY;aACjB,CAAC,CAAA;SACF;KACD;SAAM;QACN,GAAG,CAAC,IAAI,CAAC;YACR,IAAI,EAAE,CAAC;YACP,GAAG,EAAE,iBAAiB;SACtB,CAAC,CAAA;KACF;IACD,OAAO,IAAI,EAAE,CAAA;AACd,CAAC"}
\ No newline at end of file \ No newline at end of file
...@@ -9,7 +9,7 @@ const eureka_1 = require("./eureka"); ...@@ -9,7 +9,7 @@ const eureka_1 = require("./eureka");
const logger_1 = require("./logger"); const logger_1 = require("./logger");
const config = require("config"); const config = require("config");
const api_1 = require("./api"); const api_1 = require("./api");
//import {setup as setupOSS} from 'ali-oss-duiba' const ali_oss_duiba_1 = require("ali-oss-duiba");
let eureka; let eureka;
const server = restify.createServer({ const server = restify.createServer({
name: 'tiny-image', name: 'tiny-image',
...@@ -39,12 +39,12 @@ async function start() { ...@@ -39,12 +39,12 @@ async function start() {
await (0, remote_configs_1.prepare)(); await (0, remote_configs_1.prepare)();
const ossConfigs = (0, remote_configs_1.getConfigs)({ name: `apollo.oss.duiba.accessId`, alias: 'accessId' }, { name: `apollo.oss.duiba.accessKey`, alias: 'accessKey' }); const ossConfigs = (0, remote_configs_1.getConfigs)({ name: `apollo.oss.duiba.accessId`, alias: 'accessId' }, { name: `apollo.oss.duiba.accessKey`, alias: 'accessKey' });
logger_1.default.info('got oss configs:', ossConfigs); logger_1.default.info('got oss configs:', ossConfigs);
/*setupOSS({ (0, ali_oss_duiba_1.setup)({
accessKeyId: ossConfigs.accessId, accessKeyId: ossConfigs.accessId,
accessKeySecret: ossConfigs.accessKey, accessKeySecret: ossConfigs.accessKey,
bucket: 'duiba', bucket: 'duiba',
region: 'oss-cn-hangzhou', region: 'oss-cn-hangzhou',
})*/ });
const port = config.get('PORT'); const port = config.get('PORT');
server.listen(port, async function () { server.listen(port, async function () {
if (process.env.NODE_ENV) { if (process.env.NODE_ENV) {
......
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA;;GAEG;AACH,qDAA6E;AAE7E,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;AAClC,qCAAwC;AACxC,qCAA6B;AAC7B,iCAAgC;AAChC,+BAA4B;AAC5B,iDAAiD;AAEjD,IAAI,MAAM,CAAA;AAEV,MAAM,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IACnC,IAAI,EAAE,YAAY;IAClB,OAAO,EAAE,OAAO;CAChB,CAAC,CAAA;AAEF,MAAM,eAAe,GAAG,CAAC,gBAAgB,CAAC,CAAA;AAE1C,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAA;AAC3D,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAA;AACzC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAA;AACxC,MAAM,CAAC,GAAG,CAAC,UAAU,GAAG,EAAE,GAAG,EAAE,IAAI;IAClC,IAAI,CAAC,eAAe,CAA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;aACtC;YAAC,OAAO,CAAC,EAAE;gBACX,gBAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;aACpB;SACD;QACD,gBAAM,CAAC,IAAI,CAAC,oBAAoB,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,CAAA;IAC3D,CAAC,CAAC,CAAA;AACH,CAAC;AAED,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;IACjB,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;IACd,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AAChB,CAAC,CAAC,CAAA"}
\ No newline at end of file \ No newline at end of file
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
"main": "dist/index.js", "main": "dist/index.js",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"ali-oss-duiba": "^1.0.12",
"config": "^3.3.6", "config": "^3.3.6",
"eureka-client-ts": "^0.2.10", "eureka-client-ts": "^0.2.10",
"fs-extra": "^8.1.0", "fs-extra": "^8.1.0",
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
import logger from "./logger" import logger from "./logger"
import {compressImage} from "./compress" import {compressImage} from "./compress"
//import {uploadFile} from 'ali-oss-duiba' import {uploadFile} from 'ali-oss-duiba'
const acceptTypes = ['image/png', 'image/jpeg'] const acceptTypes = ['image/png', 'image/jpeg']
...@@ -31,11 +31,11 @@ async function tinify(req, res, next) { ...@@ -31,11 +31,11 @@ async function tinify(req, res, next) {
try { try {
const buffer = await compressImage(file.path, type) const buffer = await compressImage(file.path, type)
if (cdnPath) { if (cdnPath) {
/*const name = await uploadFile(buffer, cdnPath) const name = await uploadFile(buffer, cdnPath)
res.send({ res.send({
code: 0, code: 0,
data: name data: name
})*/ })
} else { } else {
res.sendRaw(buffer, { res.sendRaw(buffer, {
'Content-Type': file.type, 'Content-Type': file.type,
......
...@@ -8,7 +8,7 @@ import {getEurekaClient} from "./eureka" ...@@ -8,7 +8,7 @@ import {getEurekaClient} from "./eureka"
import logger from "./logger" import logger from "./logger"
import * as config from "config" import * as config from "config"
import applyApi from "./api" import applyApi from "./api"
//import {setup as setupOSS} from 'ali-oss-duiba' import {setup as setupOSS} from 'ali-oss-duiba'
let eureka let eureka
...@@ -51,12 +51,12 @@ async function start() { ...@@ -51,12 +51,12 @@ async function start() {
) )
logger.info('got oss configs:', ossConfigs) logger.info('got oss configs:', ossConfigs)
/*setupOSS({ setupOSS({
accessKeyId: ossConfigs.accessId, accessKeyId: ossConfigs.accessId,
accessKeySecret: ossConfigs.accessKey, accessKeySecret: ossConfigs.accessKey,
bucket: 'duiba', bucket: 'duiba',
region: 'oss-cn-hangzhou', region: 'oss-cn-hangzhou',
})*/ })
const port = config.get('PORT') const port = config.get('PORT')
server.listen(port, async function () { server.listen(port, async function () {
......
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