Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/epic-digital-im/epic-gigwage
Gigwage API Client and Express Middleware
https://github.com/epic-digital-im/epic-gigwage
api gigwage nodejs typescript
Last synced: about 1 month ago
JSON representation
Gigwage API Client and Express Middleware
- Host: GitHub
- URL: https://github.com/epic-digital-im/epic-gigwage
- Owner: epic-digital-im
- License: mit
- Created: 2022-09-15T15:43:11.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-09T07:04:09.000Z (almost 2 years ago)
- Last Synced: 2024-10-17T05:45:39.082Z (2 months ago)
- Topics: api, gigwage, nodejs, typescript
- Language: TypeScript
- Homepage:
- Size: 433 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
- Security: SECURITY.md
Awesome Lists containing this project
README
:package: @epicdm/gigwage
TypeScript Gigwage Client API and Express Middleware
Typescript Gigwage Client w/ Express Middelware for validating incoming webhooks 🚀
# Beta - Currently in Development
Adding convenience methods for certain endpoints, eg: listSubscriptions. Not all methods implemented yet. Please check back soon.# Installation
```bash
yarn add @epicdm/gigwage
npm install @epicdm/gigwage
```# See Gigwage Developer Documentation
- https://developers.gigwage.com/docs
- https://developers.gigwage.com/reference# API Client usage, see [examples](https://github.com/epicdigitalmedia/epic-gigwage/tree/main/demo)
```javascript
import GigwageService, { Contractor, Subscription } from '../src/gigwage';const gigwageService = new GigwageService({
config: {
apiKey: 'YOUR_API_KEY',
apiSecret: 'YOUR_API_SECRET',
apiEnvironment: 'sandbox',
},
});/* Exposes signed axios request methods:
gigwageService.get
gigwageService.post
gigwageService.put
gigwageService.patch
gigwageService.del
*/gigwageService.get<{ contractors: Contractor[] }>("api/v1/contractors")
.then((response) => {
const contractors = response.data.contractors;
});gigwageService.post<{ contractor: Contractor }>("api/v1/contractors", {
contractor: {
first_name: 'John',
last_name: 'Doe',
email: '[email protected]',
}
}).then((response) => {
if (response.data.error) {
/* Axios handled error, includes validation error response:
{
"error": "Validation Failed",
"errors": [
"Email missing",
]
}
*/
}
const contractor = response.data.contractor;
});// Reactivate Subscription
gigwageService.put<{ subscription: Subscription }>(`api/v1/subscriptions/13`)
.then((response) => {
const subscription = response.data.subscription;
});// Delete Subscription
gigwageService.del<{ subscription: Subscription }>(`api/v1/subscriptions/13`)
.then((response) => {
const subscription = response.data.subscription;
});
```# Express Middleware Usage, see [examples](https://github.com/epicdigitalmedia/epic-gigwage/tree/main/demo)
```javascript
route.post(
`/gigwage/payment`,
gigwageService.bodyParser(), // need raw and JSON body
gigwageService.validateWebhook(), // validate webhook signature
async (request, response) => {
try {
// do something with the request, its been validated
response.status(200).send(`I did it!`);
} catch (err: any) {
console.log(err);
response.status(500).send(`Webhook Error`);
return;
}
},
);
```# Development Getting started
## Installation
> Clone this repository:
```bash
git clone https://github.com/epicdigitalmedia/epic-gigwage
```
### Open the directory and run the script line:```bash
cd epic-gigwage
```
```bash
yarn # or npm i
```## 🤝 Contributing
Contributions, issues and feature requests are welcome!
Feel free to check [issues page](issues).## Show your support
Give a ⭐️ if this project helped you!
[![codecov](https://codecov.io/gh/epicdigitalmedia/epic-gigwage/branch/main/graph/badge.svg?token=Q9fr548J0D)](https://codecov.io/gh/epicdigitalmedia/epic-gigwage)
## 📝 License
Copyright © 2022 [Epic Digital Interactive Media LLC](https://github.com/epicdigitalmedia).
This project is [MIT](LICENSE) licensed.