修复内置token获取

This commit is contained in:
whyour 2022-07-18 15:41:53 +08:00
parent 999b5d325f
commit 42dabbf4c0
5 changed files with 19 additions and 16 deletions

View File

@ -27,16 +27,4 @@ async function startServer() {
await require('./loaders/server').default({ server });
}
function initEnv() {
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
// 声明QL_DIR环境变量
let qlHomePath = path.join(__dirname, '../../');
// 生产环境
if (qlHomePath.endsWith('/static/')) {
qlHomePath = path.join(qlHomePath, '../');
}
process.env.QL_DIR = qlHomePath;
}
initEnv();
startServer();

View File

@ -2,6 +2,15 @@ import dotenv from 'dotenv';
import path from 'path';
import { createRandomString } from './util';
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
// 声明QL_DIR环境变量
let qlHomePath = path.join(__dirname, '../../');
// 生产环境
if (qlHomePath.endsWith('/static/')) {
qlHomePath = path.join(qlHomePath, '../');
}
process.env.QL_DIR = qlHomePath;
const lastVersionFile = `http://qn.whyour.cn/version.ts?v=${Date.now()}`;
const envFound = dotenv.config();

View File

@ -170,6 +170,7 @@ export default class OpenService {
client_secret: systemApp.client_secret,
});
token = authToken.data;
token.value = token.token;
} else {
token = [...systemApp.tokens].pop();
}

View File

@ -1,9 +1,9 @@
import 'reflect-metadata';
import OpenService from '../back/services/open';
import OpenService from './services/open';
import { Container } from 'typedi';
import LoggerInstance from '../back/loaders/logger';
import LoggerInstance from './loaders/logger';
import fs from 'fs';
import config from '../back/config';
import config from './config';
import path from 'path';
const tokenFile = path.join(config.configPath, 'token.json');

View File

@ -1,7 +1,12 @@
#!/usr/bin/env bash
get_token() {
token=$(ts-node-transpile-only "$dir_shell/token.ts")
local tokenFile="$dir_static/build/token.js"
if [[ ! -f "$tokenFile" ]]; then
token=$(ts-node-transpile-only "$dir_root/back/token.ts")
else
token=$(node "$tokenFile")
fi
}
add_cron_api() {