https://github.com/idea2app/mobx-github
MobX SDK for GitHub RESTful API, which is based on MobX-RESTful.
https://github.com/idea2app/mobx-github
api decorator github mobx restful sdk
Last synced: 5 months ago
JSON representation
MobX SDK for GitHub RESTful API, which is based on MobX-RESTful.
- Host: GitHub
- URL: https://github.com/idea2app/mobx-github
- Owner: idea2app
- License: lgpl-3.0
- Created: 2024-06-05T04:26:01.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2025-10-30T16:36:53.000Z (8 months ago)
- Last Synced: 2025-10-30T18:29:34.761Z (8 months ago)
- Topics: api, decorator, github, mobx, restful, sdk
- Language: TypeScript
- Homepage: https://idea2app.github.io/MobX-GitHub/
- Size: 214 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: ReadMe.md
- License: LICENSE
Awesome Lists containing this project
README
# MobX-GitHub
[MobX][1] SDK for [GitHub RESTful API][2], which is based on [MobX-RESTful][3].
[][1]
[][4]
[][5]
[][6]
## Model
1. [User](source/User.ts)
2. [Organization](source/Organization.ts)
3. [Repository](source/Repository.ts)
1. Contributor
2. Language
3. Issue
4. [Content](source/Content.ts) - Git file tree traversal
1. Directory traversal
2. Recursive tree traversal
3. File search by extension
4. File search by pattern
5. [Issue](source/Issue.ts)
6. [Issue Comment](source/IssueComment.ts)
7. [Pull Request](source/PullRequest.ts)
8. [Discussion](source/Discussion.ts)
9. [Contributor](source/Contributor.ts)
10. [Check Run](source/CheckRun.ts)
11. [Workflow Run](source/WorkflowRun.ts)
## Usage
### Installation
```shell
npm i mobx-github
```
### `tsconfig.json`
```json
{
"compilerOptions": {
"target": "ES6",
"moduleResolution": "Node",
"useDefineForClassFields": true,
"experimentalDecorators": false,
"jsx": "react-jsx"
}
}
```
### `model/GitHub.ts`
```typescript
import { githubClient, UserModel } from 'mobx-github';
// Any possible way to pass GitHub access token
// from local files or back-end servers to Web pages
const token = new URLSearchParams(location.search).get('token');
githubClient.use(({ request }, next) => {
if (token)
request.headers = {
authorization: `Bearer ${token}`,
...request.headers
};
return next();
});
export const userStore = new UserModel();
```
### `page/GitHub.tsx`
Use [WebCell][7] as an Example
```tsx
import { component, observer } from 'web-cell';
import { userStore } from '../model/GitHub';
@component({ tagName: 'github-page' })
@observer
export class GitHubPage extends HTMLElement {
connectedCallback() {
userStore.getSession();
}
disconnectedCallback() {
userStore.clear();
}
render() {
const { namespaces } = userStore;
return (
{namespaces.map(({ login }) => (
{login}
))}
);
}
}
```
## User cases
1. https://github.com/FreeCodeCamp-Chengdu/FreeCodeCamp-Chengdu.github.io
2. https://github.com/Open-Source-Bazaar/Open-Source-Bazaar.github.io
[1]: https://mobx.js.org/
[2]: https://docs.github.com/en/rest
[3]: https://github.com/idea2app/MobX-RESTful
[4]: https://libraries.io/npm/mobx-github
[5]: https://github.com/idea2app/MobX-GitHub/actions/workflows/main.yml
[6]: https://nodei.co/npm/mobx-github/
[7]: https://github.com/EasyWebApp/WebCell