Skip to content

Commit 7fc99c1

Browse files
committed
So long, potato
FaceFactory is marginally more informative, if not less fun.
1 parent e6333c5 commit 7fc99c1

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/lib/potato.ts renamed to src/lib/FaceFactory.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Hash, hashFactory, sumAndDiff } from 'avatars-utils';
22
import { eyeImages, noseImages, mouthImages } from './imageFiles';
33

4-
export class Potato {
4+
export class FaceFactory {
55
private colorHash: Hash<string>;
66
private eyeHash: Hash<string>;
77
private noseHash: Hash<string>;
@@ -19,7 +19,7 @@ export class Potato {
1919
this.mouthHash = new Hash(mouths, hashFactory(sumAndDiff));
2020
}
2121

22-
public parts(string): Face {
22+
public create(string): Face {
2323
return {
2424
color: this.colorHash.get(string),
2525
eyes: this.eyeHash.get(string),
@@ -41,4 +41,9 @@ const defaultColors = [
4141
'#f6be5d',
4242
];
4343

44-
export default new Potato(defaultColors, eyeImages, noseImages, mouthImages);
44+
export default new FaceFactory(
45+
defaultColors,
46+
eyeImages,
47+
noseImages,
48+
mouthImages,
49+
);

src/routes/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import uuid from 'uuid';
33

44
import { imageFileNames, imageFilePaths } from '../lib/imageFiles';
55
import { combine } from '../lib/imager';
6-
import potato from '../lib/potato';
6+
import FaceFactory from '../lib/FaceFactory';
77

88
const imageTypes: ImageType[] = ['eyes', 'nose', 'mouth'];
99

@@ -23,17 +23,17 @@ router.get('/list', (req, res) => {
2323
});
2424

2525
router.get('/:size?/random', (req, res) => {
26-
const faceParts = potato.parts(uuid.v4());
26+
const face = FaceFactory.create(uuid.v4());
2727

28-
return combine(faceParts, req.params.size, (err, stdout) =>
28+
return combine(face, req.params.size, (err, stdout) =>
2929
sendImage({ stdout, response: res }),
3030
);
3131
});
3232

3333
router.get('/:size?/:id', (req, res, next) => {
34-
const faceParts = potato.parts(req.params.id);
34+
const face = FaceFactory.create(req.params.id);
3535

36-
return combine(faceParts, req.params.size, (err, stdout) =>
36+
return combine(face, req.params.size, (err, stdout) =>
3737
sendImage({ stdout, response: res }),
3838
);
3939
});

0 commit comments

Comments
 (0)