mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-15 00:55:55 +08:00
Refine project structure
This commit is contained in:
parent
bbe29a7fac
commit
6169ff5255
@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"ignorePatterns": ["*.min.js", "src/vendor/*.js"],
|
||||||
"env": {
|
"env": {
|
||||||
"browser": true,
|
"browser": true,
|
||||||
"es2021": true
|
"es2021": true
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { OpenAPI } from '../utils/open-api';
|
import { OpenAPI } from '../vendor/open-api';
|
||||||
|
|
||||||
const $ = new OpenAPI('sub-store');
|
const $ = new OpenAPI('sub-store');
|
||||||
export default $;
|
export default $;
|
||||||
|
@ -3,9 +3,9 @@ import {
|
|||||||
GIST_BACKUP_KEY,
|
GIST_BACKUP_KEY,
|
||||||
GIST_BACKUP_FILE_NAME,
|
GIST_BACKUP_FILE_NAME,
|
||||||
} from './constants';
|
} from './constants';
|
||||||
import { ENV } from '../utils/open-api';
|
import { ENV } from '../vendor/open-api';
|
||||||
import express from '../utils/express';
|
import express from '../vendor/express';
|
||||||
import { IP_API } from '../utils/geo';
|
import IP_API from '../utils/ip-api';
|
||||||
import Gist from '../utils/gist';
|
import Gist from '../utils/gist';
|
||||||
import $ from '../core/app';
|
import $ from '../core/app';
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ import registerArtifactRoutes from './artifacts';
|
|||||||
import registerSettingRoutes from './settings';
|
import registerSettingRoutes from './settings';
|
||||||
|
|
||||||
export default function serve() {
|
export default function serve() {
|
||||||
const $app = express();
|
const $app = express({ substore: $ });
|
||||||
|
|
||||||
// register routes
|
// register routes
|
||||||
registerCollectionRoutes($app);
|
registerCollectionRoutes($app);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { HTTP } from './open-api';
|
import { HTTP } from '../vendor/open-api';
|
||||||
|
|
||||||
const cache = new Map();
|
const cache = new Map();
|
||||||
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
import { HTTP } from './open-api';
|
|
||||||
|
|
||||||
// get proxy flag according to its name
|
// get proxy flag according to its name
|
||||||
export function getFlag(name) {
|
export function getFlag(name) {
|
||||||
// flags from @KOP-XIAO: https://github.com/KOP-XIAO/QuantumultX/blob/master/Scripts/resource-parser.js
|
// flags from @KOP-XIAO: https://github.com/KOP-XIAO/QuantumultX/blob/master/Scripts/resource-parser.js
|
||||||
@ -307,13 +305,3 @@ export function getFlag(name) {
|
|||||||
) || [])[0];
|
) || [])[0];
|
||||||
return oldFlag || '🏴☠️';
|
return oldFlag || '🏴☠️';
|
||||||
}
|
}
|
||||||
|
|
||||||
// util API
|
|
||||||
export async function IP_API(req, res) {
|
|
||||||
const server = decodeURIComponent(req.params.server);
|
|
||||||
const $http = HTTP();
|
|
||||||
const result = await $http
|
|
||||||
.get(`http://ip-api.com/json/${server}?lang=zh-CN`)
|
|
||||||
.then((resp) => JSON.parse(resp.body));
|
|
||||||
res.json(result);
|
|
||||||
}
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { HTTP } from './open-api';
|
import { HTTP } from '../vendor/open-api';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gist backup
|
* Gist backup
|
||||||
|
10
backend/src/utils/ip-api.js
Normal file
10
backend/src/utils/ip-api.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { HTTP } from '../vendor/open-api';
|
||||||
|
|
||||||
|
export default async function IP_API(req, res) {
|
||||||
|
const server = decodeURIComponent(req.params.server);
|
||||||
|
const $http = HTTP();
|
||||||
|
const result = await $http
|
||||||
|
.get(`http://ip-api.com/json/${server}?lang=zh-CN`)
|
||||||
|
.then((resp) => JSON.parse(resp.body));
|
||||||
|
res.json(result);
|
||||||
|
}
|
@ -1,8 +1,7 @@
|
|||||||
/* eslint-disable no-undef */
|
/* eslint-disable no-undef */
|
||||||
import { ENV } from './open-api';
|
import { ENV } from './open-api';
|
||||||
import $ from '../core/app';
|
|
||||||
|
|
||||||
export default function express({ port } = { port: 3000 }) {
|
export default function express({ substore: $, port } = { port: 3000 }) {
|
||||||
const { isNode } = ENV();
|
const { isNode } = ENV();
|
||||||
const DEFAULT_HEADERS = {
|
const DEFAULT_HEADERS = {
|
||||||
'Content-Type': 'text/plain;charset=UTF-8',
|
'Content-Type': 'text/plain;charset=UTF-8',
|
||||||
@ -212,6 +211,7 @@ export default function express({ port } = { port: 3000 }) {
|
|||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function patternMatched(pattern, path) {
|
function patternMatched(pattern, path) {
|
||||||
if (pattern instanceof RegExp && pattern.test(path)) {
|
if (pattern instanceof RegExp && pattern.test(path)) {
|
||||||
@ -283,4 +283,3 @@ export default function express({ port } = { port: 3000 }) {
|
|||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
4
backend/sub-store.min.js
vendored
4
backend/sub-store.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user