youzanyun-devtool-worker
Version:
- web - ws - proxy
45 lines (44 loc) • 1.53 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const axios_1 = tslib_1.__importDefault(require("axios"));
const spring4js_nodejs_1 = require("spring4js-nodejs");
let ActionUploadTokenService = class ActionUploadTokenService {
async processRequest(ctx, next) {
if (ctx.path === '/shop/pubImgUploadToken.json') {
let { appName } = ctx.query;
let res = await axios_1.default({
method: "GET",
url: "http://127.0.0.1:31240/api/common/upload/image/token",
params: {
appName,
}
});
ctx.set({
"Access-Control-Allow-Credentials": "true",
"Access-Control-Allow-Origin": "https://www.youzan.com",
"Access-Control-Max-Age": "86400"
});
if (res.data.code != 0 && res.data.code != 200) {
ctx.body = {
code: res.data.code,
data: {},
msg: '获取token失败'
};
return true;
}
ctx.body = {
code: 0,
data: {
uptoken: res.data.data
}
};
return true;
}
return false;
}
};
ActionUploadTokenService = tslib_1.__decorate([
spring4js_nodejs_1.Service()
], ActionUploadTokenService);
exports.default = ActionUploadTokenService;