Giter Club home page Giter Club logo

avatars-api-middleware's Introduction

adorable-avatars

Build Status

What is it?

This repository contains the express middleware that can be used to host your own avatars service!

Check out our website for more info on (and an interactive demo of) what this service does.

How do I use it?

First, you'll need to install the lone external dependency. Instructions for installing ImageMagick on a wide variety of systems are available at https://github.com/ImageMagick/ImageMagick.

Mac OS X users can install with homebrew:

brew install imagemagick

Next, you'll need the adorable-avatars package:

npm install adorable-avatars --save

Then, use the router middleware within your application:

// your_server.js
import express from 'express';
import avatarsMiddleware from 'adorable-avatars';

const myApp = express();
myApp.use('/myAvatars', avatarsMiddleware);

That's it! Your server now includes the avatars endpoints!

Endpoints

Assuming your server lives at myserver.com, and you've configured the middleware as above, you now have the following endpoints:

  • myserver.com/myAvatars/:id
    • returns an avatar for the provided id.
    • id can be anything (email, username, md5 hash, as long as it's a valid URI)
    • defaults to 400px
  • myserver.com/myAvatars/:size/:id
    • returns an avatar for the provided id at the specified size
    • size cannot exceed 400px
  • myserver.com/myAvatars/face/:eyes/:nose/:mouth/:color/:size?
    • Allows you to generate a custom avatar from the specified parts and color, and size
    • e.g. myserver.com/myAvatars/face/eyes1/nose2/mouth4/DEADBF/300
  • myserver.com/myAvatars/list
    • returns JSON of all valid parts for the custom endpoint above
    • myserver.com/myAvatars/:size?/random
      • returns a random avatar, different each time
      • e.g. myserver.com/myAvatars/300/random

Development

If you're developing locally, you'll first need to bootstrap (assumes nvm):

# use correct node version
nvm use

# install dependencies
npm install

Then, there are several npm scripts that will be useful:

# run the unit tests
npm test

# run a dev server
npm start

# run both a dev server and eslint
npm run dev

# compile the application
npm run build

# run the compiled server
npm run start:prod

Contributing

Please read the contributors' guide

Open-source Contributors

avatars-api-middleware's People

Contributors

rylnd avatar itsthatguy avatar jackymancs4 avatar bigtiger avatar camwiegert avatar joeao avatar aiobot avatar m5rk avatar

Watchers

James Cloos avatar  avatar

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.