fix: fix library path load problem
This commit is contained in:
parent
f5f0a560f1
commit
c049a62493
@ -2,13 +2,11 @@ import { Router } from 'express';
|
||||
import { body, header, param, validate } from '../middleware/validate';
|
||||
import { recordServerStatus } from '../model/serverStatus';
|
||||
import fs from 'fs-extra';
|
||||
import path from 'path';
|
||||
import { libraryPath } from '../utils/lib';
|
||||
|
||||
export const serverStatusRouter = Router();
|
||||
|
||||
const installScript = fs.readFileSync(
|
||||
path.resolve(process.cwd(), '../../scripts/install.sh')
|
||||
);
|
||||
const installScript = fs.readFileSync(libraryPath.installScript);
|
||||
|
||||
serverStatusRouter.post(
|
||||
'/report',
|
||||
|
@ -11,8 +11,8 @@ import {
|
||||
MOBILE_OS,
|
||||
MOBILE_SCREEN_WIDTH,
|
||||
} from './const';
|
||||
import path from 'path';
|
||||
import maxmind, { Reader, CityResponse } from 'maxmind';
|
||||
import { libraryPath } from './lib';
|
||||
|
||||
let lookup: Reader<CityResponse>;
|
||||
|
||||
@ -104,9 +104,7 @@ export async function getLocation(ip: string, req: Request) {
|
||||
|
||||
// Database lookup
|
||||
if (!lookup) {
|
||||
const dir = path.join(process.cwd(), 'geo');
|
||||
|
||||
lookup = await maxmind.open(path.resolve(dir, 'GeoLite2-City.mmdb'));
|
||||
lookup = await maxmind.open(libraryPath.geoPath);
|
||||
}
|
||||
|
||||
const result = lookup.get(ip);
|
||||
|
6
src/server/utils/lib.ts
Normal file
6
src/server/utils/lib.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import path from 'path';
|
||||
|
||||
export const libraryPath = {
|
||||
installScript: path.resolve(process.cwd(), '../../scripts/install.sh'),
|
||||
geoPath: path.resolve(process.cwd(), '../../geo/GeoLite2-City.mmdb'),
|
||||
};
|
Loading…
Reference in New Issue
Block a user