Skip to content

Commit

Permalink
fix: update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
rfoel committed Oct 15, 2021
1 parent b33f4ae commit 31a6418
Show file tree
Hide file tree
Showing 21 changed files with 4,283 additions and 8,283 deletions.
49 changes: 49 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"extends": [
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:prettier/recommended"
],
"parserOptions": {
"project": "./tsconfig.json"
},
"plugins": ["@typescript-eslint", "prettier", "import"],
"parser": "@typescript-eslint/parser",
"env": { "node": true, "browser": true },
"rules": {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-return": "off",
"prettier/prettier": [
"error",
{
"bracketSpacing": true,
"printWidth": 80,
"semi": false,
"singleQuote": true,
"trailingComma": "all",
"arrowParens": "always",
"endOfLine": "auto"
}
],
"import/order": [
"error",
{
"alphabetize": {
"order": "asc"
},
"groups": [
"builtin",
"external",
"internal",
"parent",
"sibling",
"index"
],
"newlines-between": "always"
}
]
}
}
10 changes: 0 additions & 10 deletions jest.config.js

This file was deleted.

12,186 changes: 4,118 additions & 8,068 deletions package-lock.json

Large diffs are not rendered by default.

38 changes: 22 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,33 @@
"scripts": {
"build": "rm -rf dist && microbundle --tsconfig tsconfig.json",
"dev": "microbundle watch --tsconfig tsconfig.json",
"lint": "tslint --project \".\"",
"test": "jest"
"lint": "eslint ."
},
"dependencies": {
"node-fetch": "^2.6.1"
"isomorphic-fetch": "^3.0.0"
},
"devDependencies": {
"@semantic-release/changelog": "^5.0.1",
"@semantic-release/commit-analyzer": "^8.0.1",
"@semantic-release/git": "^9.0.0",
"@semantic-release/github": "^7.1.1",
"@semantic-release/npm": "^7.0.6",
"@semantic-release/release-notes-generator": "^9.0.1",
"@types/node-fetch": "^2.5.7",
"jest": "^26.6.3",
"microbundle": "^0.13.0",
"nock": "^13.0.5",
"semantic-release": "^17.3.0",
"ts-jest": "^26.4.4",
"@semantic-release/changelog": "^6.0.0",
"@semantic-release/commit-analyzer": "^9.0.1",
"@semantic-release/git": "^10.0.0",
"@semantic-release/github": "^8.0.1",
"@semantic-release/npm": "^8.0.0",
"@semantic-release/release-notes-generator": "^10.0.2",
"@types/isomorphic-fetch": "0.0.35",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"eslint": "^8.0.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-prettier": "^4.0.0",
"jest": "^27.2.5",
"microbundle": "^0.14.1",
"nock": "^13.1.3",
"prettier": "^2.4.1",
"semantic-release": "^18.0.0",
"ts-jest": "^27.0.6",
"tslint": "^6.1.3",
"typescript": "^4.0.5"
"typescript": "^4.4.4"
},
"files": [
"dist"
Expand Down
4 changes: 2 additions & 2 deletions src/errors.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export class StravaError {
errors: any
errors: unknown
message: string
status: number
statusText: string

constructor(error: Response, data: any) {
constructor(error: Response, data: Record<string, string>) {
this.errors = data.errors
this.message = data.message
this.status = error.status
Expand Down
26 changes: 13 additions & 13 deletions src/models/subscriptionEvent.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { ActivityType } from '../enums/activityType';
import { ActivityType } from '../enums/activityType'

export interface SubscriptionEvent {
object_type: 'activity' | 'athlete'
object_id: number
aspect_type: 'create' | 'update' | 'delete',
updates: {
title?: string
type?: ActivityType
private?: boolean
authorized?: false
}
owner_id: number
subscription_id: number
event_time: number
object_type: 'activity' | 'athlete'
object_id: number
aspect_type: 'create' | 'update' | 'delete'
updates: {
title?: string
type?: ActivityType
private?: boolean
authorized?: false
}
owner_id: number
subscription_id: number
event_time: number
}
6 changes: 3 additions & 3 deletions src/models/zones.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HeartRateZoneRanges, PowerZoneRanges } from '.';
import { HeartRateZoneRanges, PowerZoneRanges } from '.'

export interface Zones {
heart_rate: HeartRateZoneRanges;
power: PowerZoneRanges;
heart_rate: HeartRateZoneRanges
power: PowerZoneRanges
}
20 changes: 12 additions & 8 deletions src/request.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import fetch from 'node-fetch'
import 'isomorphic-fetch'

import { StravaError } from './errors'
import { RefreshTokenRequest, RefreshTokenResponse } from './types'

type RequestParams = {
query?: any
body?: any
query?: Record<string, unknown>
body?: Record<string, unknown>
}

export class Request {
Expand Down Expand Up @@ -39,7 +39,7 @@ export class Request {
throw response
}

this.response = await response.json()
this.response = (await response.json()) as RefreshTokenResponse
}
return this.response
}
Expand All @@ -51,8 +51,12 @@ export class Request {
): Promise<Response> {
try {
await this.getAccessToken()

const query: string = new URLSearchParams(params?.query).toString()
const query: string = new URLSearchParams(
Object.entries(params).reduce(
(acc, [key, value]) => ({ ...acc, [key]: String(value) }),
{},
),
).toString()
const response = await fetch(
`https://www.strava.com/api/v3${uri}?${query}`,
{
Expand All @@ -70,10 +74,10 @@ export class Request {
}

if (response.status !== 204) {
return await response.json()
return (await response.json()) as Promise<Response>
}
} catch (error) {
const data = await error.json()
const data = (await error.json()) as Record<string, string>
switch (error.status) {
case 400:
case 401:
Expand Down
12 changes: 10 additions & 2 deletions src/resources/activities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
DetailedActivity,
Lap,
SummaryActivity,
SummaryAthlete
SummaryAthlete,
} from '../models'
import { Request } from '../request'

Expand All @@ -21,44 +21,52 @@ type CreateActivityRequest = {
}

type GetActivityByIdRequest = {
[key: string]: string | number | boolean
id: number
include_all_efforts?: boolean
}

type GetCommentsByActivityIdRequest = {
[key: string]: string | number | boolean
id: number
page?: number
per_page?: number
}

type GetKudoersByActivityIdRequest = {
[key: string]: string | number | boolean
id: number
page?: number
per_page?: number
}

type GetLapsByActivityIdRequest = {
[key: string]: string | number | boolean
id: number
}

type GetPhotosByActivityIdRequest = {
[key: string]: string | number | boolean
id: number
photo_sources?: boolean
size?: number
}

type GetZonesByActivityIdRequest = {
[key: string]: string | number | boolean
id: number
}

type GetLoggedInAthleteActivitiesRequest = {
[key: string]: string | number | boolean
before?: number
after?: number
page?: number
per_page?: number
}

type UpdateActivityByIdRequest = {
[key: string]: string | number | boolean
id: number
name: string
type: ActivityType
Expand All @@ -73,7 +81,7 @@ type UpdateActivityByIdRequest = {
export class Activities {
private readonly request: Request

constructor(request) {
constructor(request: Request) {
this.request = request
}

Expand Down
2 changes: 1 addition & 1 deletion src/resources/athletes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type UpdateLoggedInAthleteRequest = {
export class Athletes {
private readonly request: Request

constructor(request) {
constructor(request: Request) {
this.request = request
}

Expand Down
6 changes: 5 additions & 1 deletion src/resources/clubs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,26 @@ import {
import { Request } from '../request'

type GetClubActivitiesByIdRequest = {
[key: string]: string | number | boolean
id: number
page?: number
per_page?: number
}

type GetClubAdminsByIdRequest = {
[key: string]: string | number | boolean
id: number
page?: number
per_page?: number
}

type GetClubByIdRequest = {
[key: string]: string | number | boolean
id: number
}

type GetClubMembersByIdRequest = {
[key: string]: string | number | boolean
id: number
page?: number
per_page?: number
Expand All @@ -36,7 +40,7 @@ type getLoggedInAthleteClubsRequest = {
export class Clubs {
private readonly request: Request

constructor(request) {
constructor(request: Request) {
this.request = request
}

Expand Down
2 changes: 1 addition & 1 deletion src/resources/gears.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type getGearByIdRequest = {
export class Gears {
private readonly request: Request

constructor(request) {
constructor(request: Request) {
this.request = request
}

Expand Down
3 changes: 2 additions & 1 deletion src/resources/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type GetRouteByIdRequest = {
}

type GetRoutesByAthleteIdRequest = {
[key: string]: string | number | boolean
id: number
page?: number
per_page?: number
Expand All @@ -22,7 +23,7 @@ type GetRoutesByAthleteIdRequest = {
export class Routes {
private readonly request: Request

constructor(request) {
constructor(request: Request) {
this.request = request
}

Expand Down
2 changes: 1 addition & 1 deletion src/resources/runningRaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type GetRunningRacesRequest = {
export class RunningRaces {
private readonly request: Request

constructor(request) {
constructor(request: Request) {
this.request = request
}

Expand Down
2 changes: 1 addition & 1 deletion src/resources/segmentEfforts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type getSegmentEffortByIdRequest = {
export class SegmentEfforts {
private readonly request: Request

constructor(request) {
constructor(request: Request) {
this.request = request
}

Expand Down
3 changes: 2 additions & 1 deletion src/resources/segments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ type GetSegmentByIdRequest = {
}

type StarSegmentRequest = {
[key: string]: string | number | boolean
id: number
starred: boolean
}

export class Segments {
private readonly request: Request

constructor(request) {
constructor(request: Request) {
this.request = request
}

Expand Down
Loading

0 comments on commit 31a6418

Please sign in to comment.