itsthatguy / avatars-api-middleware Goto Github PK
View Code? Open in Web Editor NEWThe express middleware for our avatars service
Home Page: http://avatars.adorable.io
License: Other
The express middleware for our avatars service
Home Page: http://avatars.adorable.io
License: Other
@bigtiger Any preference on which one?
It's slow, it's an external dependency, and its API is outdated.
For example, try hitting http://localhost:3002/avatar/v , you get
Error: ENOENT, stat '/Users/itg/git/adorable/adorable-avatars/.generated/img/avatarv.png'
We previously had code in place that made the requests /avatars/foo.png
and /avatars/foo
"the same;" it was accomplished by simply stripping the extension out of the identifier. I removed this code because I thought it was silly, but I realize now that it's really a stopgap for #19.
Avatar-wise, the extension should not affect the result. Long-term, it should affect the content-type of the response.
The main reason to fix this sooner rather than later is that the .png toggle on the avatars site now behaves "weirdly," in that it actually changes the avatar being displayed.
Can I choose a color? how can I do?
Hi! Your api looks awesome! :)
It's possible to get a random avatar?
If not, do you have plans of adding that feature?
Hello,
The .generated
folder, subfolders and assumably all face, eyes and nose images are required by the app, but the directory is included in the .gitignore file. This error causes the app to crash on execution due to directories missing, and no images to generate when making a request due to files missing.
To recreate this error, clone the repo in a new directory and try to run it.
We currently have the default branch set to develop
. However, master
is generally what's on production. I think this is kind of confusing.
How many possibilities are there, for this endpoint?
Once we're actually generating avatars procedurally, we can provide a permalink to an avatar's given attributes. That way, if we add more attributes in the future and the mapping changes, people can still use the same avatar.
idk
Needed to add module.exports = router;
after var router = (0, _express2.default)();
in dist/routes/avatars.js
.
Why do I use adorable-avatars? How do I use adorable-avatars?
There are currently multiple security issues associated with babel-watch. Trying to resolve these, resulted in a long string of manual updates to nested dependencies, which is not maintainable.
I propose that we instead find another utility for this. Perhaps we switch to typescript?
I can't seem to get the middleware working. The response comes back empty:
Server setup:
import express from 'express';
import avatarsMiddleware from 'adorable-avatars';
const app = express();
app.use('/avatars', avatarsMiddleware);
app.listen(3000, () => {
console.log(`Listening on port`, 3000);
});
Node version: v8.12.0
Hi,
I was hoping to make a pull request myself but am having trouble installing the project locally.
Would it be possible to add a size parameter to the end of the Custom Face Parts endpoint? I think the endpoint is particularly useful in its flexibility, other than not being able to append a size. It looks as though it would entail the following changes:
router.get '/face/:eyes/:nose/:mouth/:color/:size', (req, res, next) -> // @/lib/routes/v2.coffee:34
imager.combine faceParts, req.params.size, (err, stdout) -> // @/lib/routes/v2.coffee:50
But without being able to test it myself, it's possible that the task is larger.
Thanks for your work on the project, I like it.
I think this would be best done in a wiki, rather than the README, or the site.
Main points we need to cover (some of which are already done elsewhere):
/avatar
)/avatars
)
/list
)/face
)Hi, I was wondering if there was a way to integrate this in Laravel. ๐
Request came from Twitter https://twitter.com/mgmarshalluk/status/752854367578054657
Getting a delayed browser wait on the avatars, e.g. api.adorable.io/avatars/100/e8โฆ. Can you cache them once generated? :)
I'm trying to use this dependency with the NestJS framework and am running into an issue. Below is an example of how I'm using it and beneath that is the error it's throwing.
import avatarsMiddleware from 'adorable-avatars';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.use('myAvatars', avatarsMiddleware);
await app.listen(process.env.PORT || 8080);
}
bootstrap();
TypeError: Router.use() requires a middleware function but got a undefined
at Function.use (/Users/gianlazzarini/Documents/Development/Lazztech.Hub-Service/node_modules/express/lib/router/index.js:458:13)
at Function.<anonymous> (/Users/gianlazzarini/Documents/Development/Lazztech.Hub-Service/node_modules/express/lib/application.js:22
Any thoughts?
I understand that you are using some form of hashing to always get the same image back based on the input value. However I am confused on how you can select something like img_01.png
based on a hash value. Can you explain to how a hash value can be used to select a value like this? Essentially you pass the hash into a switch statement and it will always return img_01.png
but if the hash changes even slightly you return img_02.png
, how does that work?
I'm trying to use this api from another github projects but I've CORS error:
Failed to load https://api.adorable.io/avatars/list: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://ckgrafico.github.io' is therefore not allowed access.
Hello,
Some URL's are all of a sudden breaking on DappVolume https://dappvolume.com/transactions/eth
For example: https://api.adorable.io/avatars/32/[email protected]
Application error
An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details.
src="'https://api.adorable.io/avatars/32/' + ethAddress + '@adorable.png'"
cc @rylnd
This was the last issue I had in mind to do, I promise!
Right now the endpoint set look like this:
/myAvatars/:id
/myAvatars/:size/:id
/myAvatars/face/:eyes/:nose/:mouth/:color
/myAvatars/face/:eyes/:nose/:mouth/:color/:size
/myAvatars/list
and as a developer I found it a bit confusing and hard coded.
So after some experiment I would propose you to implement the whole thing in a different way that (assuming #74 will land) should follow this schema:
root | scope | optional size | params |
---|---|---|---|
avatars | face | * | :id |
avatars | face | :size | :id |
avatars | face | * | :eyes/:nose/:mouth/:color |
avatars | face | :size | :eyes/:nose/:mouth/:color |
avatars | meta | * | list |
avatars | meta | :size | list |
avatars | meta | * | random |
avatars | meta | :size | random |
I tried this new routing system on my local setup and it feels pretty good, being way more predictable and scalable. Also it doesn't add almost any logic on top of what exists now.
If you are wondering about \avatars\meta\:size\list
I was thinking about letting list
return an object like
{
face: {...},
size: :size
}
This add the ability to programmatically get the default size (or any size), that is another thing I find pretty useful.
Any thoughts?
Move the 'running locally' stuff to a separate file. It'd probably be nice to say "make sure you run the tests," so I'll probably add a few sanity-check tests, too.
I got an error when visiting adorable.io/.
Error code: 1020
Ray ID: 7ef4bcfa485818a0
Country: IN
Data center: mrs01
IP: 2405:204:922e:fa0f:4579:7337:53d9:5d7f
Timestamp: 2023-07-31 09:15:40 UTC
This repository originally held all of the code necessary to deploy and run an express server serving avatars. As the name implies, this repository has since been pared down to contain only the express middleware itself; any server code contained here is only meant as a convenience for development of the middleware.
In summary: there are code relics that are understandably confusing developers (see #87) and need to be removed. Any remaining server code should be clearly identified as dev-only.
Can I specific the border radius in the URL of the api??
Given that this repo is now (mainly) an express middleware(s), it's my belief that avatars-middleware
or avatars-api-middleware
would be more informative than the current repo name.
In order to simplify integration with consuming applications
As a service provider
I want to minimize work need to implement avatars
Acceptance Criteria:
This was requested via email. Adding it to GitHub for visibility.
http://avatars.adorable.io/
no longer exists.
Is the only way to use via self-hosting now?
The ability to add a border via the adorable avatars website is pretty cool.
Could we also do this for generating avatars using URL params?
Something like:
http://api.adorable.io/avatars/b25/285/sometext.png
Could simply apply 50% border to any int passed which is higher than 50, and 0% to anything lower - not sure how you guys want to handle floats
The library can not be installed.
Node version 14.2.0
npm version 6.14.5
OS: macOS Catalina 10.15.3
I think it is because of the sharp dependency which needs to be updated.
If you try to install that version of sharp in the project, it would give the same error. The latest sharp version works, though.
It might be that that version of sharp is not supported on macOS Catalina: cncf/landscapeapp#475.
> (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
info sharp Using cached /Users/username/.npm/_libvips/libvips-8.7.4-darwin-x64.tar.gz
prebuild-install WARN install No prebuilt binaries found (target=14.2.0 runtime=node arch=x64 libc= platform=darwin)
TOUCH Release/obj.target/libvips-cpp.stamp
CXX(target) Release/obj.target/sharp/src/common.o
CXX(target) Release/obj.target/sharp/src/metadata.o
CXX(target) Release/obj.target/sharp/src/stats.o
../src/stats.cc:130:19: error: no matching member function for call to 'Set'
channels->Set(i, channelStat);
~~~~~~~~~~^~~
/Users/username/Library/Caches/node-gyp/14.2.0/include/node/v8.h:3639:37: note: candidate function not viable: requires 3 arguments, but 2 were provided
V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
^
/Users/username/Library/Caches/node-gyp/14.2.0/include/node/v8.h:3642:37: note: candidate function not viable: requires 3 arguments, but 2 were provided
V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context, uint32_t index,
^
1 error generated.
make: *** [Release/obj.target/sharp/src/stats.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:315:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12)
gyp ERR! System Darwin 19.3.0
gyp ERR! command "/usr/local/Cellar/node/14.2.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/username/Documents/Disertatie/project-name-backend/node_modules/sharp
gyp ERR! node -v v14.2.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `(node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/username/.npm/_logs/2020-05-19T11_38_54_024Z-debug.log
username@s-MacBook-Pro- project-name-backend %
This optimization comes from @TylerK: we should be able to reduce our image sizes (and thus bandwidth, etc.) by modifying our imagemagick params (and/or using pngcrush) to limit the images' bit depth and remove the alpha channel.
In general, there's likely a bunch of features of PNG that we're paying for but don't really need.
Related to adorableio/adorable-avatars-site#7, we need to unescape identifiers on the API end.
Hi all,
postinstall.js seems to fail when being run on Node 0.10, 0.12, 4.2.6 (latest LTS) and 5.5.0 (a recent stable).
The error seems to be at postinstall.js:6 runCommand("gulp");
. Commenting out this line allows installation to complete normally.
To reproduce this error, follow the Guidelines for Contributing, you should notice the error occurring at Stage 3 - npm install
, when the postinstall.js script is executed.
This works:
https://api.adorable.io/avatars/face/eyes13/nose10/mouth2/00aeff
This does not work:
https://api.adorable.io/avatars/face/eyes13/nose10/mouth2/00aeff/256
According to the tests in the code repository, the size parameter is expected to work.
Here http://avatars.adorable.io/ in FAQ said:
we also offer access to a slightly more ridiculous API that boasts over 9.6 billion possibilities.
Where to get this api?
Dear all,
I was trying out the library on your website https://api.adorable.io/ and the result of using the embedded tool is different when directly opneing the generated link. For e.g. the result for [email protected] is a pink-ish face, whereas https://api.adorable.io/avatars/285/[email protected] draws a completely different yellow-ish avatar.
Is it a problem on versions?
I'm implementing chat application by flutter. Can I use this in flutter mobile application?
If so, how can I obtain the way to call API?
@itsthatguy suggested we should move all the webserver-y stuff out of app.coffee, and turn that file into more of a manifest and entry point.
What is happening?
If the identifier โ..โ is chosen, the result is actually a 404.
What is expected?
An image as usual.
URL: https://api.adorable.io/avatars/285/..
However, it works with the suffix .png (https://api.adorable.io/avatars/285/...png)
I really like your adorable avatars and would be happy to create a version for DiceBear Avatars for it.
DiceBear Avatars works similarly. SVG avatars are created using an identifier. Sprite collections are used, which exist in addition to the library.
I would like to create such a sprite collection for Adorable Avatars, if that's okay with you. For this I would have to redraw the sprites as a vector if you don't have any vectors.
The new repository can also be located in your GitHub organization.
In order to send an example of an avatar to another person
As a user of the Avatars site
I want to be able to set some params and send that to my friends
When I visit http://avatars.adorable.io/#demo?name=Jessie
Then the site scrolls to the demo section
And I see "Jessie" in the identifer
And the avatar for "Jessie" is displayed
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.