Skip to content

Commit dcf18c8

Browse files
committed
Add release branch
1 parent 789847a commit dcf18c8

File tree

3 files changed

+25
-23
lines changed

3 files changed

+25
-23
lines changed

server.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const cacheFile = (directory, name) => {
2525
const filePath = path.resolve(__dirname, directory + name);
2626
const method = name.split('.')[0];
2727
try {
28-
const func = require(filePath);
28+
const func = require(filePath);
2929
api.set(method, func);
3030
methods = Array.from(api.keys());
3131
} catch (e) {
@@ -37,21 +37,21 @@ function cacheFolder(directory) {
3737
const cacheFilePath = cacheFile.bind(null, directory);
3838
fs.readdir(directory, (err, files) => {
3939
files.forEach(cacheFilePath);
40-
})
40+
});
4141
}
4242

43-
async function getArgs(req) {
43+
async function getArgs(req) {
4444
return new Promise((resolve, reject) => {
4545
const chuncks = [];
46-
req.on('data', chunck => {
46+
req.on('data', (chunck) => {
4747
chuncks.push(chunck);
48-
})
48+
});
4949
req.on('end', () => {
5050
const args = JSON.parse(chuncks.join(''));
5151
resolve(args);
52-
})
53-
})
54-
}
52+
});
53+
});
54+
}
5555

5656
cacheFolder(transformFilesPath);
5757

@@ -92,8 +92,8 @@ const server = http.createServer(async (req, res) => {
9292
}
9393
res.writeHead(200, { 'Content-Type': mimeType });
9494
res.end(data);
95-
})
96-
} catch(e) {
95+
});
96+
} catch (e) {
9797
res.statusCode = 500;
9898
res.end('Unknown method');
9999
return;

static/client.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@ const currentUrl = window.location.pathname;
22
const url = `/api${currentUrl}`;
33
generateBtn.addEventListener('click', (e) => {
44
const body = {
5-
data: Array.from(imageData.data)
6-
}
5+
data: Array.from(imageData.data),
6+
};
77
fetch(url, {
88
method: 'POST',
99
headers: { 'Content-Type': 'application/json' },
1010
body: JSON.stringify(body),
11-
}).then(response => {
12-
return response.json()
13-
}).then(data => {
14-
const concatedData = [].concat(...data);
15-
imageDataToImg(concatedData);
16-
});
17-
})
11+
})
12+
.then((response) => {
13+
return response.json();
14+
})
15+
.then((data) => {
16+
const concatedData = [].concat(...data);
17+
imageDataToImg(concatedData);
18+
});
19+
});

static/fileHandler.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ const reader = new FileReader();
2525
reader.onload = function (e) {
2626
const dataURL = e.target.result;
2727
defaultImgElement.src = dataURL;
28-
}
28+
};
2929

30-
fileElement.addEventListener('change', e => {
30+
fileElement.addEventListener('change', (e) => {
3131
const file = fileElement.files[0];
3232
reader.readAsDataURL(file);
33-
})
33+
});
3434

3535
function imageDataToImg(data) {
3636
const canvas = document.createElement('canvas');
@@ -40,4 +40,4 @@ function imageDataToImg(data) {
4040
const imageData = new ImageData(new Uint8ClampedArray(data), w, h);
4141
ctx.putImageData(imageData, 0, 0);
4242
defaultImgElement.src = canvas.toDataURL();
43-
}
43+
}

0 commit comments

Comments
 (0)