Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Added Typings, updated docs #20

Merged
merged 9 commits into from
Oct 3, 2019
Merged

Refactor: Added Typings, updated docs #20

merged 9 commits into from
Oct 3, 2019

Conversation

Moebits
Copy link
Contributor

@Moebits Moebits commented Oct 3, 2019

What: I added typings for Typescript users, every function now returns either CamelCased types or snake_cased types depending on the value of camelcaseKeys. Example:

//const pixiv = new PixivAppApi(process.env.NAME, process.env.PASSWORD, {camelcaseKeys: true})
interface PixivClient = {
  accessToken: string
  expiresIn: number
  tokenType: string
  scope: string
  refreshToken: string
  user: PixivClientUser
  deviceToken: string
}

//const pixiv = new PixivAppApi(process.env.NAME, process.env.PASSWORD, {camelcaseKeys: false})
interface Pixiv_Client = {
  access_token: string
  expires_in: number
  token_type: string
  scope: string
  refresh_token: string
  user: Pixiv_Client_User
  device_token: string
}

Other changes:
-Removed almost every any type
-Changed all .then() chains to async/await
-Added the new endpoint /v1/ugoira/metadata
-Updated the docs

Broken endpoints:
-Some endpoints no longer work, I got this error while testing them: Specified end-point doesn't exist. I added comments to these functions, most notably they involve adding/deleting follows or bookmarks.
-I don't know what this function does nextQuery() since it always returns undefined. However, I left it as is.

Why: Using this library is a pain for Typescript users due to the lack of type definitions. Especially since it's written with Typescript, it should return types for all of the functions.

How: I added type definitions in these two files: PixivTypes.ts and Pixiv_Types.ts and I imported them in index.ts.

Checklist:

  • Documentation
  • Tests
  • Ready to be merged I would still double check the typings, since there are a lot and I could have missed some/incorrectly typed some.
  • Added myself to contributors table

@@ -0,0 +1,7795 @@
{
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove package-lock.json. use yarn.

@@ -2,8 +2,8 @@
"extends": "@akameco/tsconfig",
"compilerOptions": {
"outDir": "dist",
"strict": false,
"noImplicitAny": false
"strict": true,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

.prettierrc Outdated
"semi": false,
"singleQuote": true
"singleQuote": false,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep "singleQuote": true

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not change .prettierrc

src/index.ts Outdated
const filter = "for_ios"

export default class PixivApp<B extends boolean> {
public camelcaseKeys = true as B
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool 💯

@akameco akameco merged commit 72c580e into akameco:master Oct 3, 2019
@akameco
Copy link
Owner

akameco commented Oct 3, 2019

@Tenpi Thank you 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants