diff --git a/.github/workflows/tsc.yml b/.github/workflows/tsc.yml index b732d9f..be5d303 100644 --- a/.github/workflows/tsc.yml +++ b/.github/workflows/tsc.yml @@ -17,4 +17,4 @@ jobs: - name: install dependencies run: npm install - name: Build - run: npm run build \ No newline at end of file + run: npm run build:bot \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 90490c2..7e2f93e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,9 +2,10 @@ FROM node:19.5.0-alpine as build WORKDIR /app COPY package*.json ./ +COPY bot/package*.json ./bot/ RUN npm install COPY . . -RUN cd ./bot && npm run build +RUN npm run build:bot RUN npm prune --production diff --git a/bot/src/userData.ts b/bot/src/userData.ts index 37811ce..c6be554 100644 --- a/bot/src/userData.ts +++ b/bot/src/userData.ts @@ -3,6 +3,7 @@ const express = require('express'); // const fetch = require('node-fetch'); // you can fix this by using import instead of require import axios from 'axios'; +import { User } from './db'; // import User from './db.js'; import { saveUser, getUser } from './db'; @@ -51,7 +52,11 @@ app.get('/discord-oauth-callback', (req, res) => { }).then(res => { // console.log(res.data.id); // add user to database - saveUser(res.data.id, refresh_token) + const user = new User({ + id: res.data.id, + refresh_token: refresh_token, + }); + saveUser(user); }); }); res.redirect("/dashboard"); @@ -82,7 +87,11 @@ export const getAccessToken = async (userID, refresh_token) => { } }); // save the new refresh token - saveUser(userID, res.data.refresh_token); + const user = new User({ + id: res.data.id, + refresh_token: res.data.refresh_token, + }); + saveUser(user); return res.data.access_token; } diff --git a/package.json b/package.json index d3e24c1..d11639d 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "sqlite3": "^5.1.6" }, "scripts": { - "build": "cd bot && npm run build && cd ../web", + "build:bot": "cd bot && npm run build", "setup:bot": "npm install && cd bot && npm install && npm run build", "start:bot": "cd bot && npm start" },