Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .eslintrc.yml

This file was deleted.

45 changes: 12 additions & 33 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,31 @@ name: CI
on:
push:
branches:
- "**"
tags-ignore:
- "**"
- master
pull_request:

jobs:
lint:
ci:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x]
node-version: [22.x]

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
- name: Install
run: |
yarn
- name: Lint
run: |
yarn lint:prettier
yarn lint:eslint
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x]

needs: lint

steps:
- uses: actions/checkout@v3
version: 10
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
cache: "pnpm"
- name: Install
run: |
yarn
pnpm i
- name: Lint
run: pnpm check
- name: Build
run: |
yarn build
run: pnpm build
5 changes: 0 additions & 5 deletions .prettierrc

This file was deleted.

4 changes: 1 addition & 3 deletions anilist-codegen.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
schema: ./anilist-schema.json
documents: ./gql-documents/anilist/*.gql
generates:
./src/aniListGql.ts:
./src/generated/aniListGql.ts:
plugins:
- add:
content: "/* eslint-disable */"
- typescript
- typescript-operations
- typescript-graphql-request
Expand Down
24,514 changes: 24,513 additions & 1 deletion anilist-schema.json

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions annict-codegen.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
schema: ./annict-schema.gql
documents: ./gql-documents/annict/*.gql
config:
namingConvention: ./annictGqlNaming.js
namingConvention: ./annictGqlNaming.ts
generates:
./src/annictGql.ts:
./src/generated/annictGql.ts:
plugins:
- add:
content: "/* eslint-disable */"
- typescript
- typescript-operations
- typescript-graphql-request
Expand Down
File renamed without changes.
54 changes: 54 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"$schema": "https://biomejs.dev/schemas/2.1.2/schema.json",
"vcs": { "enabled": false, "clientKind": "git", "useIgnoreFile": false },
"files": {
"ignoreUnknown": false,
"includes": [
"src/**/*",
"!src/generated/**/*",
"anilist*",
"annict*",
"*.json",
".github/**/*",
"gql-documents/**/*",
"netlify/**/*",
"*.ts"
]
},
"formatter": {
"enabled": true,
"formatWithErrors": false,
"indentStyle": "space",
"indentWidth": 2,
"lineEnding": "lf",
"lineWidth": 80,
"attributePosition": "auto",
"bracketSameLine": false,
"bracketSpacing": true,
"expand": "auto",
"useEditorconfig": true
},
"linter": {
"enabled": true,
"rules": { "recommended": true },
"domains": { "react": "recommended" }
},
"javascript": {
"formatter": {
"jsxQuoteStyle": "double",
"quoteProperties": "asNeeded",
"trailingCommas": "es5",
"semicolons": "asNeeded",
"arrowParentheses": "always",
"bracketSameLine": false,
"quoteStyle": "double",
"attributePosition": "auto",
"bracketSpacing": true
}
},
"html": { "formatter": { "selfCloseVoidElements": "always" } },
"assist": {
"enabled": true,
"actions": { "source": { "organizeImports": "on" } }
}
}
18 changes: 16 additions & 2 deletions gql-documents/anilist/lib.gql
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
query queryLibrary($userId: Int!, $sort: [MediaListSort!]!, $perChunk: Int!, $chunk: Int!, $status: MediaListStatus!) {
MediaListCollection(userId: $userId, sort: $sort, perChunk: $perChunk, chunk: $chunk, type: ANIME, forceSingleCompletedList: true, status: $status) {
query queryLibrary(
$userId: Int!
$sort: [MediaListSort!]!
$perChunk: Int!
$chunk: Int!
$status: MediaListStatus!
) {
MediaListCollection(
userId: $userId
sort: $sort
perChunk: $perChunk
chunk: $chunk
type: ANIME
forceSingleCompletedList: true
status: $status
) {
lists {
entries {
id
Expand Down
12 changes: 6 additions & 6 deletions gql-documents/anilist/me.gql
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
query getMe {
Viewer {
id
name
avatar {
large
}
Viewer {
id
name
avatar {
large
}
}
}
38 changes: 27 additions & 11 deletions gql-documents/anilist/update.gql
Original file line number Diff line number Diff line change
@@ -1,17 +1,33 @@
mutation createMediaStatus($id: Int!, $status: MediaListStatus!, $numWatchedEpisodes: Int!) {
SaveMediaListEntry(mediaId: $id, status: $status, progress: $numWatchedEpisodes) {
id
}
mutation createMediaStatus(
$id: Int!
$status: MediaListStatus!
$numWatchedEpisodes: Int!
) {
SaveMediaListEntry(
mediaId: $id
status: $status
progress: $numWatchedEpisodes
) {
id
}
}

mutation updateMediaStatus($id: Int!, $status: MediaListStatus!, $numWatchedEpisodes: Int!) {
UpdateMediaListEntries(ids: [$id], status: $status, progress: $numWatchedEpisodes) {
id
}
mutation updateMediaStatus(
$id: Int!
$status: MediaListStatus!
$numWatchedEpisodes: Int!
) {
UpdateMediaListEntries(
ids: [$id]
status: $status
progress: $numWatchedEpisodes
) {
id
}
}

mutation deleteMediaStatus($id: Int!) {
DeleteMediaListEntry(id: $id) {
deleted
}
DeleteMediaListEntry(id: $id) {
deleted
}
}
27 changes: 17 additions & 10 deletions netlify/functions/anilist-callback.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
import { Handler } from "@netlify/functions"
import type { Handler, HandlerResponse } from "@netlify/functions"
import axios from "axios"
import cookie from "cookie"

const handler: Handler = async (event) => {
const clientId = process.env.VITE_ANILIST_CLIENT_ID
const clientSecret = process.env.ANILIST_CLIENT_SECRET
const deployUrl = process.env.DEPLOY_PRIME_URL
if (!clientId || !clientSecret || !deployUrl) {
throw new Error("Missing environment variables")
}
const redirectUrl = `${deployUrl}/.netlify/functions/anilist-callback`

const handler: Handler = async (event): Promise<HandlerResponse> => {
if (!event.queryStringParameters) {
return { statusCode: 400 }
}
const { code, state, error } = event.queryStringParameters
if (typeof error === "string") {
return {
statusCode: 403,
body: "access denied.",
headers: {
Location: "/",
},
}
}
if (typeof code !== "string" || typeof state !== "string") {
Expand All @@ -32,9 +40,9 @@ const handler: Handler = async (event) => {
new URLSearchParams({
grant_type: "authorization_code",
code,
client_id: process.env.VITE_ANILIST_CLIENT_ID,
client_secret: process.env.ANILIST_CLIENT_SECRET,
redirect_uri: process.env.VITE_ANILIST_REDIRECT_URL,
client_id: clientId,
client_secret: clientSecret,
redirect_uri: redirectUrl,
code_verifier: challange,
}),
{
Expand All @@ -46,15 +54,14 @@ const handler: Handler = async (event) => {
if (typeof result.data.access_token !== "string") {
return {
statusCode: 400,
body: "try again",
}
}
return {
statusCode: 200,
headers: {
"Content-Type": "text/html",
},
body: `<script>localStorage.setItem("ANILIST_ACCESS_TOKEN", ${JSON.stringify(result.data.access_token)});history.replaceState({}, document.title, "/");location.reload()</script>`
body: `<script>localStorage.setItem("ANILIST_ACCESS_TOKEN", ${JSON.stringify(result.data.access_token)});history.replaceState({}, document.title, "/");location.reload()</script>`,
}
}

Expand Down
26 changes: 17 additions & 9 deletions netlify/functions/annict-callback.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
import { Handler } from "@netlify/functions"
import type { Handler, HandlerResponse } from "@netlify/functions"
import axios from "axios"

const handler: Handler = async (event) => {
const clientId = process.env.VITE_ANNICT_CLIENT_ID
const clientSecret = process.env.ANNICT_CLIENT_SECRET
const deployUrl = process.env.DEPLOY_PRIME_URL
if (!clientId || !clientSecret || !deployUrl) {
throw new Error("Missing environment variables")
}
const redirectUrl = `${deployUrl}/.netlify/functions/annict-callback`

const handler: Handler = async (event): Promise<HandlerResponse> => {
if (!event.queryStringParameters) {
return { statusCode: 400 }
}
const { code, error } = event.queryStringParameters
if (typeof error === "string") {
return {
statusCode: 403,
body: "access denied.",
headers: {
Location: "/",
},
}
}
if (typeof code !== "string") {
Expand All @@ -23,9 +31,9 @@ const handler: Handler = async (event) => {
{
grant_type: "authorization_code",
code,
client_id: process.env.VITE_ANNICT_CLIENT_ID,
client_secret: process.env.ANNICT_CLIENT_SECRET,
redirect_uri: process.env.VITE_ANNICT_REDIRECT_URL,
client_id: clientId,
client_secret: clientSecret,
redirect_uri: redirectUrl,
},
{
headers: {
Expand All @@ -44,7 +52,7 @@ const handler: Handler = async (event) => {
headers: {
"Content-Type": "text/html",
},
body: `<script>localStorage.setItem("ANNICT_ACCESS_TOKEN", ${JSON.stringify(result.data.access_token)});history.replaceState({}, document.title, "/");location.reload()</script>`
body: `<script>localStorage.setItem("ANNICT_ACCESS_TOKEN", ${JSON.stringify(result.data.access_token)});history.replaceState({}, document.title, "/");location.reload()</script>`,
}
}

Expand Down
Loading