Commit 829cc065 authored by rockyl's avatar rockyl

init2

parent 240063b6
...@@ -90,12 +90,12 @@ async function prepareInputs(req) { ...@@ -90,12 +90,12 @@ async function prepareInputs(req) {
if (!acceptTypes.includes(file.type)) { if (!acceptTypes.includes(file.type)) {
continue; continue;
} }
let extname, buffer; let extname, buffer, type;
if (file.type === TYPE_DATA_URL) { if (file.type === TYPE_DATA_URL) {
const dataUrl = await fs.readFile(file.path, 'utf-8'); const dataUrl = await fs.readFile(file.path, 'utf-8');
const result = dataUrl.match(/data:(image\/\w+);/); const result = dataUrl.match(/data:(image\/\w+);/);
if (result) { if (result) {
const type = result[1]; type = result[1];
if (!acceptTypes.includes(type)) { if (!acceptTypes.includes(type)) {
continue; continue;
} }
...@@ -105,10 +105,12 @@ async function prepareInputs(req) { ...@@ -105,10 +105,12 @@ async function prepareInputs(req) {
} }
} }
else { else {
type = file.type;
extname = path.extname(file.name); extname = path.extname(file.name);
buffer = await fs.readFile(file.path); buffer = await fs.readFile(file.path);
} }
const input = { const input = {
type,
key, key,
extname, extname,
buffer, buffer,
......
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAEH,qCAA6B;AAC7B,yCAAwC;AACxC,iDAAwC;AACxC,0CAAyC;AACzC,6BAA4B;AAC5B,+BAA8B;AAE9B,MAAM,aAAa,GAAG,cAAc,CAAA;AACpC,MAAM,WAAW,GAAG,CAAC,WAAW,EAAE,YAAY,EAAE,aAAa,CAAC,CAAA;AAE9D,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;Q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GAAG,IAAI,CAAC,IAAI,CAAA;YAChB,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YACjC,MAAM,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;SACrC;QAED,MAAM,KAAK,GAAQ;YAClB,IAAI;YACJ,GAAG;YACH,OAAO;YACP,MAAM;SACN,CAAA;QACD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;KAClB;IACD,OAAO,MAAM,CAAA;AACd,CAAC;AAED,KAAK,UAAU,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO;IAC5C,IAAI;QACH,MAAM,MAAM,GAAG,MAAM,IAAA,wBAAa,EAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QACrD,IAAI,OAAO,EAAE;YACZ,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAA;YACrE,OAAO,IAAA,0BAAU,EAAC,MAAM,EAAE,OAAO,CAAC,CAAA;SAClC;aAAM;YACN,OAAO,MAAM,CAAA;SACb;KACD;IAAC,OAAO,CAAC,EAAE;QACX,OAAO,CAAC,CAAA;KACR;AACF,CAAC"}
\ No newline at end of file \ No newline at end of file
...@@ -17,15 +17,14 @@ async function prepare() { ...@@ -17,15 +17,14 @@ async function prepare() {
}, {}); }, {});
} }
exports.prepare = prepare; exports.prepare = prepare;
function getConfigs(name, ...args) { function getConfigs(...args) {
let configs = {}; let configs = {};
args.unshift(name); for (let arg of args) {
for (let key of args) { let name = arg;
let name = key; let mapKey = arg;
let mapKey = key; if (typeof arg === 'object') {
if (typeof key === 'object') { name = arg.alias;
name = key.alias; mapKey = arg.name;
mapKey = key.name;
} }
configs[name] = exports.remoteConfigs[mapKey]; configs[name] = exports.remoteConfigs[mapKey];
} }
......
{"version":3,"file":"remote-configs.js","sourceRoot":"","sources":["../src/remote-configs.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,2CAA8B;AAC9B,iCAAgC;AAErB,QAAA,aAAa,GAAG,EAAE,CAAA;AAEtB,KAAK,UAAU,OAAO;IAC5B,MAAM,eAAe,GAAU,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAA;IAC9D,MAAM,IAAI,GAAG,MAAM,IAAA,oBAAK,EAAC,eAAe,CAAC,CAAA;IACzC,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAA;IACvC,8CAA8C;IAE9C,qBAAa,GAAG,aAAa,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;QACnE,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;IACxC,CAAC,EAAE,EAAE,CAAC,CAAA;AACP,CAAC;AATD,0BASC;AAED,SAAgB,UAAU,CAAC,IAAI,EAAE,GAAG,IAAI;IACvC,IAAI,OAAO,GAAG,EAAE,CAAA;IAChB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAClB,KAAK,IAAI,GAAG,IAAI,IAAI,EAAE;QACrB,IAAI,IAAI,GAAG,GAAG,CAAA;QACd,IAAI,MAAM,GAAG,GAAG,CAAA;QAChB,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;YAC5B,IAAI,GAAG,GAAG,CAAC,KAAK,CAAA;YAChB,MAAM,GAAG,GAAG,CAAC,IAAI,CAAA;SACjB;QACD,OAAO,CAAC,IAAI,CAAC,GAAG,qBAAa,CAAC,MAAM,CAAC,CAAA;KACrC;IACD,OAAO,OAAO,CAAA;AACf,CAAC;AAbD,gCAaC"} {"version":3,"file":"remote-configs.js","sourceRoot":"","sources":["../src/remote-configs.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,2CAA8B;AAC9B,iCAAgC;AAErB,QAAA,aAAa,GAAG,EAAE,CAAA;AAEtB,KAAK,UAAU,OAAO;IAC5B,MAAM,eAAe,GAAU,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAA;IAC9D,MAAM,IAAI,GAAG,MAAM,IAAA,oBAAK,EAAC,eAAe,CAAC,CAAA;IACzC,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAA;IACvC,8CAA8C;IAE9C,qBAAa,GAAG,aAAa,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;QACnE,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;IACxC,CAAC,EAAE,EAAE,CAAC,CAAA;AACP,CAAC;AATD,0BASC;AAED,SAAgB,UAAU,CAAC,GAAG,IAAI;IACjC,IAAI,OAAO,GAAG,EAAE,CAAA;IAChB,KAAK,IAAI,GAAG,IAAI,IAAI,EAAE;QACrB,IAAI,IAAI,GAAG,GAAG,CAAA;QACd,IAAI,MAAM,GAAG,GAAG,CAAA;QAChB,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;YAC5B,IAAI,GAAG,GAAG,CAAC,KAAK,CAAA;YAChB,MAAM,GAAG,GAAG,CAAC,IAAI,CAAA;SACjB;QACD,OAAO,CAAC,IAAI,CAAC,GAAG,qBAAa,CAAC,MAAM,CAAC,CAAA;KACrC;IACD,OAAO,OAAO,CAAA;AACf,CAAC;AAZD,gCAYC"}
\ No newline at end of file \ No newline at end of file
...@@ -92,25 +92,27 @@ async function prepareInputs(req) { ...@@ -92,25 +92,27 @@ async function prepareInputs(req) {
continue continue
} }
let extname, buffer let extname, buffer, type
if (file.type === TYPE_DATA_URL) { if (file.type === TYPE_DATA_URL) {
const dataUrl = await fs.readFile(file.path, 'utf-8') const dataUrl = await fs.readFile(file.path, 'utf-8')
const result = dataUrl.match(/data:(image\/\w+);/) const result = dataUrl.match(/data:(image\/\w+);/)
if (result) { if (result) {
const type = result[1] type = result[1]
if (!acceptTypes.includes(type)) { if (!acceptTypes.includes(type)) {
continue continue
} }
extname = '.' + type.substr(type.indexOf('/')+1) extname = '.' + type.substr(type.indexOf('/') + 1)
let base64Data = dataUrl.replace(/^data:image\/\w+;base64,/, "") let base64Data = dataUrl.replace(/^data:image\/\w+;base64,/, "")
buffer = new Buffer(base64Data, 'base64') buffer = new Buffer(base64Data, 'base64')
} }
} else { } else {
type = file.type
extname = path.extname(file.name) extname = path.extname(file.name)
buffer = await fs.readFile(file.path) buffer = await fs.readFile(file.path)
} }
const input: any = { const input: any = {
type,
key, key,
extname, extname,
buffer, buffer,
......
...@@ -18,15 +18,14 @@ export async function prepare() { ...@@ -18,15 +18,14 @@ export async function prepare() {
}, {}) }, {})
} }
export function getConfigs(name, ...args):any { export function getConfigs(...args):any {
let configs = {} let configs = {}
args.unshift(name) for (let arg of args) {
for (let key of args) { let name = arg
let name = key let mapKey = arg
let mapKey = key if (typeof arg === 'object') {
if (typeof key === 'object') { name = arg.alias
name = key.alias mapKey = arg.name
mapKey = key.name
} }
configs[name] = remoteConfigs[mapKey] configs[name] = remoteConfigs[mapKey]
} }
......
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