Code Monkey home page Code Monkey logo

avatars-api-middleware's People

Contributors

aiobot avatar bigtiger avatar camwiegert avatar dependabot[bot] avatar itsthatguy avatar jackymancs4 avatar joeao avatar m5rk avatar rptoma avatar rylnd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

avatars-api-middleware's Issues

extensions affect the returned avatar

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.

Empty response from server

I can't seem to get the middleware working. The response comes back empty:
localhost_3000_avatars_abc
localhost_3000_avatars_abc_and_server_js_ _test-avatar

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

NestJS: requires a middleware function but got a undefined

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?

SSL Support

This was requested via email. Adding it to GitHub for visibility.

module.exports missing

idk

Needed to add module.exports = router; after var router = (0, _express2.default)(); in dist/routes/avatars.js.

Avatar Permalinks

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.

Documentate

Why do I use adorable-avatars? How do I use adorable-avatars?

add the ability to use Adorable Avatars API as a middleware

In order to simplify integration with consuming applications
As a service provider
I want to minimize work need to implement avatars

Acceptance Criteria:

  • Users can include middleware and enable avatars
  • Analytics and Monitoring keys are removed from the distributed repository
  • User has the ability to run the full API if they desire

Unescape identifiers

Related to adorableio/adorable-avatars-site#7, we need to unescape identifiers on the API end.

postinstall.js Fails

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.

Make the repository name more descriptive.

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.

GET random avatar

Hi! Your api looks awesome! :)

It's possible to get a random avatar?

If not, do you have plans of adding that feature?

Consolidate API Documentation

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):

  • v1 API (/avatar)
  • v2 API (/avatars)
    • list API (/list)
    • manual API (/face)

Let's work together

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.

Replace babel-watch due to slow security fixes

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?

Reduce image size by limiting bit depth, etc.

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.

I got an error when visiting adorable.io/.

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

Can I use in mobile application?

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?

Contribution Instructions

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.

Discussion: a better routing schema

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?

Question about predictable random generator

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?

Generated image files missing

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.

Library can't be installed

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 % 

Add size parameter to Custom Face Parts endpoint

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.

Remove outdated/confusing server code

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.