Skip to content

Commit 4dcf649

Browse files
authored
Merge pull request #69 from adorableio/document_and_clean_up
Documentation and cleanup
2 parents 03f530a + c96d135 commit 4dcf649

File tree

2 files changed

+56
-71
lines changed

2 files changed

+56
-71
lines changed

README.md

Lines changed: 56 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,64 +2,80 @@
22
[![Build Status](https://travis-ci.org/adorableio/avatars-api.svg?branch=master)](https://travis-ci.org/adorableio/avatars-api?branch=master)
33

44
## What is it?
5+
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!
56

6-
#### What are avatars?
7-
Avatars are earthly creatures that serve as proxies for gods.
8-
In the web world, they just represent people, and they're usually small images.
7+
Check out [our website](http://avatars.adorable.io/) for more info on (and an interactive demo of) what this service does.
98

10-
Some use photographs of themselves as their avatar. Some people use caricatures of themselves. Others pick their favorite superhero. The sky's the limit.
11-
12-
#### What's an avatar _service_?
13-
It answers the question "What is this user's avatar?"
14-
In this way, it provides a consistent representation of that user.
15-
Across _all_ websites that use that service. Pretty cool, right?
16-
17-
But what if you haven't uploaded your image to that service?
18-
Then you get a really boring, gray silhouette.
19-
20-
#### So what's the Adorable Avatars service?
21-
It's an interface to a better universe. With a simple route, your face will be filled with consistently-linked avatar glory!
22-
23-
Huh? _Consistently-linked avatar glory?_
9+
## How do I use it?
10+
First, you'll need to install the package:
2411

25-
Whenever you make a request to Adorable Avatars, using an identifier like "[email protected]," we give you an image for you to use on your page.
26-
Most importantly, it's the same image! Every. Single. Time.
12+
```bash
13+
npm install adorable-avatars --save
14+
```
2715

28-
## Why would I use it?
29-
What if you're developing a feature like member lists or profiles, but you don't have any images to use?
30-
Just give us your user's identifier and we'll give you their avatar image!
31-
That's it.
16+
Then, use the router middleware within your application:
3217

33-
Already have avatars implemented in your application?
34-
Use Adorable Avatars as a fallback and get rid of those gray silhouettes!
18+
```js
19+
// your_server.js
20+
var express = require('express');
21+
var avatarsMiddleware = require('adorable-avatars');
3522

36-
## How do I use it?
37-
Here's a quick example in Haml:
38-
```haml
39-
.user
40-
%img.avatar(src="http://api.adorable.io/avatar/#{user.name}")
23+
var myApp = express();
24+
myApp.use('/myAvatars', avatarsMiddleware);
4125
```
4226

43-
### Requesting an Avatar
44-
The most basic request is of the following form:
27+
That's it! Your server now includes the avatars endpoints!
28+
29+
### Endpoints
30+
Assuming your server lives at `myserver.com`, and you've configured the middleware as above, you now have the following endpoints:
31+
32+
* `myserver.com/myAvatars/:id`
33+
* returns an avatar for the provided `id`.
34+
* `id` can be anything (email, username, md5 hash, as long as it's a valid URI)
35+
* defaults to 400px
36+
* `myserver.com/myAvatars/:size/:id`
37+
* returns an avatar for the provided `id` at the specified `size`
38+
* size cannot exceed 400px
39+
* `myserver.com/myAvatars/face/:eyes/:nose/:mouth/:color`
40+
* Allows you to generate a custom avatar from the specified parts and color
41+
* e.g. `myserver.com/myAvatars/face/eyes1/nose2/mouth4/DEADBF`
42+
* `myserver.com/myAvatars/list`
43+
* returns JSON of all valid parts for the custom endpoint above
44+
45+
## Development
46+
If you're developing locally, you'll first need to bootstrap (assumes [nvm](https://github.com/creationix/nvm)):
47+
48+
```bash
49+
# use correct node version
50+
nvm use
51+
52+
# install dependencies
53+
npm install
54+
```
4555

46-
http://api.adorable.io/avatar/<identifier>
56+
Then, there are several npm scripts that will be useful:
4757

48-
Where `identifier` is the unique identifier for your user (name, email, md5, etc.).
49-
This will serve the image in its default size.
58+
```bash
59+
# run the unit tests
60+
npm run test
5061

51-
To request an avatar with specific size, use the following form:
62+
# run a dev server
63+
npm run start
5264

53-
http://api.adorable.io/avatar/<size>/<identifier>
65+
# run both a dev server and eslint
66+
npm run dev
5467

55-
So, if you want your friend Bob's avatar, with a height and width of 200px, the URL would be:
68+
# compile the application
69+
npm run build
5670

57-
http://api.adorable.io/avatar/200/bob
71+
# run the compiled server
72+
npm run start:prod
73+
```
5874

5975
## Contributing
6076

6177
Please read the [contributors' guide](CONTRIBUTING.md)
6278

6379
## Open-source Contributors
6480

65-
* [missingdink](https://twitter.com/missingdink): Illustrated the very first avatars! [/avatar/](http://api.adorable.io/avatar/hi_mom)
81+
* [missingdink](https://twitter.com/missingdink): Illustrated the very first avatars! [Check them out!](http://api.adorable.io/avatar/hi_mom)

src/routes/v1.js

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)