chore: migrate to Now v2 (#320)

* feat: new doc generator (stage 1)
* feat: migrate badges to now v2 (stage 2)
* chore: update build & deploy config (stage 3)
* chore: address review comments
* chore: cleanup files
* fix: now deployment config
* fix: ts config
* chore: remove topbar
* chore: update routes config
pull/322/head 2.2.0
晋晓炜 Amio / 2019-11-18 23:52:07 +08:00 zatwierdzone przez GitHub
rodzic 30e19d0a07
commit b008408591
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
55 zmienionych plików z 463 dodań i 967 usunięć

1
.gitignore vendored
Wyświetl plik

@ -1,6 +1,7 @@
dist
yarn.lock
node_modules
public
.firebase
.next
.meta

4
.nowignore 100644
Wyświetl plik

@ -0,0 +1,4 @@
dist
test
.next
public

Wyświetl plik

@ -70,9 +70,9 @@ To ensure that your addition is working correctly, start the development server
__NOTES__
- You can create live badge without touching badgen.net's code. Checkout docs for [/runkit](https://badgen.net/docs/runkit) or [/https](https://badgen.net/docs/https).
- You can create live badge without touching badgen.net's code. Checkout docs for [/runkit](https://badgen.net/runkit) or [/https](https://badgen.net/https).
- The [/runkit](https://badgen.net/docs/runkit) support would be super handy for prototyping a new live badge.
- The [/runkit](https://badgen.net/runkit) support would be super handy for prototyping a new live badge.
### Add Icon

Wyświetl plik

@ -1,13 +1,8 @@
import got from '../libs/got'
import { millify, stars, version, versionColor } from '../libs/utils'
import {
badgenServe,
BadgenServeMeta as Meta,
BadgenServeHandlers as Handlers,
BadgenServeHandlerArgs as Args
} from '../libs/badgen-serve'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
export const meta: Meta = {
export default createBadgenHandler({
title: 'Mozilla Add-on',
examples: {
'/amo/v/markdown-viewer-chrome': 'version',
@ -15,14 +10,13 @@ export const meta: Meta = {
'/amo/rating/markdown-viewer-chrome': 'rating',
'/amo/stars/markdown-viewer-chrome': 'stars',
'/amo/reviews/markdown-viewer-chrome': 'reviews',
},
handlers: {
'/amo/:topic/:name': handler
}
}
})
export const handlers: Handlers = {
'/amo/:topic/:name': handler
}
async function handler ({ topic, name }: Args) {
async function handler ({ topic, name }: PathArgs) {
const endpoint = `https://addons.mozilla.org/api/v3/addons/addon/${name}/`
const addon = await got(endpoint).then(res => res.body)
@ -65,5 +59,3 @@ async function handler ({ topic, name }: Args) {
}
}
}
export default badgenServe(handlers)

Wyświetl plik

@ -1,28 +1,22 @@
import millify from 'millify'
import got from '../libs/got'
import { version, versionColor } from '../libs/utils'
import {
badgenServe,
BadgenServeMeta as Meta,
BadgenServeHandlers as Handlers,
BadgenServeHandlerArgs as Args
} from '../libs/badgen-serve'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
export const meta: Meta = {
export default createBadgenHandler({
title: 'Atom Package',
examples: {
'/apm/v/linter': 'version',
'/apm/stars/linter': 'stars',
'/apm/license/linter': 'license',
'/apm/downloads/linter': 'downloads'
},
handlers: {
'/apm/:topic/:pkg': handler
}
}
})
export const handlers: Handlers = {
'/apm/:topic/:pkg': handler
}
async function handler ({ topic, pkg }: Args) {
async function handler ({ topic, pkg }: PathArgs) {
const endpoint = `https://atom.io/api/packages/${pkg}`
const data = await got(endpoint).then(res => res.body)
@ -66,5 +60,3 @@ async function handler ({ topic, pkg }: Args) {
}
}
}
export default badgenServe(handlers)

Wyświetl plik

@ -1,24 +1,18 @@
import got from '../libs/got'
import {
badgenServe,
BadgenServeMeta as Meta,
BadgenServeHandlers as Handlers,
BadgenServeHandlerArgs as Args
} from '../libs/badgen-serve'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
export const meta: Meta = {
export default createBadgenHandler({
title: 'AppVeyor',
examples: {
'/appveyor/ci/gruntjs/grunt': 'build',
'/appveyor/ci/gruntjs/grunt/deprecate': 'build (branch)'
},
handlers: {
'/appveyor/ci/:account/:project/:branch?': handler
}
}
})
export const handlers: Handlers = {
'/appveyor/ci/:account/:project/:branch?': handler
}
async function handler ({ account, project, branch }: Args) {
async function handler ({ account, project, branch }: PathArgs) {
branch = branch ? `/branch/${branch}` : ''
const endpoint = `https://ci.appveyor.com/api/projects/${account}/${project}${branch}`
const { build } = await got(endpoint).then(res => res.body)
@ -29,5 +23,3 @@ async function handler ({ account, project, branch }: Args) {
color: build.status === 'success' ? 'green' : 'red'
}
}
export default badgenServe(handlers)

Wyświetl plik

@ -1,27 +1,19 @@
import cheerio from 'cheerio'
import got from '../libs/got'
import {
badgenServe,
BadgenServeMeta as Meta,
BadgenServeHandlers as Handlers,
BadgenServeHandlerArgs as Args
} from '../libs/badgen-serve'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
export const meta: Meta = {
export default createBadgenHandler({
title: 'Azure Piplines',
examples: {
'/azure-pipelines/yarnpkg/yarn/Yarn Acceptance Tests': 'build',
'/azure-pipelines/yarnpkg/yarn/Yarn Acceptance Tests/azure-pipelines': 'build (branch)',
},
handlers: {
'/azure-pipelines/:org/:project/:definition/:branch?': handler
}
}
})
export const handlers: Handlers = {
'/azure-pipelines/:org/:project/:definition/:branch?': handler
}
export default badgenServe(handlers)
async function handler ({ org, project, definition, branch = 'master'}: Args) {
async function handler ({ org, project, definition, branch = 'master'}: PathArgs) {
// @ts-ignore
const response = await got(`https://dev.azure.com/${org}/${project}/_apis/build/status/${definition}?branchName=${branch}`, { json: false })
const contentType = response.headers['content-type']

39
api/badge.ts 100644
Wyświetl plik

@ -0,0 +1,39 @@
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
export default createBadgenHandler({
title: 'Static',
examples: {
'/badge/Swift/4.2/orange': 'swift version',
'/badge/license/MIT/blue': 'license MIT',
'/badge/chat/on%20gitter/cyan': 'chat on gitter',
'/badge/stars/★★★★☆': 'star rating',
'/badge/become/a%20patron/F96854': 'patron',
'/badge/code%20style/standard/f2a': 'code style: standard'
},
handlers: {
'/badge/:label/:status': handler,
'/badge/:label/:status/:color': handler
}
})
async function handler ({ label, status, color }: PathArgs) {
return {
subject: label,
status,
color
}
}
// {
// title: 'With Options',
// examples: {
// '/badge/icon/github?icon=github': 'use builtin icon',
// '/badge/github/github?icon': 'use builtin icon (by subject)',
// '/badge/jQuery/powered?icon=https://simpleicons.now.sh/jquery/fff': 'use external icon',
// '/badge/icon/github?label=custom%20label': 'custom label',
// '/badge/icon/github?label': 'disable label',
// '/badge/github/github?icon&label': 'use icon, disable label',
// '/badge/platform/ios,macos,tvos?list=|': 'list (custom seprator)'
// }
// }

Wyświetl plik

@ -1,28 +1,20 @@
import got from '../libs/got'
import {
badgenServe,
BadgenServeMeta as Meta,
BadgenServeHandlers as Handlers,
BadgenServeHandlerArgs as Args
} from '../libs/badgen-serve'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
export const meta: Meta = {
export default createBadgenHandler({
title: 'Badgesize',
examples: {
'/badgesize/normal/amio/emoji.json/master/emoji-compact.json': 'normal size',
'/badgesize/brotli/amio/emoji.json/master/emoji-compact.json': 'brotli size',
'/badgesize/gzip/amio/emoji.json/master/emoji-compact.json': 'gzip size',
'/badgesize/normal/https://unpkg.com/snarkdown/dist/snarkdown.js': 'arbitrary url',
},
handlers: {
'/badgesize/:topic/:path+': handler
}
}
})
export const handlers: Handlers = {
'/badgesize/:topic/:path+': handler
}
export default badgenServe(handlers)
async function handler ({ topic, path }: Args) {
async function handler ({ topic, path }: PathArgs) {
const endpoint = `https://img.badgesize.io/${path}.json`
const { prettySize, color } = await got(endpoint, {
query: {

Wyświetl plik

@ -1,31 +1,23 @@
import byteSize from 'byte-size'
import got from '../libs/got'
import {
badgenServe,
BadgenServeMeta as Meta,
BadgenServeHandlers as Handlers,
BadgenServeHandlerArgs as Args
} from '../libs/badgen-serve'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
export const meta: Meta = {
export default createBadgenHandler({
title: 'Bundlephobia',
examples: {
'/bundlephobia/min/react': 'minified',
'/bundlephobia/minzip/react': 'minified + gzip',
'/bundlephobia/minzip/@material-ui/core': '(scoped pkg) minified + gzip',
},
handlers: {
'/bundlephobia/:topic/:scope<@.*>/:name': handler,
'/bundlephobia/:topic/:name': handler,
}
}
export const handlers: Handlers = {
'/bundlephobia/:topic/:scope<@.*>/:name': handler,
'/bundlephobia/:topic/:name': handler,
}
export default badgenServe(handlers)
})
// https://github.com/pastelsky/bundlephobia/issues/4
async function handler ({ topic, scope, name }: Args) {
async function handler ({ topic, scope, name }: PathArgs) {
const pkg = scope ? `${scope}/${name}` : name
const endpoint = `https://bundlephobia.com/api/size?package=${pkg}`
const resp = await got(endpoint).then(res => res.body)

Wyświetl plik

@ -1,14 +1,9 @@
import millify from 'millify'
import webstore from 'chrome-webstore'
import { version, versionColor, stars } from '../libs/utils'
import {
badgenServe,
BadgenServeMeta as Meta,
BadgenServeHandlers as Handlers,
BadgenServeHandlerArgs as Args
} from '../libs/badgen-serve'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
export const meta: Meta = {
export default createBadgenHandler({
title: 'Chrome Extensions',
examples: {
'/chrome-web-store/v/ckkdlimhmcjmikdlpkmbgfkaikojcbjk': 'version',
@ -17,17 +12,13 @@ export const meta: Meta = {
'/chrome-web-store/stars/ckkdlimhmcjmikdlpkmbgfkaikojcbjk': 'stars',
'/chrome-web-store/rating/ckkdlimhmcjmikdlpkmbgfkaikojcbjk': 'rating',
'/chrome-web-store/rating-count/ckkdlimhmcjmikdlpkmbgfkaikojcbjk': 'rating count',
},
handlers: {
'/chrome-web-store/:topic<v|users|price|stars|rating|rating-count>/:id': handler
}
}
})
export const handlers: Handlers = {
'/chrome-web-store/:topic<v|users|price|stars|rating|rating-count>/:id': handler
}
export default badgenServe(handlers)
async function handler ({ topic, id }: Args) {
async function handler ({ topic, id }: PathArgs) {
const meta = await webstore.detail({ id })
switch (topic) {
case 'v':

Wyświetl plik

@ -1,27 +1,19 @@
import qs from 'querystring'
import got from '../libs/got'
import {
badgenServe,
BadgenServeMeta as Meta,
BadgenServeHandlers as Handlers,
BadgenServeHandlerArgs as Args
} from '../libs/badgen-serve'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
export const meta: Meta = {
export default createBadgenHandler({
title: 'CircleCI',
examples: {
'/circleci/github/nuxt/nuxt.js': 'build',
'/circleci/github/nuxt/nuxt.js/master': 'build (branch)',
},
handlers: {
'/circleci/:vcs<github|gitlab>/:user/:project/:branch?': handler
}
}
})
export const handlers: Handlers = {
'/circleci/:vcs<github|gitlab>/:user/:project/:branch?': handler
}
export default badgenServe(handlers)
async function handler ({ vcs, user, project, branch }: Args) {
async function handler ({ vcs, user, project, branch }: PathArgs) {
// https://circleci.com/docs/api/v1-reference/
branch = branch ? `/tree/${qs.escape(branch)}` : ''
const endpoint = `https://circleci.com/api/v1.1/project/${vcs}/${user}/${project}${branch}?filter=completed&limit=1`

Wyświetl plik

@ -1,28 +1,19 @@
import {
badgenServe,
BadgenServeHandlerArgs as Args,
BadgenServeHandlers as Handlers,
BadgenServeMeta as Meta
} from '../libs/badgen-serve'
// import { coverage as cov, coverageColor } from '../libs/utils'
import got from '../libs/got'
import { coverage as cov, coverageColor } from '../libs/utils'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
export const meta: Meta = {
export default createBadgenHandler({
title: 'Codacy',
examples: {
'/codacy/coverage/f0875490cea1497a9eca9c25f3f7774e': 'coverage',
'/codacy/coverage/f0875490cea1497a9eca9c25f3f7774e/dev-master': 'branch coverage',
'/codacy/grade/f0875490cea1497a9eca9c25f3f7774e': 'code quality',
'/codacy/grade/f0875490cea1497a9eca9c25f3f7774e/dev-master': 'branch code quality'
},
handlers: {
'/codacy/:type<coverage|grade>/:projectId/:branch?': handler
}
}
export const handlers: Handlers = {
'/codacy/:type<coverage|grade>/:projectId/:branch?': handler
}
export default badgenServe(handlers)
})
const uriBase = 'https://api.codacy.com/project/badge'
@ -43,7 +34,7 @@ const SUBJECT_BY_TYPE = {
grade: 'code quality'
}
async function handler ({ type, projectId, branch }: Args) {
async function handler ({ type, projectId, branch }: PathArgs) {
if (projectId) {
const svg = await got(`${uriBase}/${type}/${projectId}`,
// @ts-ignore

Wyświetl plik

@ -1,13 +1,8 @@
import got from '../libs/got'
import { coverage as cov, scale } from '../libs/utils'
import {
badgenServe,
BadgenServeMeta as Meta,
BadgenServeHandlers as Handlers,
BadgenServeHandlerArgs as Args
} from '../libs/badgen-serve'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
export const meta: Meta = {
export default createBadgenHandler({
title: 'Code Climate',
examples: {
'/codeclimate/loc/codeclimate/codeclimate': 'lines of code',
@ -17,16 +12,13 @@ export const meta: Meta = {
'/codeclimate/maintainability-percentage/codeclimate/codeclimate': 'maintainability (percentage)',
'/codeclimate/coverage/codeclimate/codeclimate': 'coverage',
'/codeclimate/coverage-letter/codeclimate/codeclimate': 'coverage (letter)',
},
handlers: {
'/codeclimate/:topic/:owner/:repo': handler
}
}
})
export const handlers: Handlers = {
'/codeclimate/:topic/:owner/:repo': handler
}
export default badgenServe(handlers)
async function handler ({ topic, owner, repo }: Args) {
async function handler ({ topic, owner, repo }: PathArgs) {
const api = `https://api.codeclimate.com/v1/repos?github_slug=${owner}/${repo}`
const meta = await got(api).then(res => res.body.data[0])

Wyświetl plik

@ -1,13 +1,8 @@
import got from '../libs/got'
import { coverage, coverageColor } from '../libs/utils'
import {
badgenServe,
BadgenServeMeta as Meta,
BadgenServeHandlers as Handlers,
BadgenServeHandlerArgs as Args
} from '../libs/badgen-serve'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
export const meta: Meta = {
export default createBadgenHandler({
title: 'CodeCov',
examples: {
'/codecov/c/github/babel/babel': 'coverage (github)',
@ -16,16 +11,13 @@ export const meta: Meta = {
'/codecov/c/bitbucket/ignitionrobotics/ign-math/master': 'coverage (bitbucket, branch)',
'/codecov/c/gitlab/gitlab-org/gitaly': 'coverage (gitlab)',
'/codecov/c/gitlab/gitlab-org/gitaly/master': 'coverage (gitlab, branch)'
},
handlers: {
'/codecov/c/:vcs<gh|github|bitbucket|gitlab>/:owner/:repo/:branch?': handler
}
}
})
export const handlers: Handlers = {
'/codecov/c/:vcs<gh|github|bitbucket|gitlab>/:owner/:repo/:branch?': handler
}
export default badgenServe(handlers)
async function handler ({ vcs, owner, repo, branch }: Args) {
async function handler ({ vcs, owner, repo, branch }: PathArgs) {
const vcsType = {
github: 'gh',
bitbucket: 'bb',

Wyświetl plik

@ -1,31 +1,23 @@
import got from '../libs/got'
import { coverage as cov, coverageColor } from '../libs/utils'
import {
badgenServe,
BadgenServeMeta as Meta,
BadgenServeHandlers as Handlers,
BadgenServeHandlerArgs as Args
} from '../libs/badgen-serve'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
export const meta: Meta = {
export default createBadgenHandler({
title: 'Coveralls',
examples: {
'/coveralls/c/github/jekyll/jekyll': 'coverage (github)',
'/coveralls/c/github/jekyll/jekyll/master': 'coverage (github, branch)',
'/coveralls/c/bitbucket/pyKLIP/pyklip': 'coverage (bitbucket)',
'/coveralls/c/bitbucket/pyKLIP/pyklip/master': 'coverage (bitbucket, branch)',
},
handlers: {
'/coveralls/c/:vcs<github|bitbucket>/:owner/:repo/:branch?': handler
}
}
export const handlers: Handlers = {
'/coveralls/c/:vcs<github|bitbucket>/:owner/:repo/:branch?': handler
}
export default badgenServe(handlers)
})
// Detect coveralls.io's badge redirection instead of using it's api
// See https://github.com/badgen/badgen.net/issues/96
async function handler ({ vcs, owner, repo, branch }: Args) {
async function handler ({ vcs, owner, repo, branch }: PathArgs) {
const endpoint = `https://coveralls.io/repos/${vcs}/${owner}/${repo}/badge.svg`
const badgeURL = await got.head(endpoint, {
// @ts-ignore

Wyświetl plik

@ -1,28 +1,20 @@
import got from '../libs/got'
import { millify, version, versionColor } from '../libs/utils'
import {
badgenServe,
BadgenServeMeta as Meta,
BadgenServeHandlers as Handlers,
BadgenServeHandlerArgs as Args
} from '../libs/badgen-serve'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
export const meta: Meta = {
export default createBadgenHandler({
title: 'Rust Crates',
examples: {
'/crates/v/regex': 'version',
'/crates/d/regex': 'downloads',
'/crates/dl/regex': 'downloads (latest version)',
},
handlers: {
'/crates/:topic<v|d|dl>/:pkg': handler
}
}
})
export const handlers: Handlers = {
'/crates/:topic<v|d|dl>/:pkg': handler
}
export default badgenServe(handlers)
async function handler ({topic, pkg}: Args) {
async function handler ({topic, pkg}: PathArgs) {
const endpoint = `https://crates.io/api/v1/crates/${pkg}`
const { crate } = await got(endpoint).then(res => res.body)

Wyświetl plik

@ -1,12 +1,7 @@
import got from '../libs/got'
import {
badgenServe,
BadgenServeMeta as Meta,
BadgenServeHandlers as Handlers,
BadgenServeHandlerArgs as Args
} from '../libs/badgen-serve'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
export const meta: Meta = {
export default createBadgenHandler({
title: 'David DM',
examples: {
'/david/dep/zeit/pkg': 'dependencies',
@ -14,12 +9,11 @@ export const meta: Meta = {
'/david/peer/epoberezkin/ajv-keywords': 'peer dependencies',
'/david/optional/epoberezkin/ajv-keywords': 'optional dependencies',
'/david/dep/babel/babel/packages/babel-cli': 'dependencies (sub path)',
},
handlers: {
'/david/:topic/:user/:repo/:path*': handler
}
}
export const handlers: Handlers = {
'/david/:topic/:user/:repo/:path*': handler
}
})
const statusInfo = {
insecure: ['insecure', 'red'],
@ -29,7 +23,7 @@ const statusInfo = {
none: ['none', 'green']
}
async function handler ({ topic, user, repo, path }: Args) {
async function handler ({ topic, user, repo, path }: PathArgs) {
const prefix = {
dep: '',
dev: 'dev-',
@ -71,5 +65,3 @@ async function handler ({ topic, user, repo, path }: Args) {
}
}
}
export default badgenServe(handlers)

Wyświetl plik

@ -1,10 +1,5 @@
import got from '../libs/got'
import {
badgenServe,
BadgenServeMeta as Meta,
BadgenServeHandlers as Handlers,
BadgenServeHandlerArgs as Args
} from '../libs/badgen-serve'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
const help = `
## Private repositories
@ -38,21 +33,18 @@ https://badgen.net/dependabot/badgen/example-private-repo/<b>123456789</b>?icon=
</pre>
`
export const meta: Meta = {
export default createBadgenHandler({
title: 'Dependabot',
help,
examples: {
'/dependabot/dependabot/dependabot-core/?icon=dependabot': 'status'
},
help
}
handlers: {
'/dependabot/:owner/:repo/:identifier?': handler
}
})
export const handlers: Handlers = {
'/dependabot/:owner/:repo/:identifier?': handler
}
export default badgenServe(handlers)
async function handler ({ owner, repo, identifier }: Args) {
async function handler ({ owner, repo, identifier }: PathArgs) {
// https://github.com/dependabot/feedback/issues/6#issuecomment-503994253
let endpoint = `https://api.dependabot.com/badges/status?host=github&repo=${owner}/${repo}`
if (identifier) {

Wyświetl plik

@ -1,29 +1,21 @@
import millify from 'millify'
import got from '../libs/got'
import {
badgenServe,
BadgenServeMeta as Meta,
BadgenServeHandlers as Handlers,
BadgenServeHandlerArgs as Args
} from '../libs/badgen-serve'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
export const meta: Meta = {
export default createBadgenHandler({
title: 'Docker',
examples: {
'/docker/pulls/library/ubuntu': 'pulls (library)',
'/docker/stars/library/ubuntu': 'stars (library)',
'/docker/pulls/amio/node-chrome': 'pulls (scoped)',
'/docker/stars/library/mongo?icon=docker&label=stars': 'stars (icon & label)',
},
handlers: {
'/docker/:topic<stars|pulls>/:scope/:name': handler
}
}
})
export const handlers: Handlers = {
'/docker/:topic<stars|pulls>/:scope/:name': handler
}
export default badgenServe(handlers)
async function handler ({ topic, scope, name }: Args) {
async function handler ({ topic, scope, name }: PathArgs) {
if (!['stars', 'pulls'].includes(topic)) {
return {
subject: 'docker',

Wyświetl plik

@ -3,15 +3,9 @@ import distanceToNow from 'date-fns/formatDistanceToNow'
import got from '../libs/got'
import { version, millify } from '../libs/utils'
import {
badgenServe,
BadgenError,
BadgenServeMeta as Meta,
BadgenServeHandlers as Handlers,
BadgenServeHandlerArgs as Args
} from '../libs/badgen-serve'
import { createBadgenHandler, BadgenError, PathArgs } from '../libs/create-badgen-handler'
export const meta: Meta = {
export default createBadgenHandler({
title: 'GitHub',
examples: {
'/github/release/babel/babel': 'latest release',
@ -55,24 +49,23 @@ export const meta: Meta = {
'/github/assets-dl/electron/electron/v7.0.0': 'assets downloads for a tag',
'/github/dependents-repo/micromatch/micromatch': 'repository depentents',
'/github/dependents-pkg/micromatch/micromatch': 'package dependents',
},
handlers: {
'/github/:topic<watchers|stars|forks|branches|releases|tags|tag|license>/:owner/:repo': repoStats,
'/github/:topic<prs|open-prs|closed-prs|merged-prs>/:owner/:repo': repoStats,
'/github/:topic<issues|open-issues|closed-issues>/:owner/:repo': repoStats,
'/github/:topic<label-issues>/:owner/:repo/:label/:states?<open|closed>': repoStats,
'/github/:topic<commits|last-commit>/:owner/:repo/:ref?': repoStats,
'/github/:topic<dt|assets-dl>/:owner/:repo/:tag?': downloads, // `dt` is deprecated
'/github/release/:owner/:repo/:channel?': release,
'/github/checks/:owner/:repo/:ref?': checks,
'/github/status/:owner/:repo/:ref?': status,
'/github/status/:owner/:repo/:ref/:context+': status,
'/github/contributors/:owner/:repo': contributors,
'/github/dependents-repo/:owner/:repo': dependents('REPOSITORY'),
'/github/dependents-pkg/:owner/:repo': dependents('PACKAGE'),
}
}
export const handlers: Handlers = {
'/github/:topic<watchers|stars|forks|branches|releases|tags|tag|license>/:owner/:repo': repoStats,
'/github/:topic<prs|open-prs|closed-prs|merged-prs>/:owner/:repo': repoStats,
'/github/:topic<issues|open-issues|closed-issues>/:owner/:repo': repoStats,
'/github/:topic<label-issues>/:owner/:repo/:label/:states?<open|closed>': repoStats,
'/github/:topic<commits|last-commit>/:owner/:repo/:ref?': repoStats,
'/github/:topic<dt|assets-dl>/:owner/:repo/:tag?': downloads, // `dt` is deprecated
'/github/release/:owner/:repo/:channel?': release,
'/github/checks/:owner/:repo/:ref?': checks,
'/github/status/:owner/:repo/:ref?': status,
'/github/status/:owner/:repo/:ref/:context+': status,
'/github/contributors/:owner/:repo': contributors,
'/github/dependents-repo/:owner/:repo': dependents('REPOSITORY'),
'/github/dependents-pkg/:owner/:repo': dependents('PACKAGE'),
}
})
const pickGithubToken = () => {
const { GH_TOKENS } = process.env
@ -125,7 +118,7 @@ function combined (states: Array<any>, stateKey: string = 'state') {
throw new Error(`Unknown states: ${states.map(x => x.state).join()}`)
}
async function checks ({ owner, repo, ref = 'master'}: Args) {
async function checks ({ owner, repo, ref = 'master'}: PathArgs) {
const resp = await restGithub(`repos/${owner}/${repo}/commits/${ref}/check-runs`, 'antiope')
const status = combined(resp.check_runs, 'conclusion')
@ -136,7 +129,7 @@ async function checks ({ owner, repo, ref = 'master'}: Args) {
}
}
async function status ({ owner, repo, ref = 'master', context }: Args) {
async function status ({ owner, repo, ref = 'master', context }: PathArgs) {
const resp = await restGithub(`repos/${owner}/${repo}/commits/${ref}/status`)
let state = typeof context === 'string'
@ -162,7 +155,7 @@ async function status ({ owner, repo, ref = 'master', context }: Args) {
}
}
async function release ({ owner, repo, channel }: Args) {
async function release ({ owner, repo, channel }: PathArgs) {
const releases = await restGithub(`repos/${owner}/${repo}/releases`)
if (!releases || !releases.length) {
@ -192,7 +185,7 @@ async function release ({ owner, repo, channel }: Args) {
}
}
async function contributors ({ owner, repo }: Args) {
async function contributors ({ owner, repo }: PathArgs) {
const contributors = await restGithub(`repos/${owner}/${repo}/contributors`)
return {
@ -202,7 +195,7 @@ async function contributors ({ owner, repo }: Args) {
}
}
async function downloads ({ owner, repo, tag }: Args) {
async function downloads ({ owner, repo, tag }: PathArgs) {
const releaseSelection = tag ? `tags/${tag}` : 'latest'
const release = await restGithub(`repos/${owner}/${repo}/releases/${releaseSelection}`)
@ -303,7 +296,7 @@ const makeRepoQuery = (topic, owner, repo, restArgs) => {
}
}
async function repoStats ({topic, owner, repo, ...restArgs}: Args) {
async function repoStats ({topic, owner, repo, ...restArgs}: PathArgs) {
const result = await makeRepoQuery(topic, owner, repo, restArgs)
if (!result) {
@ -419,7 +412,7 @@ async function repoStats ({topic, owner, repo, ...restArgs}: Args) {
}
function dependents (type: string) {
return async function ({ owner, repo }: Args) {
return async function ({ owner, repo }: PathArgs) {
const html = await got(`https://github.com/${owner}/${repo}/network/dependents`, {
// @ts-ignore
json: false,
@ -446,5 +439,3 @@ const parseDependents = (html, type) => {
return depLink.text().replace(/[^0-9,]/g, '')
}
export default badgenServe(handlers)

Wyświetl plik

@ -1,28 +1,20 @@
import got from '../libs/got'
import { version as v, versionColor } from '../libs/utils'
import {
badgenServe,
BadgenServeMeta as Meta,
BadgenServeHandlers as Handlers,
BadgenServeHandlerArgs as Args
} from '../libs/badgen-serve'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
export const meta: Meta = {
export default createBadgenHandler({
title: 'Hackage',
examples: {
'/hackage/v/abt': 'version',
'/hackage/v/Cabal': 'version',
'/hackage/license/Cabal': 'license',
},
handlers: {
'/hackage/:topic<v|license>/:pkg': handler
}
}
})
export const handlers: Handlers = {
'/hackage/:topic<v|license>/:pkg': handler
}
export default badgenServe(handlers)
async function handler ({ topic, pkg }: Args) {
async function handler ({ topic, pkg }: PathArgs) {
const endpoint = `https://hackage.haskell.org/package/${pkg}/${pkg}.cabal`
// @ts-ignore
const cabal = await got(endpoint, { json: false }).then(res => res.body)

Wyświetl plik

@ -1,25 +1,19 @@
import got from '../libs/got'
import { version, versionColor } from '../libs/utils'
import {
badgenServe,
BadgenServeMeta as Meta,
BadgenServeHandlers as Handlers,
BadgenServeHandlerArgs as Args
} from '../libs/badgen-serve'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
export const meta: Meta = {
export default createBadgenHandler({
title: 'Homebrew',
examples: {
'/homebrew/v/fish': 'version',
'/homebrew/v/cake': 'version'
},
handlers: {
'/homebrew/v/:pkg': handler
}
}
})
export const handlers: Handlers = {
'/homebrew/v/:pkg': handler
}
async function handler ({ pkg }: Args) {
async function handler ({ pkg }: PathArgs) {
const endpoint = `https://formulae.brew.sh/api/formula/${pkg}.json`
const { versions } = await got(endpoint).then(res => res.body)
@ -29,5 +23,3 @@ async function handler ({ pkg }: Args) {
color: versionColor(versions.stable)
}
}
export default badgenServe(handlers)

Wyświetl plik

@ -1,10 +1,5 @@
import got from '../libs/got'
import {
badgenServe,
BadgenServeMeta as Meta,
BadgenServeHandlers as Handlers,
BadgenServeHandlerArgs as Args
} from '../libs/badgen-serve'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
const help = `
## Use Badgen with HTTPS Endpoint
@ -50,23 +45,20 @@ Furthermore, you may append path args to it:
</style>
`
export const meta: Meta = {
export default createBadgenHandler({
title: 'With HTTPS Endpoint',
help,
examples: {
'/https/cal-badge-icd0onfvrxx6.runkit.sh': 'https endpoint',
'/https/cal-badge-icd0onfvrxx6.runkit.sh/Asia/Shanghai': 'https endpoint (with path args)',
'/https/cal-badge-icd0onfvrxx6.runkit.sh/America/Los_Angeles': 'https endpoint (with path args)',
},
help
}
handlers: {
'/https/:hostname/:path*': handler
}
})
export const handlers: Handlers = {
'/https/:hostname/:path*': handler
}
async function handler ({ hostname, path }: Args) {
async function handler ({ hostname, path }: PathArgs) {
const endpoint = `https://${hostname}/${path || ''}`
return await got(endpoint).then(res => res.body)
}
export default badgenServe(handlers)

Wyświetl plik

@ -1,31 +1,23 @@
import millify from 'millify'
import got from '../libs/got'
import { versionColor } from '../libs/utils'
import {
badgenServe,
BadgenServeMeta as Meta,
BadgenServeHandlers as Handlers,
BadgenServeHandlerArgs as Args
} from '../libs/badgen-serve'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
export const meta: Meta = {
export default createBadgenHandler({
title: 'jsDelivr',
examples: {
'/jsdelivr/hits/gh/jquery/jquery': 'hits (per month)',
'/jsdelivr/hits/npm/lodash': 'hits (per month)',
'/jsdelivr/rank/npm/lodash': 'rank',
'/jsdelivr/v/npm/lodash': 'version',
},
handlers: {
'/jsdelivr/:topic<hits|rank>/:platform/:pkg+': handler,
'/jsdelivr/:topic<v>/npm/:pkg+': handler
}
}
})
export const handlers: Handlers = {
'/jsdelivr/:topic<hits|rank>/:platform/:pkg+': handler,
'/jsdelivr/:topic<v>/npm/:pkg+': handler
}
export default badgenServe(handlers)
async function handler ({ topic, platform, pkg }: Args) {
async function handler ({ topic, platform, pkg }: PathArgs) {
switch (topic) {
case 'hits':
return stats('hits', platform, pkg)

Wyświetl plik

@ -1,25 +1,17 @@
import got from '../libs/got'
import {
badgenServe,
BadgenServeMeta as Meta,
BadgenServeHandlers as Handlers,
BadgenServeHandlerArgs as Args
} from '../libs/badgen-serve'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
export const meta: Meta = {
export default createBadgenHandler({
title: 'Keybase',
examples: {
'/keybase/pgp/lukechilds': 'pgp key',
},
handlers: {
'/keybase/:topic<pgp>/:username': handler
}
}
})
export const handlers: Handlers = {
'/keybase/:topic<pgp>/:username': handler
}
export default badgenServe(handlers)
async function handler ({ topic, username }: Args) {
async function handler ({ topic, username }: PathArgs) {
const endpoint = `https://keybase.io/_/api/1.0/user/lookup.json`
const { body } = await got(endpoint, {
query: {

Wyświetl plik

@ -1,13 +1,8 @@
import millify from 'millify'
import got from '../libs/got'
import {
badgenServe,
BadgenServeMeta as Meta,
BadgenServeHandlers as Handlers,
BadgenServeHandlerArgs as Args
} from '../libs/badgen-serve'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
export const meta: Meta = {
export default createBadgenHandler({
title: 'LGTM',
examples: {
'/lgtm/langs/g/apache/cloudstack/java': 'langs',
@ -16,17 +11,14 @@ export const meta: Meta = {
'/lgtm/grade/g/apache/cloudstack/java': 'grade (java)',
'/lgtm/grade/g/apache/cloudstack': 'grade (auto)',
'/lgtm/grade/g/systemd/systemd': 'grade (auto)',
},
handlers: {
'/lgtm/:topic<alerts|grade|lines|langs>/g/:owner/:name/:lang?': handler,
'/lgtm/:topic<grade>/:lang/g/:owner/:name': handler, // deprecated
}
}
})
export const handlers: Handlers = {
'/lgtm/:topic<alerts|grade|lines|langs>/g/:owner/:name/:lang?': handler,
'/lgtm/:topic<grade>/:lang/g/:owner/:name': handler, // deprecated
}
export default badgenServe(handlers)
async function handler ({ topic, owner, name, lang }: Args) {
async function handler ({ topic, owner, name, lang }: PathArgs) {
// https://lgtm.com/help/lgtm/api/api-v1#LGTM-API-specification-Projects
const endpoint = `https://lgtm.com/api/v1.0/projects/g/${owner}/${name}`
const data = await got(endpoint).then(res => res.body)

Wyświetl plik

@ -1,18 +1,9 @@
import cheerio from 'cheerio'
import got from '../libs/got'
import { millify, version, versionColor } from '../libs/utils'
import {
badgenServe,
BadgenServeMeta as Meta,
BadgenServeHandlers as Handlers,
BadgenServeHandlerArgs as Args
} from '../libs/badgen-serve'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
// https://github.com/npm/registry/blob/master/docs/REGISTRY-API.md
// https://github.com/npm/registry/blob/master/docs/download-counts.md
// https://unpkg.com/
export const meta: Meta = {
export default createBadgenHandler({
title: 'npm',
examples: {
'/npm/v/express': 'version',
@ -31,17 +22,18 @@ export const meta: Meta = {
'/npm/types/tslib': 'types',
'/npm/types/react': 'types',
'/npm/types/queri': 'types',
},
handlers: {
'/npm/:topic/:scope<@.+>/:pkg/:tag?': handler,
'/npm/:topic/:pkg/:tag?': handler
}
}
})
export const handlers: Handlers = {
'/npm/:topic/:scope<@.+>/:pkg/:tag?': handler,
'/npm/:topic/:pkg/:tag?': handler
}
// https://github.com/npm/registry/blob/master/docs/REGISTRY-API.md
// https://github.com/npm/registry/blob/master/docs/download-counts.md
// https://unpkg.com/
export default badgenServe(handlers)
async function handler ({ topic, scope, pkg, tag }: Args) {
async function handler ({ topic, scope, pkg, tag }: PathArgs) {
const npmName = scope ? `${scope}/${pkg}` : pkg
switch (topic) {

Wyświetl plik

@ -1,32 +1,24 @@
import got from '../libs/got'
import { version, versionColor } from '../libs/utils'
import {
badgenServe,
BadgenServeMeta as Meta,
BadgenServeHandlers as Handlers,
BadgenServeHandlerArgs as Args
} from '../libs/badgen-serve'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
export const meta: Meta = {
export default createBadgenHandler({
title: 'Nuget',
examples: {
'/nuget/v/newtonsoft.json': 'version (stable channel)',
'/nuget/v/newtonsoft.json/pre': 'version (pre channel)',
'/nuget/v/newtonsoft.json/latest': 'version (latest channel)',
},
handlers: {
'/nuget/v/:project/:channel?': handler
}
}
export const handlers: Handlers = {
'/nuget/v/:project/:channel?': handler
}
export default badgenServe(handlers)
})
const pre = versions => versions.filter(v => v.includes('-'))
const stable = versions => versions.filter(v => !v.includes('-'))
const latest = versions => versions.length > 0 && versions.slice(-1)[0]
async function handler ({ project, channel }: Args) {
async function handler ({ project, channel }: PathArgs) {
const endpoint = `https://api.nuget.org/v3-flatcontainer/${project}/index.json`
const { versions } = await got(endpoint).then(res => res.body)

Wyświetl plik

@ -1,30 +1,22 @@
import got from '../libs/got'
import {
badgenServe,
BadgenServeMeta as Meta,
BadgenServeHandlers as Handlers,
BadgenServeHandlerArgs as Args
} from '../libs/badgen-serve'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
export const meta: Meta = {
export default createBadgenHandler({
title: 'Open Collective',
examples: {
'/opencollective/backers/webpack': 'backers',
'/opencollective/contributors/webpack': 'contributors',
'/opencollective/balance/webpack': 'balance',
'/opencollective/yearly/webpack': 'yearly income',
},
handlers: {
'/opencollective/:topic<backers|contributors|balance|yearly>/:slug': handler
}
}
export const handlers: Handlers = {
'/opencollective/:topic<backers|contributors|balance|yearly>/:slug': handler
}
export default badgenServe(handlers)
})
// https://developer.opencollective.com/#/api/collectives
async function handler ({ topic, slug }: Args) {
async function handler ({ topic, slug }: PathArgs) {
const endpoint = `https://opencollective.com/${slug}.json`
const details = await got(endpoint).then(res => res.body)

Wyświetl plik

@ -1,28 +1,20 @@
import got from '../libs/got'
import {
badgenServe,
BadgenServeMeta as Meta,
BadgenServeHandlers as Handlers,
BadgenServeHandlerArgs as Args
} from '../libs/badgen-serve'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
export const meta: Meta = {
export default createBadgenHandler({
title: 'Packagephobia',
examples: {
'/packagephobia/install/webpack': 'install size',
'/packagephobia/publish/webpack': 'publish size',
'/packagephobia/publish/@tusbar/cache-control': '(scoped pkg) publish size',
},
handlers: {
'/packagephobia/:topic/:scope<@.*>/:name': handler,
'/packagephobia/:topic/:name': handler,
}
}
})
export const handlers: Handlers = {
'/packagephobia/:topic/:scope<@.*>/:name': handler,
'/packagephobia/:topic/:name': handler,
}
export default badgenServe(handlers)
async function handler ({ topic, scope, name}: Args) {
async function handler ({ topic, scope, name}: PathArgs) {
const pkg = scope ? `${scope}/${name}` : name
const endpoint = `https://packagephobia.now.sh/v2/api.json?p=${pkg}`
const { install, publish } = await got(endpoint).then(res => res.body)

Wyświetl plik

@ -1,14 +1,9 @@
import millify from 'millify'
import got from '../libs/got'
import { version as v, versionColor, versionCompare } from '../libs/utils'
import {
badgenServe,
BadgenServeMeta as Meta,
BadgenServeHandlers as Handlers,
BadgenServeHandlerArgs as Args
} from '../libs/badgen-serve'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
export const meta: Meta = {
export default createBadgenHandler({
title: 'Packagist',
examples: {
'/packagist/v/monolog/monolog': 'version',
@ -28,16 +23,13 @@ export const meta: Meta = {
'/packagist/lang/monolog/monolog': 'language',
'/packagist/license/monolog/monolog': 'license',
'/packagist/php/monolog/monolog': 'php',
},
handlers: {
'/packagist/:topic<v|php>/:vendor/:pkg/:channel?': handler,
'/packagist/:topic<dt|dd|dm|favers|dependents|suggesters|n|name>/:vendor/:pkg': handler,
'/packagist/:topic<ghs|ghw|ghf|ghi|lang|license>/:vendor/:pkg': handler
}
}
export const handlers: Handlers = {
'/packagist/:topic<v|php>/:vendor/:pkg/:channel?': handler,
'/packagist/:topic<dt|dd|dm|favers|dependents|suggesters|n|name>/:vendor/:pkg': handler,
'/packagist/:topic<ghs|ghw|ghf|ghi|lang|license>/:vendor/:pkg': handler
}
export default badgenServe(handlers)
})
const pre = versions => versions.filter(v => v.includes('-') && v.indexOf('dev') !== 0)
const stable = versions => versions.filter(v => !v.includes('-'))
@ -65,7 +57,7 @@ const getVersion = (packageMeta, channel) => {
return version || latest(versions)
}
async function handler ({ topic, vendor, pkg, channel = 'latest' }: Args) {
async function handler ({ topic, vendor, pkg, channel = 'latest' }: PathArgs) {
const endpoint = `https://packagist.org/packages/${vendor}/${pkg}.json`
const { package: packageMeta } = await got(endpoint).then(res => res.body)

Wyświetl plik

@ -1,28 +1,20 @@
import got from '../libs/got'
import { version, versionColor } from '../libs/utils'
import {
badgenServe,
BadgenServeMeta as Meta,
BadgenServeHandlers as Handlers,
BadgenServeHandlerArgs as Args
} from '../libs/badgen-serve'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
export const meta: Meta = {
export default createBadgenHandler({
title: 'Pypi',
examples: {
'/pypi/v/pip': 'version',
'/pypi/v/docutils': 'version',
'/pypi/license/pip': 'license',
},
handlers: {
'/pypi/:topic<v|license>/:project': handler
}
}
})
export const handlers: Handlers = {
'/pypi/:topic<v|license>/:project': handler
}
export default badgenServe(handlers)
async function handler ({ topic, project }: Args) {
async function handler ({ topic, project }: PathArgs) {
const endpoint = `https://pypi.org/pypi/${project}/json`
const { info } = await got(endpoint).then(res => res.body)

Wyświetl plik

@ -1,14 +1,9 @@
import millify from 'millify'
import got from '../libs/got'
import { version as v, versionColor } from '../libs/utils'
import {
badgenServe,
BadgenServeMeta as Meta,
BadgenServeHandlers as Handlers,
BadgenServeHandlerArgs as Args
} from '../libs/badgen-serve'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
export const meta: Meta = {
export default createBadgenHandler({
title: 'Ruby Gems',
examples: {
'/rubygems/v/rails': 'version (stable)',
@ -18,15 +13,12 @@ export const meta: Meta = {
'/rubygems/dv/rails': 'latest version downloads',
'/rubygems/n/rails': 'name',
'/rubygems/p/rails': 'platform',
},
handlers: {
'/rubygems/v/:gem/:channel?': versionHandler,
'/rubygems/:topic<dt|dv|n|p>/:gem': handler
}
}
export const handlers: Handlers = {
'/rubygems/v/:gem/:channel?': versionHandler,
'/rubygems/:topic<dt|dv|n|p>/:gem': handler
}
export default badgenServe(handlers)
})
const preConditions = ['.rc', '.beta', '-rc', '-beta']
@ -52,7 +44,7 @@ const stable = versions => versions.filter(v => {
const latest = versions => versions.length > 0 && versions.slice(-1)[0]
async function versionHandler ({ gem, channel = 'stable' }: Args) {
async function versionHandler ({ gem, channel = 'stable' }: PathArgs) {
const endpoint = `https://rubygems.org/api/v1/versions/${gem}.json`
const response = await got(endpoint).then(res => res.body)
@ -81,7 +73,7 @@ async function versionHandler ({ gem, channel = 'stable' }: Args) {
}
}
async function handler ({ topic, gem }: Args) {
async function handler ({ topic, gem }: PathArgs) {
const endpoint = `https://rubygems.org/api/v1/gems/${gem}.json`
const response = await got(endpoint).then(res => res.body)

Wyświetl plik

@ -1,10 +1,5 @@
import got from '../libs/got'
import {
badgenServe,
BadgenServeMeta as Meta,
BadgenServeHandlers as Handlers,
BadgenServeHandlerArgs as Args
} from '../libs/badgen-serve'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
const help = `
https://badgen.net/runkit/cal-badge-icd0onfvrxx6/Asia/Shanghai
@ -65,23 +60,20 @@ https://cal-badge-icd0onfvrxx6.runkit.sh/Asia/Shanghai
\`\`\`
`
export const meta: Meta = {
export default createBadgenHandler({
title: 'With RunKit Endpoint',
help,
examples: {
'/runkit/satisfaction-flq08o9mm3ka/102909/topic': 'satisfaction (topic)',
'/runkit/satisfaction-flq08o9mm3ka/102909/people': 'satisfaction (people)',
'/runkit/satisfaction-flq08o9mm3ka/102909/employee': 'satisfaction (employ)',
},
help
}
handlers: {
'/runkit/:endpoint-id/:path*': handler
}
})
export const handlers: Handlers = {
'/runkit/:endpoint-id/:path*': handler
}
async function handler ({ 'endpoint-id': id, path }: Args) {
async function handler ({ 'endpoint-id': id, path }: PathArgs) {
const endpoint = `https://${id}.runkit.sh/${path || ''}`
return await got(endpoint).then(res => res.body)
}
export default badgenServe(handlers)

Wyświetl plik

@ -1,26 +1,18 @@
import got from '../libs/got'
import {
badgenServe,
BadgenServeMeta as Meta,
BadgenServeHandlers as Handlers,
BadgenServeHandlerArgs as Args
} from '../libs/badgen-serve'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
export const meta: Meta = {
export default createBadgenHandler({
title: 'Travis CI',
examples: {
'/travis/babel/babel': 'build',
'/travis/babel/babel/6.x': 'build (branch)',
},
handlers: {
'/travis/:user/:repo/:branch?': handler
}
}
})
export const handlers: Handlers = {
'/travis/:user/:repo/:branch?': handler
}
export default badgenServe(handlers)
async function handler ({ user, repo, branch = 'master' }: Args) {
async function handler ({ user, repo, branch = 'master' }: PathArgs) {
const com = `https://api.travis-ci.com/${user}/${repo}.svg?branch=${branch}`
const org = `https://api.travis-ci.org/${user}/${repo}.svg?branch=${branch}`
const [svg1, svg2] = await Promise.all([

Wyświetl plik

@ -1,27 +1,19 @@
import millify from 'millify'
import got from '../libs/got'
import {
badgenServe,
BadgenServeMeta as Meta,
BadgenServeHandlers as Handlers,
BadgenServeHandlerArgs as Args
} from '../libs/badgen-serve'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
export const meta: Meta = {
export default createBadgenHandler({
title: 'Twitter',
examples: {
'/twitter/follow/rustlang': 'followers count',
'/twitter/follow/golang': 'followers count',
},
handlers: {
'/twitter/:topic<follow>/:user': handler
}
}
})
export const handlers: Handlers = {
'/twitter/:topic<follow>/:user': handler
}
export default badgenServe(handlers)
async function handler ({ topic, user }: Args) {
async function handler ({ topic, user }: PathArgs) {
const endpoint = `http://cdn.syndication.twimg.com/widgets/followbutton/info.json?screen_names=${user}`
const [info] = await got(endpoint).then(res => res.body)

Wyświetl plik

@ -1,11 +1,6 @@
import got from '../libs/got'
import { scale } from '../libs/utils'
import {
badgenServe,
BadgenServeMeta as Meta,
BadgenServeHandlers as Handlers,
BadgenServeHandlerArgs as Args
} from '../libs/badgen-serve'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
const help = `## Usage
@ -22,7 +17,7 @@ To use an \`/uptime-robot\` badge, you have to create or find an API key specifi
From your UptimeRobot dashboard, go to
[My Settings](https://uptimerobot.com/dashboard.php#mySettings) > API Settings > Monitor-Specific API Keys.`
export const meta: Meta = {
export default createBadgenHandler({
help,
title: 'Uptime Robot',
examples: {
@ -31,14 +26,11 @@ export const meta: Meta = {
'/uptime-robot/week/m780862024-50db2c44c703e5c68d6b1ebb': '(past week) uptime',
'/uptime-robot/month/m780862024-50db2c44c703e5c68d6b1ebb': '(past month) uptime',
'/uptime-robot/response/m780862024-50db2c44c703e5c68d6b1ebb': '(last hour) response',
},
handlers: {
'/uptime-robot/:topic<status|day|week|month|response>/:apikey': handler
}
}
export const handlers: Handlers = {
'/uptime-robot/:topic<status|day|week|month|response>/:apikey': handler
}
export default badgenServe(handlers)
})
/**
* DOCS
@ -48,7 +40,7 @@ export default badgenServe(handlers)
* /uptime-robot/:topic/:api_key
* :api_key are generated from uptimerobot settings page
*/
async function handler ({ topic, apikey }: Args) {
async function handler ({ topic, apikey }: PathArgs) {
const endpoint = `https://api.uptimerobot.com/v2/getMonitors`
const { monitors } = await got.post(endpoint, {
body: {

Wyświetl plik

@ -1,30 +1,22 @@
import millify from 'millify'
import got from '../libs/got'
import { version as v, versionColor } from '../libs/utils'
import {
badgenServe,
BadgenServeMeta as Meta,
BadgenServeHandlers as Handlers,
BadgenServeHandlerArgs as Args
} from '../libs/badgen-serve'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
export const meta: Meta = {
export default createBadgenHandler({
title: 'Visual Studio Marketplace',
examples: {
'/vs-marketplace/v/vscodevim.vim': 'version',
'/vs-marketplace/i/vscodevim.vim': 'installs',
'/vs-marketplace/d/vscodevim.vim': 'downloads',
'/vs-marketplace/rating/vscodevim.vim': 'rating',
},
handlers: {
'/vs-marketplace/:topic<v|i|d|rating>/:pkg': handler
}
}
})
export const handlers: Handlers = {
'/vs-marketplace/:topic<v|i|d|rating>/:pkg': handler
}
export default badgenServe(handlers)
async function handler ({ topic, pkg }: Args) {
async function handler ({ topic, pkg }: PathArgs) {
const { results } = await queryVSM(pkg)
const extension = results[0].extensions[0]

Wyświetl plik

@ -1,27 +1,19 @@
import got from '../libs/got'
import {
badgenServe,
BadgenServeMeta as Meta,
BadgenServeHandlers as Handlers,
BadgenServeHandlerArgs as Args
} from '../libs/badgen-serve'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
export const meta: Meta = {
export default createBadgenHandler({
title: 'XO',
examples: {
'/xo/status/badgen': 'status',
'/xo/status/chalk': 'status',
'/xo/indent/@tusbar/cache-control': 'indent',
'/xo/semi/got': 'semicolons',
},
handlers: {
'/xo/:topic<status|indent|semi>/:name': handler,
'/xo/:topic<status|indent|semi>/:scope<@.+>/:name': handler
}
}
export const handlers: Handlers = {
'/xo/:topic<status|indent|semi>/:name': handler,
'/xo/:topic<status|indent|semi>/:scope<@.+>/:name': handler
}
export default badgenServe(handlers)
})
const getIndent = space => {
if (space === false) return 'tab'
@ -30,7 +22,7 @@ const getIndent = space => {
return `${space} spaces`
}
async function handler ({ topic, scope, name }: Args) {
async function handler ({ topic, scope, name }: PathArgs) {
const pkg = scope ? `${scope}/${name}` : name
const endpoint = `https://cdn.jsdelivr.net/npm/${pkg}/package.json`
const data = await got(endpoint).then(res => res.body)

Wyświetl plik

@ -48,11 +48,11 @@ export default function HomeIntro ({ isFlat = false }) {
<h3>Advanced usage</h3>
<ul>
<li>
<a href='/docs/runkit'><code>/runkit</code></a>
<a href='/runkit'><code>/runkit</code></a>
create arbitrary live badge with RunKit's online IDE.
</li>
<li>
<a href='/docs/https'><code>/https</code></a>
<a href='/https'><code>/https</code></a>
turn an api endpoint into a svg live badge.
</li>
</ul>

Wyświetl plik

@ -1,42 +0,0 @@
import { badgenServe } from '../libs/badgen-serve'
export const examples = [
{
title: 'General',
examples: {
'/badge/Swift/4.2/orange': 'swift version',
'/badge/license/MIT/blue': 'license MIT',
'/badge/chat/on%20gitter/cyan': 'chat on gitter',
'/badge/stars/★★★★☆': 'star rating',
'/badge/become/a%20patron/F96854': 'patron',
'/badge/code%20style/standard/f2a': 'code style: standard'
}
}, {
title: 'With Options',
examples: {
'/badge/icon/github?icon=github': 'use builtin icon',
'/badge/github/github?icon': 'use builtin icon (by subject)',
'/badge/jQuery/powered?icon=https://simpleicons.now.sh/jquery/fff': 'use external icon',
'/badge/icon/github?label=custom%20label': 'custom label',
'/badge/icon/github?label': 'disable label',
'/badge/github/github?icon&label': 'use icon, disable label',
'/badge/platform/ios,macos,tvos?list=|': 'list (custom seprator)'
}
}
]
export const handlers = {
'/badge/:label/:status': handler,
'/badge/:label/:status/:color': handler
}
async function handler (args) {
const { label, status, color } = args
return {
subject: label,
status,
color
}
}
export default badgenServe(handlers)

Wyświetl plik

@ -17,7 +17,7 @@ const sendRedirection = (res: http.ServerResponse, code: number, dest: string) =
res.end()
}
const badgeNames = fs.readdirSync(path.join(__dirname, 'endpoints'))
const badgeNames = fs.readdirSync(path.join(__dirname, 'api'))
.filter(name => /\.[jt]s$/.test(name))
.map(name => name.replace(/\.[jt]s$/, ''))
@ -61,7 +61,7 @@ const server = http.createServer(async (req, res) => {
try {
if (handlerName) {
const handlerPath = path.join(__dirname, 'endpoints', handlerName)
const handlerPath = path.join(__dirname, 'api', handlerName)
const { default: handler } = await import(handlerPath)
return handler(req, res, handlerName)
}

Wyświetl plik

@ -1,5 +1,5 @@
import path from 'path'
import { examples as staticBadgeExamples } from '../endpoints/badge'
import staticBadges from '../api/badge'
const rel = (...args) => path.resolve(__dirname, ...args)
@ -50,20 +50,25 @@ export const liveBadgeList = [
export async function loadBadgeMeta () {
const liveBadgeExamples = await Promise.all(liveBadgeList.map(async id => {
const { meta, handlers } = await import(rel('../endpoints', id))
const { title, examples, help } = meta
const mod = await import(rel('../api', id))
const { title, examples, handlers } = mod.default.meta
return {
id,
title,
examples,
routes: Object.keys(handlers),
help
}
}))
const statics = {
title: staticBadges.meta.title,
examples: staticBadges.meta.examples,
routes: Object.keys(staticBadges.meta.handlers)
}
return {
live: liveBadgeExamples,
static: staticBadgeExamples
static: [statics]
}
}

Wyświetl plik

@ -1,165 +0,0 @@
import url from 'url'
import matchRoute from 'my-way'
import fetchIcon from './fetch-icon'
import serveBadge from './serve-badge'
import serveDocs from './serve-docs'
import serve404 from './serve-404'
import sentry from './sentry'
import { BadgenParams } from './types'
export type BadgenServeMeta = {
title: string
examples: { [url: string]: string }
help?: string
}
export type BadgenServeHandlerArgs = { [key: string]: string }
export type BadgenServeHandlerResult = Promise<BadgenParams | undefined>
export type BadgenServeHandler = (args: BadgenServeHandlerArgs) => BadgenServeHandlerResult
export type BadgenServeHandlers = { [key: string]: BadgenServeHandler }
export function badgenServe (handlers: BadgenServeHandlers): Function {
return async function Handler (req, res, name) {
const { pathname = '/', query } = url.parse(req.url, true)
// Serve favicon
if (pathname === '/favicon.ico' || pathname === null) {
return res.end()
}
// Serve docs
if (matchRoute(`/${name}`, pathname)) {
return serveDocs(req, res, name)
}
// Find handler
let matchedArgs
const matchedScheme = Object.keys(handlers).find(scheme => {
matchedArgs = matchRoute(scheme, decodeURI(pathname))
return matchedArgs !== null
})
const defaultLabel = pathname.split('/')[1]
const defaultParams = {
subject: defaultLabel,
status: 'unknown',
color: 'grey'
}
if (matchedScheme) {
try {
const paramsPromise = handlers[matchedScheme](matchedArgs)
let iconPromise: Promise<string | undefined> = Promise.resolve(undefined)
if (typeof query.icon === 'string') {
if (query.icon.startsWith('https://')) {
iconPromise = fetchIcon(query.icon).catch(e => undefined)
} else {
iconPromise = Promise.resolve(query.icon)
}
}
const [ icon, params = defaultParams ] = await Promise.all([
iconPromise,
paramsPromise
])
params.subject = simpleDecode(params.subject)
params.status = simpleDecode(params.status)
if (icon !== undefined) {
query.icon = icon === '' ? params.subject : icon
}
if (query.style === undefined) {
const host = req.headers['x-forwarded-host'] || req.headers.host
if (host.startsWith('flat')) {
query.style = 'flat'
}
}
return serveBadge(req, res, { params, query: query as any })
} catch (error) {
if (error instanceof BadgenError) {
console.error(`BGE${error.code} "${error.status}" ${req.url}`)
return serveBadge(req, res, {
code: error.code,
sMaxAge: 5,
params: {
subject: defaultLabel,
status: error.status,
color: error.color
}
})
}
// Handle timeout for `got` requests
if (error.code === 'ETIMEDOUT') {
console.error(`APIE504 ${req.url}`)
return serveBadge(req, res, {
code: 504,
sMaxAge: 5,
params: {
subject: defaultLabel,
status: 'timeout',
color: 'grey'
}
})
}
// Handle requests errors from `got`
if (error.statusCode) {
const errorInfo = `${error.url} ${error.statusMessage}`
console.error(`APIE${error.statusCode} ${req.url} ${errorInfo}`)
return serveBadge(req, res, {
code: 502,
sMaxAge: 5,
params: {
subject: defaultLabel,
status: error.statusCode,
color: 'grey'
}
})
}
sentry.configureScope((scope) => {
scope.setTag('path', req.url)
scope.setTag('service', defaultLabel)
})
sentry.captureException(error)
// uncatched error
console.error(`UCE ${req.url}`, error.message, error)
return serveBadge(req, res, {
code: 500,
sMaxAge: 5,
params: {
subject: 'badgen',
status: 'error',
color: 'grey'
}
})
}
} else {
return serve404(req, res)
}
}
}
export class BadgenError {
public status: string // error badge param: status (required)
public color: string // error badge param: color
public code: number // status code for response
constructor ({ status, color = 'grey', code = 500 }) {
this.status = status
this.color = color
this.code = code
}
}
function simpleDecode (str: any): string {
return String(str).replace(/%2F/g, '/')
}

Wyświetl plik

@ -4,7 +4,7 @@ import urlParse from 'url-parse'
import fetchIcon from './fetch-icon'
import serveBadge from './serve-badge'
import serveDocs from './serve-docs'
import serveDoc from './serve-doc'
import sentry from './sentry'
import { BadgenParams } from './types'
@ -12,7 +12,7 @@ import { BadgenParams } from './types'
export type PathArgs = NonNullable<ReturnType<typeof matchRoute>>
export interface BadgeMaker {
(pathArgs: PathArgs) : Promise<BadgenParams>;
(pathArgs: PathArgs) : Promise<BadgenParams | undefined>;
}
export interface BadgenServeConfig {
@ -34,8 +34,12 @@ export class BadgenError {
}
}
export function createBadgenHandler (conf: BadgenServeConfig): http.RequestListener {
return async function badgenHandler (req, res) {
export interface BadgenHandler extends http.RequestListener {
meta: BadgenServeConfig;
}
export function createBadgenHandler (conf: BadgenServeConfig): BadgenHandler {
async function badgenHandler (req, res) {
const url = req.url ?? '/'
const { pathname, query } = urlParse(url, true)
@ -158,6 +162,9 @@ export function createBadgenHandler (conf: BadgenServeConfig): http.RequestListe
})
}
}
badgenHandler.meta = conf
return badgenHandler
}
function getBadgeStyle (req: http.IncomingMessage): string | undefined {
@ -184,10 +191,3 @@ function serve404 (req: http.IncomingMessage, res: http.ServerResponse) {
serveBadge(req, res, { code: 404, params, query })
}
function serveDoc (conf: BadgenServeConfig): http.RequestListener {
return (req, res) => {
// TODO: render docs
res.end('docs')
}
}

Wyświetl plik

@ -1,71 +0,0 @@
import path from 'path'
import matchRoute from 'my-way'
export default function genHelp (id) {
let badgeModule
try {
badgeModule = require(path.resolve(__dirname, '../endpoints', id))
} catch (e) {
return ''
}
if (id === 'badge') {
return genStaticBadgeHelp(badgeModule.examples)
}
const { meta, handlers } = badgeModule
const { examples, help = ''} = meta
const routes = Object.keys(handlers)
let md = `# /${id}\n\n${help}\n\n`
const egCats = routes.reduce((accu, curr) => {
accu[curr] = []
return accu
}, {})
Object.entries(examples).forEach((eg) => {
const scheme = routes.find(r => matchRoute(r, eg[0]))
if (scheme) {
egCats[scheme].push(eg)
}
})
md += '## Examples\n\n'
Object.entries(egCats).forEach(([cat, egs]) => {
// category title (scheme)
const hash = hashify(cat)
md += `\n\n<h4 id="${hash}"><a href="#${hash}">
<code>${cat.replace(/</g, '&lt;')}</code>
</a></h4>\n\n`
// category example list
// @ts-ignore
md += egs.map(egLine).join('\n')
})
return md
}
// turn `/github/:topic<commits|last-commit>/:owner/:repo/:ref?`
// into `github-topic-commits-last-commit-owner-repo-ref`
function hashify (str: string) {
// return str.replace(/[^\w]/g, '')
return str.split(/[^\w]+/).filter(Boolean).join('-')
}
function egLine ([url, desc]) {
return `- ![${url}](${url}) [${url}](${url}) <i>${desc}</i>`
}
function genStaticBadgeHelp (staticExamples) {
let md = `# Static Badge\n\n`
md += staticExamples.map(({ title, examples }) => {
return `### ${title}\n\n` + Object.entries(examples).map(egLine).join('\n')
}).join('\n\n')
return md
}

Wyświetl plik

@ -1,28 +1,69 @@
import http from 'http'
import matchRoute from 'my-way'
import serveMarked from 'serve-marked'
import serve404 from '../libs/serve-404'
import genHelp from '../libs/gen-help'
import { BadgenServeConfig } from '../libs/create-badgen-handler'
export default async function (req, res, name) {
const helpMarkdown = genHelp(name)
export default function serveDoc (conf: BadgenServeConfig): http.RequestListener {
return (req, res) => {
const helpMarkdown = generateHelpMarkdown(conf)
if (helpMarkdown) {
res.setHeader('Cache-Control', 'public, max-age=86400, s-maxage=604800, stale-while-revalidate=86400')
if (helpMarkdown) {
res.setHeader('Cache-Control', 'public, max-age=86400, s-maxage=604800, stale-while-revalidate=86400')
return serveMarked(helpMarkdown, {
title: `${name} badge | Badgen`,
inlineCSS,
beforeHeadEnd: '<link rel="icon" href="/favicon.png">',
beforeBodyEnd: helpFooter,
trackingGA: process.env.TRACKING_GA
})(req, res)
return serveMarked(helpMarkdown, {
title: `${conf.title} badge | Badgen`,
inlineCSS,
beforeHeadEnd: '<link rel="icon" href="/favicon.png">',
beforeBodyEnd: helpFooter,
trackingGA: process.env.TRACKING_GA
})(req, res)
}
serve404(req, res)
}
}
serve404(req, res)
function generateHelpMarkdown ({ title, help, examples, handlers }: BadgenServeConfig): string {
const mainTitle = `# ${title} Badge`
const customHelp = help ?? ''
const exampleTitle = `## Examples`
const routes = Object.keys(handlers)
const categorizedExamples = Object.entries(examples).reduce((accu, [url, desc]) => {
const scheme = routes.find(route => matchRoute(route, url))
if (scheme) {
accu[scheme] ? accu[scheme].push({ url, desc }) : accu[scheme] = [{ url, desc }]
}
return accu
}, {})
const examplesSection = Object.entries(categorizedExamples).reduce((accu, [header, list]) => {
const hash = hashify(header)
const h4 = `<h4 id="${hash}"><a href="#${hash}"><code>${header.replace(/</g, '&lt;')}</code></a></h4>`
const ul = (list as Array<any>).reduce((acc, { url, desc }) => {
return `${acc}\n- ![${url}](${url}) [${url}](${url}) <i>${desc}</i>`
}, '')
return `${accu}\n\n${h4}\n\n${ul}`
}, '')
console.log(categorizedExamples, examplesSection)
return [mainTitle, customHelp, exampleTitle, examplesSection].join('\n\n')
}
// turn `/github/:topic<commits|last-commit>/:owner/:repo/:ref?`
// into `github-topic-commits-last-commit-owner-repo-ref`
function hashify (str: string) {
// return str.replace(/[^\w]/g, '')
return str.split(/[^\w]+/).filter(Boolean).join('-')
}
const inlineCSS = `
html, body { scroll-behavior: smooth }
.markdown-body { max-width: 850px }
.markdown-body { max-width: 850px; min-height: calc(100vh - 348px) }
.markdown-body h1 { margin-bottom: 42px }
li > img { vertical-align: middle; margin: 0.2em 0; font-size: 12px; float: right }
li > img + a { font-family: monospace; font-size: 0.9em }

34
now-v1.json 100644
Wyświetl plik

@ -0,0 +1,34 @@
{
"version": 1,
"type": "docker",
"alias": [
"badgen.net",
"flat.badgen.net"
],
"files": [
"package.json",
"package-lock.json",
"server.tsconfig.json",
"tsconfig.json",
"next-env.d.ts",
"next.config.js",
"index.ts",
"tools",
"libs",
"pages",
"static",
"endpoints",
"components"
],
"env": {
"GH_TOKENS": "@badgen-gh-tokens",
"SENTRY_DSN": "@badgen-sentry-dsn",
"TRACKING_GA": "@badgen-tracking-ga"
},
"engines": {
"node": "^10"
},
"github": {
"autoAlias": false
}
}

Wyświetl plik

@ -1,44 +0,0 @@
{
"version": 2,
"alias": [
"v2.badgen.net"
],
"regions": ["sfo", "lhr", "hnd"],
"builds": [
{ "src": "endpoints/*.ts", "use": "@now/node" },
{ "src": "package.json", "use": "@now/static-build" }
],
"routes": [
{ "src": "/(?<name>[^/]+)/.*", "dest": "/endpoints/$name.ts" },
{ "src": "/(\\w+)\\/?", "dest": "/endpoints/$1.ts" },
{
"src": "/",
"headers": {
"cache-control": "public, s-maxage=604800, stale-while-revalidate: 86400"
}
}
],
"env": {
"GH_TOKENS": "@badgen-gh-tokens",
"SENTRY_DSN": "@badgen-sentry-dsn",
"TRACKING_GA": "@badgen-tracking-ga"
},
"github": {
"autoAlias": false
},
"files": [
"package.json",
"package-lock.json",
"server.tsconfig.json",
"tsconfig.json",
"next-env.d.ts",
"next.config.js",
"index.ts",
"tools",
"libs",
"pages",
"static",
"endpoints",
"components"
]
}

Wyświetl plik

@ -1,33 +1,21 @@
{
"version": 1,
"type": "docker",
"alias": [
"badgen.net",
"flat.badgen.net"
"version": 2,
"alias": ["badgen.net", "flat.badgen.net"],
"regions": ["sfo", "lhr", "hnd"],
"builds": [
{ "src": "package.json", "use": "@now/static-build" },
{ "src": "api/*.ts", "use": "@now/node" }
],
"files": [
"package.json",
"package-lock.json",
"server.tsconfig.json",
"tsconfig.json",
"next-env.d.ts",
"next.config.js",
"index.ts",
"tools",
"libs",
"pages",
"static",
"endpoints",
"components"
"routes": [
{ "src": "/docs/(.*)", "status": 301, "headers": { "Location": "/$1" } },
{ "src": "/builder", "dest": "/builder.html" },
{ "src": "/(?<name>[^/]+).*", "dest": "/api/$name.ts" }
],
"env": {
"GH_TOKENS": "@badgen-gh-tokens",
"SENTRY_DSN": "@badgen-sentry-dsn",
"TRACKING_GA": "@badgen-tracking-ga"
},
"engines": {
"node": "^10"
},
"github": {
"autoAlias": false
}

Wyświetl plik

@ -13,7 +13,6 @@
"dev:api": "nodemon --config nodemon.json index.ts",
"dev:web": "next",
"tools": "ts-node -TP server.tsconfig.json tools/gen-examples.ts",
"now-build": "npm run build",
"start": "node dist/index.js"
},
"standard": {

Wyświetl plik

@ -1,7 +1,7 @@
import { useState, useEffect } from 'react'
import BadgeExamples from '../components/badge-examples'
import BadgenTitle from '../components/badgen-title'
import TopBar from '../components/top-bar'
// import TopBar from '../components/top-bar'
import Intro from '../components/home-intro'
import Footer from '../components/footer'
import examples from '../static/.meta/badges.json'
@ -17,7 +17,6 @@ const Index = () => {
})
return <>
<TopBar />
<BadgenTitle host={host} />
<div className='docs' style={{ width: '980px', margin: '0 auto' }}>
<Intro />

Wyświetl plik

@ -5,7 +5,7 @@
"allowJs": true,
"skipLibCheck": true,
"jsx": "preserve",
"target": "esnext",
"target": "es2018",
"module": "commonjs",
"moduleResolution": "node",
"esModuleInterop": true,
@ -16,7 +16,6 @@
},
"include": [
"index.ts",
"endpoints",
"types"
"api"
]
}

Wyświetl plik

@ -5,7 +5,7 @@
"allowJs": true,
"skipLibCheck": true,
"jsx": "preserve",
"target": "es2017",
"target": "es2018",
"module": "esnext",
"moduleResolution": "node",
"esModuleInterop": true,
@ -23,11 +23,11 @@
"noEmit": false
},
"include": [
"api",
"libs",
"index.ts",
"endpoints",
"components",
"pages",
"static"
"pages"
],
"exclude": [
"node_modules"