A Typescript library to access Forgejo via its api
Find a file
Maxim Slipenko dcdb933916
All checks were successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/tag/release Pipeline was successful
feat: support forgejo 11 (#2)
closes #1

Reviewed-on: #2
Co-authored-by: Maxim Slipenko <maks1ms@altlinux.org>
Co-committed-by: Maxim Slipenko <maks1ms@altlinux.org>
2025-05-13 09:11:13 +00:00
.woodpecker 🐛 fix ci npm token 2024-12-09 21:02:49 +01:00
contrib feat: support forgejo 11 (#2) 2025-05-13 09:11:13 +00:00
src feat: support forgejo 11 (#2) 2025-05-13 09:11:13 +00:00
.env.example 🎉 init 2024-12-09 20:03:43 +01:00
.gitignore 🎉 init 2024-12-09 20:03:43 +01:00
.prettierignore 💄 fix format check 2024-12-09 20:55:27 +01:00
.prettierrc.js 🎉 init 2024-12-09 20:03:43 +01:00
.releaserc.json 🎉 init 2024-12-09 20:03:43 +01:00
LICENSE 🎉 init 2024-12-09 20:03:43 +01:00
package.json feat: support forgejo 11 (#2) 2025-05-13 09:11:13 +00:00
pnpm-lock.yaml feat: support forgejo 11 (#2) 2025-05-13 09:11:13 +00:00
README.md feat: support forgejo 11 (#2) 2025-05-13 09:11:13 +00:00
tsconfig.json 🎉 init 2024-12-09 20:03:43 +01:00
vite.config.ts 🎉 init 2024-12-09 20:03:43 +01:00

Forgejo-js api client with Typescript support

NPM Version NPM Types NPM license CI status badge

Forgejo-js is an api client automatically created from the official OpenAPI definition of Forgejo. The client uses the Fetch Api (native browser support) to make requests. For node you can use cross-fetch to polyfill the Fetch Api.

For Gitea you can use gitea-js.

Version mapping

The major and minor version of this library is mapped to the version of the Forgejo api. The patch version of this library is incremented for every release and uses the latest patch version of Forgejo.

Forgejo-js Forgejo
11.0.x 11.0
9.0.x 9.0

Examples

Browser

import { forgejoApi } from 'forgejo-js';

const api = forgejoApi('https://codeberg.org/', {
  token: 'access-token', // generate one at https://forgejo.example.com/user/settings/applications
});

const repo = api.repos.repoGet('anbraten', 'forgejo-js');
console.log(repo);

Node.js

const { forgejoApi } = require('forgejo-js');
const fetch = require('cross-fetch'); // You have to use a fetch compatible polyfill like cross-fetch for older Node.JS versions

const api = forgejoApi('https://codeberg.org/', {
  token: 'access-token', // generate one at https://forgejo.example.com/user/settings/applications
  customFetch: fetch,
});

const repo = api.repos.repoGet('anbraten', 'forgejo-js');
console.log(repo);