https://github.com/techquery/mobx-usa-congress
MobX SDK for USA Congress API, which is based on MobX-RESTful.
https://github.com/techquery/mobx-usa-congress
api congress governance mobx restful sdk usa
Last synced: about 2 months ago
JSON representation
MobX SDK for USA Congress API, which is based on MobX-RESTful.
- Host: GitHub
- URL: https://github.com/techquery/mobx-usa-congress
- Owner: TechQuery
- License: lgpl-3.0
- Created: 2024-09-16T10:23:52.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-11-24T15:16:35.000Z (over 1 year ago)
- Last Synced: 2025-10-04T08:54:52.013Z (6 months ago)
- Topics: api, congress, governance, mobx, restful, sdk, usa
- Language: TypeScript
- Homepage: http://tech-query.me/MobX-USA-Congress/
- Size: 206 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: ReadMe.md
- License: LICENSE
Awesome Lists containing this project
README
# MobX-USA-Congress
[MobX][1] SDK for [USA Congress API][2], which is based on [MobX-RESTful][3].
[][1]
[][4]
[][5]
[][6]
[][7]
[][8]
## Model
1. [Congress](source/Congress.ts)
2. [Member](source/Member.ts)
3. [Hearing](source/Hearing.ts)
4. [Committee](source/Committee/index.ts)
1. [Print](source/Committee/Print.ts)
5. [Bill](source/Bill.ts)
6. [Summary](source/Summary.ts)
## Usage
### Installation
```shell
npm i mobx-usa-congress
```
### `tsconfig.json`
```json
{
"compilerOptions": {
"target": "ES6",
"moduleResolution": "Node",
"useDefineForClassFields": true,
"experimentalDecorators": false,
"jsx": "react-jsx"
}
}
```
### `model/Congress.ts`
```typescript
import { githubClient, CongressModel } from 'mobx-usa-congress';
// Any possible way to pass USA Congress API token
// from local files or back-end servers to Web pages
const token = new URLSearchParams(location.search).get('token');
congressClient.use(({ request }, next) => {
if (token)
request.headers = {
authorization: `Bearer ${token}`,
...request.headers
};
return next();
});
export const congressStore = new CongressModel();
```
### `page/Congress.tsx`
Use [WebCell][9] as an Example
```tsx
import { Session } from 'mobx-usa-congress';
import { component, observer } from 'web-cell';
import { congressStore } from '../model/Congress';
@component({ tagName: 'congress-page' })
@observer
export class CongressPage extends HTMLElement {
connectedCallback() {
congressStore.getThisYearOne();
}
renderSession = ({
type,
number,
chamber,
startDate,
endDate
}: Session) => (
{type} #{number} {chamber} (
{' '}
~{' '}
)
);
render() {
const { thisYearOne } = congressStore;
return (
USA Congress
{thisYearOne?.name} ({thisYearOne?.startYear} ~{' '}
{thisYearOne?.endYear})
sessions
- {thisYearOne?.sessions.map(this.renderSession)}
);
}
}
```
[1]: https://mobx.js.org/
[2]: https://github.com/LibraryOfCongress/api.congress.gov
[3]: https://github.com/idea2app/MobX-RESTful
[4]: https://libraries.io/npm/mobx-usa-congress
[5]: https://github.com/TechQuery/MobX-USA-Congress/actions/workflows/main.yml
[6]: https://nodei.co/npm/mobx-usa-congress/
[7]: https://codespaces.new/TechQuery/MobX-USA-Congress
[8]: https://gitpod.io/?autostart=true#https://github.com/TechQuery/MobX-USA-Congress
[9]: https://github.com/EasyWebApp/WebCell