An avatar generetor https://avatars.jusemon.com
Find a file
2024-10-04 12:23:29 -05:00
src Fix build and non-random seed 2024-09-26 02:57:38 -05:00
.dockerignore Switch to npm, added docker setup 2024-09-26 19:00:29 -05:00
.env.example Refactor for using koa and dicebear 2024-09-26 01:13:22 -05:00
.gitignore Initial commit 2024-07-07 21:50:52 -05:00
docker-compose.yml Remove network from docker compose 2024-09-26 20:58:35 -05:00
Dockerfile Improve production image size 2024-10-04 12:23:29 -05:00
LICENSE.md Refactor for using koa and dicebear 2024-09-26 01:13:22 -05:00
package-lock.json Switch to npm, added docker setup 2024-09-26 19:00:29 -05:00
package.json Switch to npm, added docker setup 2024-09-26 19:00:29 -05:00
README.md Update readme with example image 2024-09-26 20:44:25 -05:00
tsconfig.json Fix build and non-random seed 2024-09-26 02:57:38 -05:00

Avatars API

A self-hosted avatars API using some of the DiceBear CC0 styles

You can take a look at my own self-hosted version here: https://avatars.jusemon.com

The following endpoints are available:

The size and style of the image can be changed with the following query params:

  • size: any number between 16 and 512
  • style: see the list endpoint, the valid values are defined by the property key

Example:

https://avatars.jusemon.com/jusemon?size=256&style=open-peeps where jusemon is the :seed

Example

Installation

Development

For run locally it needs a .env file with the environment variables defined in the .env.example

ALLOWED_ORIGINS includes a comma separated list for the allowed CORS sites.

Install dependencies npm install or yarn To start the project run npm run dev or yarn dev

Production

For run it in docker just run docker compose up

Alternatively, you can run the image without cloning this repo using the image published here

With docker run:

docker run -p 3000:3000 -e NODE_ENV=production -e HOST=0.0.0.0 -e PORT=3000 -e API_VERSION=1 -e ALLOWED_ORIGINS=https://example.com git.jusemon.com/jusemon/avatars-api:1.0.0

With docker compose:

name: avatars
services:
  api:
    image: git.jusemon.com/jusemon/avatars-api:1.0.0
    ports:
      - 3000:3000
    environment:
      NODE_ENV: "production"
      HOST: "0.0.0.0"
      PORT: 3000
      API_VERSION: 1
      ALLOWED_ORIGINS: "https://example.com"

Libraries Used

  • DiceBear (for avatar generation)
  • sharp (for png exportation)
  • uuid (for random seeds)

Credits

  • Created by Juan Sebastián Montoya

Credits for Styles:

Title Creator Source Homepage License
Open Peeps Pablo Stanley https://www.openpeeps.com/ https://twitter.com/pablostanley CC0 1.0
Pixel Art DiceBear https://www.figma.com/community/file/1198754108850888330 https://www.dicebear.com CC0 1.0
Thumbs DiceBear https://www.dicebear.com https://www.dicebear.com CC0 1.0

License

This project is licensed under the MIT License.