Skip to content

Commit

Permalink
* Major version bump to 2.0.0
Browse files Browse the repository at this point in the history
* Convert to ESM (fixes tabletojson import error)
* Update dependency versions
* Remove broken functions due to API 404 so all tests pass (mbb getRankings, wbb getRankings, ncaa getTeamStats getScoringSummary)
* Re-gen README and Markdown docs
  • Loading branch information
baclap committed Feb 14, 2024
1 parent 0230907 commit c627940
Show file tree
Hide file tree
Showing 36 changed files with 435 additions and 961 deletions.
74 changes: 0 additions & 74 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,6 @@ Operations for Men's College Basketball.
* [.getBoxScore(id)](#mbb.getBoxScore)
* [.getSummary(id)](#mbb.getSummary)
* [.getPicks(id)](#mbb.getPicks)
* [.getRankings(year, week)](#mbb.getRankings)
* [.getPlayerRankings(year, page, group)](#mbb.getPlayerRankings)
* [.getSchoolRankings(year, page)](#mbb.getSchoolRankings)
* [.getSchoolCommits(year, school)](#mbb.getSchoolCommits)
Expand Down Expand Up @@ -460,25 +459,6 @@ Gets the Men's College Basketball game PickCenter data for a specified game.
```js
const result = await sdv.mbb.getPicks(401260281);
```
<a name="mbb.getRankings"></a>

### mbb.getRankings(year, week) ⇒
Gets the Men's College Basketball rankings data for a specified year and week if available.

**Kind**: static method of [<code>mbb</code>](#mbb)
**Returns**: json

| Param | Type | Description |
| --- | --- | --- |
| year | <code>\*</code> | Year (YYYY) |
| week | <code>\*</code> | Week |

**Example**
```js
const result = await sdv.mbb.getRankings(
year = 2020, week = 15
)
```
<a name="mbb.getPlayerRankings"></a>

### mbb.getPlayerRankings(year, page, group) ⇒
Expand Down Expand Up @@ -1042,8 +1022,6 @@ Operations for NCAA Sports.
* [.getInfo(game)](#ncaa.getInfo)
* [.getBoxScore(game)](#ncaa.getBoxScore)
* [.getPlayByPlay(game)](#ncaa.getPlayByPlay)
* [.getTeamStats(game)](#ncaa.getTeamStats)
* [.getScoringSummary(game)](#ncaa.getScoringSummary)
* [.getScoreboard(sport, division, year, month, day)](#ncaa.getScoreboard)
* [.getSports()](#ncaa.getSports)
* [.getSeasons(sport)](#ncaa.getSeasons)
Expand Down Expand Up @@ -1121,38 +1099,6 @@ Gets the play-by-play data for a specified game if available.
```js
const result = await sdv.ncaa.getPlayByPlay(5764053);
```
<a name="ncaa.getTeamStats"></a>

### ncaa.getTeamStats(game) ⇒
Gets the team stats data for a specified game if available.

**Kind**: static method of [<code>ncaa</code>](#ncaa)
**Returns**: json

| Param | Type | Description |
| --- | --- | --- |
| game | <code>number</code> | Game id. |

**Example**
```js
const result = await sdv.ncaa.getTeamStats(5764053);
```
<a name="ncaa.getScoringSummary"></a>

### ncaa.getScoringSummary(game) ⇒
Gets the scoring summary data for a specified game if available.

**Kind**: static method of [<code>ncaa</code>](#ncaa)
**Returns**: json

| Param | Type | Description |
| --- | --- | --- |
| game | <code>number</code> | Game id. |

**Example**
```js
const result = await sdv.ncaa.getScoringSummary(5764053);
```
<a name="ncaa.getScoreboard"></a>

### ncaa.getScoreboard(sport, division, year, month, day) ⇒
Expand Down Expand Up @@ -1682,7 +1628,6 @@ Operations for WBB.
* [.getPlayByPlay(id)](#wbb.getPlayByPlay)
* [.getBoxScore(id)](#wbb.getBoxScore)
* [.getSummary(id)](#wbb.getSummary)
* [.getRankings(year, week)](#wbb.getRankings)
* [.getSchedule(year, month, day, group, seasontype, limit)](#wbb.getSchedule)
* [.getScoreboard(year, month, day, group, seasontype, limit)](#wbb.getScoreboard)
* [.getConferences(year, group)](#wbb.getConferences)
Expand Down Expand Up @@ -1739,25 +1684,6 @@ Gets the Women's College Basketball game summary data for a specified game.
```js
const result = await sdv.wbb.getSummary(401260565);
```
<a name="wbb.getRankings"></a>

### wbb.getRankings(year, week) ⇒
Gets the WBB rankings data for a specified year and week if available.

**Kind**: static method of [<code>wbb</code>](#wbb)
**Returns**: json

| Param | Type | Description |
| --- | --- | --- |
| year | <code>\*</code> | Year (YYYY) |
| week | <code>\*</code> | Week |

**Example**
```js
const result = await sdv.wbb.getRankings(
year = 2021, week = 4
)
```
<a name="wbb.getSchedule"></a>

### wbb.getSchedule(year, month, day, group, seasontype, limit) ⇒
Expand Down
33 changes: 22 additions & 11 deletions app/app.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
import cfb from './services/cfb.service.js';
import mbb from './services/mbb.service.js';
import mlb from './services/mlb.service.js';
import nba from './services/nba.service.js';
import ncaa from './services/ncaa.service.js';
import nfl from './services/nfl.service.js';
import nhl from './services/nhl.service.js';
import tennis from './services/tennis.service.js';
import wbb from './services/wbb.service.js';
import wnba from './services/wnba.service.js';

module.exports.cfb = require('./services/cfb.service');
module.exports.mbb = require('./services/mbb.service');
module.exports.mlb = require('./services/mlb.service');
module.exports.nba = require('./services/nba.service');
module.exports.ncaa = require('./services/ncaa.service');
module.exports.nfl = require('./services/nfl.service');
module.exports.nhl = require('./services/nhl.service');
module.exports.tennis = require('./services/tennis.service');
module.exports.wbb = require('./services/wbb.service');
module.exports.wnba = require('./services/wnba.service');

export default {
cfb,
mbb,
mlb,
nba,
ncaa,
nfl,
nhl,
tennis,
wbb,
wnba
};
6 changes: 3 additions & 3 deletions app/services/cfb.service.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const axios = require('axios');
const cheerio = require('cheerio');
import axios from 'axios';
import cheerio from 'cheerio';
/**
* Operations for College Football.
*
* @namespace cfb
*/
module.exports = {
export default {
/**
* Gets the College Football game play-by-play data for a specified game.
* @memberOf cfb
Expand Down
38 changes: 3 additions & 35 deletions app/services/mbb.service.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const axios = require('axios');
const cheerio = require('cheerio');
import axios from 'axios';
import cheerio from 'cheerio';
/**
* Operations for Men's College Basketball.
*
* @namespace mbb
*/
module.exports = {
export default {
/**
* Gets the Men's College Basketball game play-by-play data for a specified game.
* @memberOf mbb
Expand Down Expand Up @@ -132,38 +132,6 @@ module.exports = {
standings: res.data.standings
};
},

/**
* Gets the Men's College Basketball rankings data for a specified year and week if available.
* @memberOf mbb
* @async
* @function
* @param {*} year - Year (YYYY)
* @param {*} week - Week
* @returns json
* @example
* const result = await sdv.mbb.getRankings(
* year = 2020, week = 15
* )
*/
getRankings: async function ({ year, week }) {
const baseUrl = 'http://cdn.espn.com/core/mens-college-basketball/rankings';
const params = {};

if (year) {
params.year = year;
}

if (week) {
params.week = week;
}

const res = await axios.get(baseUrl, {
params
});

return res.data;
},
/**
* Gets the Men's College Basketball Player recruiting data for a specified year, page, position and institution type if available.
* @memberOf mbb
Expand Down
4 changes: 2 additions & 2 deletions app/services/mlb.service.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const axios = require("axios");
import axios from 'axios';
/**
* Operations for MLB.
*
* @namespace mlb
*/
module.exports = {
export default {
/**
* Gets the MLB game play-by-play data for a specified game.
* @memberOf mlb
Expand Down
4 changes: 2 additions & 2 deletions app/services/nba.service.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const axios = require('axios');
import axios from 'axios';
/**
* Operations for NBA.
*
* @namespace nba
*/
module.exports = {
export default {
/**
* Gets the NBA game play-by-play data for a specified game.
* @memberOf nba
Expand Down
40 changes: 5 additions & 35 deletions app/services/ncaa.service.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const axios = require('axios');
const cheerio = require('cheerio');
const decode = require('decode-html');
const tabletojson = require("tabletojson").Tabletojson;
import axios from 'axios';
import cheerio from 'cheerio';
import decode from 'decode-html';
import { Tabletojson as tabletojson } from 'tabletojson';
/**
* Operations for NCAA Sports.
*
* @namespace ncaa
*/
module.exports = {
export default {
/**
* Gets the gameId for older games whose url redirects to the current url pattern using the
* game url fragment (relative to [https://ncaa.com](https://ncaa.com)) pulled from ncaaScoreboard
Expand Down Expand Up @@ -75,36 +75,6 @@ module.exports = {
const res = await axios.get(baseUrl);
return res.data;
},
/**
* Gets the team stats data for a specified game if available.
* @memberOf ncaa
* @async
* @function
* @param {number} game - Game id.
* @returns json
* @example
* const result = await sdv.ncaa.getTeamStats(5764053);
*/
getTeamStats: async function (game) {
const baseUrl = `https://data.ncaa.com/casablanca/game/${game}/teamStats.json`;
const res = await axios.get(baseUrl);
return res.data;
},
/**
* Gets the scoring summary data for a specified game if available.
* @memberOf ncaa
* @async
* @function
* @param {number} game - Game id.
* @returns json
* @example
* const result = await sdv.ncaa.getScoringSummary(5764053);
*/
getScoringSummary: async function (game) {
const baseUrl = `https://data.ncaa.com/casablanca/game/${game}/scoringSummary.json`;
const res = await axios.get(baseUrl);
return res.data;
},
/**
* Gets the scoreboard data for a specified date and team sport if available.
* @memberOf ncaa
Expand Down
4 changes: 2 additions & 2 deletions app/services/nfl.service.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const axios = require('axios');
import axios from 'axios';
/**
* Operations for NFL.
*
* @namespace nfl
*/
module.exports = {
export default {
/**
* Gets the NFL game play-by-play data for a specified game.
* @memberOf nfl
Expand Down
4 changes: 2 additions & 2 deletions app/services/nhl.service.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const axios = require('axios');
import axios from 'axios';
/**
* Operations for NHL.
*
* @namespace nhl
*/
module.exports = {
export default {
/**
* Gets the NHL game play-by-play data for a specified game.
* @memberOf nhl
Expand Down
4 changes: 2 additions & 2 deletions app/services/tennis.service.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const axios = require('axios');
import axios from 'axios';
/**
* Operations for Tennis.
*
* @namespace tennis
*/
module.exports = {
export default {
/**
* Gets the scoreboard data for a specified date and league if available.
* @memberOf tennis
Expand Down
39 changes: 2 additions & 37 deletions app/services/wbb.service.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const axios = require('axios');
import axios from 'axios';
/**
* Operations for WBB.
*
* @namespace wbb
*/
module.exports = {
export default {
/**
* Gets the Women's College Basketball game play-by-play data for a specified game.
* @memberOf wbb
Expand Down Expand Up @@ -97,41 +97,6 @@ module.exports = {

};
},
/**
* Gets the WBB rankings data for a specified year and week if available.
* @memberOf wbb
* @async
* @function
* @param {*} year - Year (YYYY)
* @param {*} week - Week
* @returns json
* @example
* const result = await sdv.wbb.getRankings(
* year = 2021, week = 4
* )
*/
getRankings: async function ({
year,
week
}) {
const baseUrl = 'http://cdn.espn.com/core/womens-college-basketball/rankings';
const params = {};

if (year) {
params.year = year;
}

if (week) {
params.week = week;
}

const res = await axios.get(baseUrl, {
params
});

return res.data;
},

/**
* Gets the Women's College Basketball schedule data for a specified date if available.
* @memberOf wbb
Expand Down
Loading

0 comments on commit c627940

Please sign in to comment.