https://github.com/codam-coding-college/42-connector
This Node module interfaces with the 42 API --> https://api.intra.42.fr
https://github.com/codam-coding-college/42-connector
Last synced: 8 months ago
JSON representation
This Node module interfaces with the 42 API --> https://api.intra.42.fr
- Host: GitHub
- URL: https://github.com/codam-coding-college/42-connector
- Owner: codam-coding-college
- Created: 2022-06-21T11:36:52.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-06-23T13:45:01.000Z (about 4 years ago)
- Last Synced: 2025-01-06T23:51:19.508Z (over 1 year ago)
- Language: TypeScript
- Size: 26.4 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 42-connector
This Node module interfaces with the 42 API --> https://api.intra.42.fr
## Usage
### Installation
`npm i --save https://github.com/codam-coding-college/42-connector.git`
or if you want a specific version:
`npm i --save https://github.com/codam-coding-college/42-connector.git#3.0.0`
## Code example
```typescript
import { API } from '42-connector'
const api = new API(clientUID, clientSecret)
const response: Response = await api.get('/v2/achievements')
console.log(response)
const post_response: Response = await api.post('/v2/feedbacks', {
'feedback[comment]': 'Much good, such wow',
'feedback[feedback_details_attributes][rate]': 2,
'feedback[feedback_details_attributes][kind]': 'interesting',
})
const delete_response: Response = await api.delete('/v2/events_users/:id')
const allPages: Response = await api.getPaged('/v2/achievements_users', (singlePage) => {
console.log(singlePage)
})
```
### Using options
```typescript
import { API } from '42-connector'
const defaultOptions = {
maxRequestPerSecond: 1 / 3, // The default unprivileged intra app can do 1200 requests per hour, or 1/3 per second
logging: false, // Nice for debugging and logging
root: 'https://api.intra.42.fr', // The url with which to prefix every request
timeout: 2147483647 // Maximum time to wait for intra to give a 2xx response before throwing an error
}
const api = new API(clientUID, clientSecret, defaultOptions)
const response: Response = await api.get('/v2/achievements')
console.log(response)
```