Home

Awesome

Tokei Serverless API

license CI GitHub repo size

This is a fork of the Tokei badge service that runs as a Vercel serverless function, utilizing Vercel's edge caching for fast responses. You can use the service hosted at https://aschey.tech/tokei or you can fork this repo and host it on your personal Vercel account.

Motivation

Hosting Tokei on a traditional server has the inherent issue of filling up disk space because Tokei works by cloning repositories. This can cause the service to go down if the disk space on the server fills up. Running on a serverless platform mitigates this issue because the container that runs the service is ephemeral. If someone requests a repository that crashes the service, it should still work fine for other users because it will just spin up a separate container.

Examples

Default (total lines): Total Lines

Lines of Code: Lines of Code

Blanks: Blanks

Comments: Comments

Files: Files

Plastic: Flat

Flat Square: Flat

Social: Flat

For the Badge: Flat

Styled: Styled

Logo Only: Logo Only

Logo as Label: Logo as Label

URL Scheme

https://aschey.tech/tokei/<domain>[.com]/<namespace>/<repository>[?category=<category>&format=<format>&style=<style>&labelColor=<labelColor>&color=<color>&label=<label>&logo=<logo>&logoAsLabel=<logoAsLabel>&cacheSeconds=<cacheSeconds>&branch=<branch>]

All querystring parameters are optional.

Standard Options used by shields.io

Custom Options

Self Hosting

To host this API yourself, you can fork this repository and connect your fork to your Vercel account. Once deployed, your API should be available at your-subdomain.vercel.app/tokei.

Running Locally

Install the Vercel CLI. Once installed, run vercel dev from the root directory. The site should be available at localhost:3000/tokei/[domain]/[user]/[repo].