Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/itsthatguy/avatars-api-middleware
The express middleware for our avatars service
https://github.com/itsthatguy/avatars-api-middleware
Last synced: about 6 hours ago
JSON representation
The express middleware for our avatars service
- Host: GitHub
- URL: https://github.com/itsthatguy/avatars-api-middleware
- Owner: itsthatguy
- License: other
- Created: 2014-05-11T05:25:46.000Z (over 10 years ago)
- Default Branch: develop
- Last Pushed: 2023-03-01T19:26:18.000Z (over 1 year ago)
- Last Synced: 2024-05-19T01:53:02.031Z (6 months ago)
- Language: TypeScript
- Homepage: http://avatars.adorable.io
- Size: 4.13 MB
- Stars: 747
- Watchers: 41
- Forks: 98
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-identicons - Adorable Avatars - - [Adorable IO](https://github.com/adorableio) -->— 2014 (Adorable Avatars)
README
# adorable-avatars
[![Build Status](https://travis-ci.org/adorableio/avatars-api-middleware.svg)](https://travis-ci.org/adorableio/avatars-api-middleware)## What is it?
This repository contains the [express middleware](https://expressjs.com/en/guide/using-middleware.html#middleware.router) that can be used to host your own avatars service!Check out [our website](http://avatars.adorable.io/) for more info on (and an interactive demo of) what this service does.
## How do I use it?
First, you'll need the `adorable-avatars` package:```bash
npm install adorable-avatars --save
```Then, use the router middleware within your application:
```js
// 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](https://github.com/creationix/nvm)):```bash
# use correct node version
nvm use# install dependencies
npm install
```Then, there are several npm scripts that will be useful:
```bash
# run the unit tests
npm test# run both a dev server and eslint
npm run dev# run a dev server
npm run dev:server# run eslint
npm run dev:lint# compile the application
npm run build
```## Contributing
Please read the [contributors' guide](CONTRIBUTING.md)
## Open-source Contributors
* Kevin Altman [twitter @itg](https://twitter.com/itg) [github @itsthaguy](https://github.com/itsthatguy): Creator of Adorable Avatars, service, site, and artwork.
* Ryland Herrick [github @rylnd](https://github.com/rylnd): Programmer extraordinaire!
* [twitter @missingdink](https://twitter.com/missingdink): Illustrated the very first avatars! [Check them out!](http://api.adorable.io/avatar/hi_mom)