mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-23 23:06:06 +08:00
修复服务端ts类型检查
This commit is contained in:
parent
ff412c7497
commit
0141cd81c4
5
back/index.d.ts
vendored
Normal file
5
back/index.d.ts
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
declare namespace Express {
|
||||||
|
interface Request {
|
||||||
|
platform: 'desktop' | 'mobile';
|
||||||
|
}
|
||||||
|
}
|
|
@ -80,11 +80,7 @@ export default ({ app }: { app: Application }) => {
|
||||||
const data = fs.readFileSync(config.authConfigFile, 'utf8');
|
const data = fs.readFileSync(config.authConfigFile, 'utf8');
|
||||||
if (data) {
|
if (data) {
|
||||||
const { token = '', tokens = {} } = JSON.parse(data);
|
const { token = '', tokens = {} } = JSON.parse(data);
|
||||||
console.log(tokens);
|
|
||||||
console.log(req.platform);
|
|
||||||
console.log(tokens[req.platform]);
|
|
||||||
if (headerToken === token || tokens[req.platform] === headerToken) {
|
if (headerToken === token || tokens[req.platform] === headerToken) {
|
||||||
console.log('yes');
|
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,11 @@ import * as fs from 'fs';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import jwt from 'jsonwebtoken';
|
import jwt from 'jsonwebtoken';
|
||||||
import { authenticator } from '@otplib/preset-default';
|
import { authenticator } from '@otplib/preset-default';
|
||||||
import { exec } from 'child_process';
|
|
||||||
import DataStore from 'nedb';
|
import DataStore from 'nedb';
|
||||||
import { AuthDataType, AuthInfo, LoginStatus } from '../data/auth';
|
import { AuthDataType, AuthInfo, LoginStatus } from '../data/auth';
|
||||||
import { NotificationInfo } from '../data/notify';
|
import { NotificationInfo } from '../data/notify';
|
||||||
import NotificationService from './notify';
|
import NotificationService from './notify';
|
||||||
|
import { Request } from 'express';
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
export default class AuthService {
|
export default class AuthService {
|
||||||
|
|
6
typings.d.ts
vendored
6
typings.d.ts
vendored
|
@ -8,9 +8,3 @@ declare module '*.svg' {
|
||||||
const url: string;
|
const url: string;
|
||||||
export default url;
|
export default url;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare namespace Express {
|
|
||||||
export interface Request {
|
|
||||||
platform: 'desktop' | 'mobile';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user