Skip to content

Commit

Permalink
add nfl state endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
jameson-athanasiou committed Sep 18, 2022
1 parent 6ef8fcf commit 3adcd7d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ module.exports = {
rules: {
camelcase: 0,
'@typescript-eslint/semi': ['error', 'never'],
'no-shadow': 'off',
'@typescript-eslint/no-shadow': ['error'],
'import/extensions': 0,
'import/prefer-default-export': 0,
indent: ['error', 2],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jathanasiou/sleeper-api",
"version": "0.1.1",
"version": "0.2.0",
"description": "",
"exports": "./dist/index.js",
"main": "dist/index.js",
Expand Down
28 changes: 28 additions & 0 deletions src/apis/nfl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import axios from 'axios'
import { baseUrlV1 } from '../config'

enum SeasonType {
pre,
post,
regular,
}

type NFLStatus = {
week: number
season_type: SeasonType
season_start_date: string
season: string
previous_season: string
leg: number
league_season: string
league_create_season: string
display_week: number
}

export type GetNFLStatus = () => Promise<NFLStatus>

export const getNFLStatus: GetNFLStatus = async () => {
const url = `${baseUrlV1}/state/nfl`
const result = await axios.get(url)
return result.data
}
5 changes: 5 additions & 0 deletions test/static/getNFLStatus.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { getNFLStatus } from '../../src/apis/nfl'

getNFLStatus().then((res) => {
console.log(res)
})

0 comments on commit 3adcd7d

Please sign in to comment.