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

chore: type check #231

Merged
merged 3 commits into from
Aug 24, 2024
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
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "Chat Game",
"image": "mcr.microsoft.com/devcontainers/typescript-node:20",
"image": "mcr.microsoft.com/devcontainers/typescript-node:22",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "npm i -g [email protected] && pnpm install",
"postCreateCommand": "npm i -g [email protected] && pnpm i",

// Configure tool-specific properties.
"customizations": {
Expand Down
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
max_line_length = off
trim_trailing_whitespace = false
3 changes: 0 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# Go to Twitch developer console
NUXT_PUBLIC_TWITCH_CLIENT_ID=""
NUXT_TWITCH_SECRET_ID=""

NUXT_OAUTH_TWITCH_CLIENT_ID=""
NUXT_OAUTH_TWITCH_CLIENT_SECRET=""

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ Let's build a similar world together! ⭐️ Become a Stargazer ⭐️

- [PixiJS](https://pixijs.com/): The HTML5 Creation Engine.
- [Twurple](https://twurple.js.org/): A set of libraries that aims to cover all existing Twitch APIs.
- [Vue](https://vuejs.org/): An approachable, performant and versatile framework for building web user interfaces.
- [Nuxt](https://nuxt.com/): An open source framework that makes web development intuitive and powerful.
- [Prisma](https://www.prisma.io/orm): Next-generation Node.js and TypeScript ORM.
- [Howler.js](https://howlerjs.com/): Audio library for the modern web.
- [Turborepo](https://turbo.build/repo/docs): High-performance build system for JavaScript and TypeScript codebases.
- [TypeScript](https://www.typescriptlang.org/): A strongly typed programming language that builds on JavaScript, giving you better tooling at any scale.
- [ESLint](https://eslint.org/): Statically analyzes a code to quickly find problems.

Expand Down
6 changes: 0 additions & 6 deletions apps/website/app/components/MenuProfile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,12 @@
</template>

<script setup lang="ts">
const { public: publicEnv } = useRuntimeConfig()
const { isFeedOpened } = useApp()
const { loggedIn, user } = useUserSession()

function handleMenuClick() {
isFeedOpened.value = !isFeedOpened.value
}

const url = new URL('https://id.twitch.tv/oauth2/authorize')
url.searchParams.set('client_id', publicEnv.twitchClientId)
url.searchParams.set('redirect_uri', publicEnv.signInRedirectUrl)
url.searchParams.set('response_type', 'code')
</script>

<style scoped>
Expand Down
10 changes: 2 additions & 8 deletions apps/website/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,14 @@ export default defineNuxtConfig({
runtimeConfig: {
websiteBearer: '', // NUXT_WEBSITE_BEARER
jwtSecretKey: '', // NUXT_JWT_SECRET_KEY
twitchSecretId: '', // NUXT_TWITCH_SECRET_ID
twitchChannelName: '', // NUXT_TWITCH_CHANNEL_NAME
twitchChannelId: '', // NUXT_TWITCH_CHANNEL_ID
twitchOauthCode: '', // NUXT_TWITCH_OAUTH_CODE
yookassaShopId: '', // NUXT_YOOKASSA_SHOP_ID
yookassaApiKey: '', // NUXT_YOOKASSA_API_KEY
oauth: {
twitch: {
clientId: '',
clientSecret: '',
},
},
oauthTwitchClientId: '', // NUXT_OAUTH_TWITCH_CLIENT_ID
oauthTwitchClientSecret: '', // NUXT_OAUTH_TWITCH_CLIENT_SECRET
public: {
twitchClientId: '', // NUXT_PUBLIC_TWITCH_CLIENT_ID
signInRedirectUrl: '', // NUXT_PUBLIC_SIGN_IN_REDIRECT_URL
cookieKey: '', // NUXT_PUBLIC_COOKIE_KEY
},
Expand Down
2 changes: 1 addition & 1 deletion apps/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"clean:modules": "rm -rf .turbo .nuxt node_modules",
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"typecheck": "nuxt typecheck",
"typecheck": "prisma generate && nuxt typecheck",
"postinstall": "nuxt prepare",
"db:generate": "prisma generate"
},
Expand Down
4 changes: 2 additions & 2 deletions apps/website/server/api/auth/twitch3.get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ export default defineEventHandler(async (event) => {
})

async function obtainTwitchAccessToken(code: string) {
const { public: publicEnv, twitchSecretId } = useRuntimeConfig()
const { public: publicEnv, oauthTwitchClientId, oauthTwitchClientSecret } = useRuntimeConfig()

try {
const response = await fetch(
`https://id.twitch.tv/oauth2/token?client_id=${publicEnv.twitchClientId}&client_secret=${twitchSecretId}&code=${code}&grant_type=authorization_code&redirect_uri=${publicEnv.signInRedirectUrl}`,
`https://id.twitch.tv/oauth2/token?client_id=${oauthTwitchClientId}&client_secret=${oauthTwitchClientSecret}&code=${code}&grant_type=authorization_code&redirect_uri=${publicEnv.signInRedirectUrl}`,
{
method: 'POST',
},
Expand Down
5 changes: 2 additions & 3 deletions apps/website/server/api/twitch/code/index.post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,11 @@ export default defineEventHandler<EventHandlerRequest, Promise<TokenCreateRespon
)

async function obtainTwitchAccessToken(code: string, redirectUrl: string) {
const { public: publicEnv, twitchSecretId } = useRuntimeConfig()
const clientId = publicEnv.twitchClientId
const { oauthTwitchClientSecret, oauthTwitchClientId } = useRuntimeConfig()

try {
const response = await fetch(
`https://id.twitch.tv/oauth2/token?client_id=${clientId}&client_secret=${twitchSecretId}&code=${code}&grant_type=authorization_code&redirect_uri=${redirectUrl}`,
`https://id.twitch.tv/oauth2/token?client_id=${oauthTwitchClientId}&client_secret=${oauthTwitchClientSecret}&code=${code}&grant_type=authorization_code&redirect_uri=${redirectUrl}`,
{
method: 'POST',
},
Expand Down
10 changes: 3 additions & 7 deletions apps/website/server/utils/twitch/twitch.addon.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,9 @@ class TwitchAddonController {
token: string
}) {
const strings = text.split(' ')

if (!strings?.length) {
return
}

const firstChar = strings[0].charAt(0)
const possibleCommand = strings[0].substring(1)
const firstWord = strings[0] ?? ''
const firstChar = firstWord.charAt(0)
const possibleCommand = firstWord.substring(1)
const otherStrings = strings.toSpliced(0, 1)

const profile = await this.#repository.findOrCreateProfile({ userId, userName })
Expand Down
6 changes: 3 additions & 3 deletions apps/website/server/utils/twitch/twitch.ai.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class TwitchAiController {
constructor() {
this.#repository = new DBRepository()

const { public: publicEnv, twitchSecretId } = useRuntimeConfig()
this.#clientId = publicEnv.twitchClientId
this.#clientSecret = twitchSecretId
const { oauthTwitchClientSecret, oauthTwitchClientId } = useRuntimeConfig()
this.#clientId = oauthTwitchClientId
this.#clientSecret = oauthTwitchClientSecret

void this.#init()
}
Expand Down
7 changes: 4 additions & 3 deletions apps/website/server/utils/twitch/twitch.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ class TwitchProvider {
const {
public: publicEnv,
twitchChannelId,
twitchSecretId,
oauthTwitchClientId,
oauthTwitchClientSecret,
twitchOauthCode,
} = useRuntimeConfig()
this.#userId = twitchChannelId.toString()
this.#clientSecret = twitchSecretId
this.#clientSecret = oauthTwitchClientSecret
this.#code = twitchOauthCode
this.#clientId = publicEnv.twitchClientId
this.#clientId = oauthTwitchClientId
this.#redirectUrl = publicEnv.signInRedirectUrl

void this.getAuthProvider()
Expand Down
12 changes: 5 additions & 7 deletions apps/website/server/utils/twitch/twitch.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@ export class TwitchService {
text: string
}) {
const strings = text.split(' ')
if (!strings?.length) {
return
}

const firstChar = strings[0].charAt(0)
const possibleCommand = strings[0].substring(1)
const firstWord = strings[0] ?? ''
const firstChar = firstWord.charAt(0)
const possibleCommand = firstWord.substring(1)
const otherStrings = strings.toSpliced(0, 1)
const firstParam = otherStrings[0] ?? ''

const profile = await this.#repository.findProfileByTwitchId(userId)
if (!profile) {
Expand All @@ -44,7 +42,7 @@ export class TwitchService {

if (firstChar === '!' && possibleCommand) {
if (possibleCommand === 'купон' || possibleCommand === 'coupon') {
return this.handleCouponActivation(otherStrings[0], player.profileId)
return this.handleCouponActivation(firstParam, player.profileId)
}
if (possibleCommand === 'инвентарь' || possibleCommand === 'inventory') {
return this.handleInventoryCommand(player.profileId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,9 @@ class TwitchWoodlandController {
token: string
}) {
const strings = text.split(' ')
if (!strings?.length) {
return
}

const firstChar = strings[0].charAt(0)
const possibleCommand = strings[0].substring(1)
const firstWord = strings[0] ?? ''
const firstChar = firstWord.charAt(0)
const possibleCommand = firstWord.substring(1)
const otherStrings = strings.toSpliced(0, 1)

const woodland = await this.#repository.findActiveWoodland(token)
Expand Down
24 changes: 0 additions & 24 deletions tsconfig.base.json

This file was deleted.

Loading