Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
T
tx3-bang-reader
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
tx3-bang-reader
Commits
1b749299
Commit
1b749299
authored
Jul 02, 2020
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finish
parent
d4898080
Pipeline
#221
passed with stages
in 2 minutes and 9 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
5 deletions
+25
-5
README.md
README.md
+13
-1
config.example.yaml
config.example.yaml
+1
-0
src/fetcher.ts
src/fetcher.ts
+1
-0
src/run.ts
src/run.ts
+10
-4
No files found.
README.md
View file @
1b749299
# tx3-bang-reader
Read TX3 bang and parse it
Reads TX3 bang http://bang.tx3.163.com and parse it.
## How to use
*
`npm run build`
*
Create a
`config.yaml`
file based on
`config.example.yaml`
.
*
`npm run fetch`
## Docker image
You may also build a Docker image from the Dockerfile here. mount a
`config.yaml`
file into
`/usr/src/app`
.
\ No newline at end of file
config.example.yaml
View file @
1b749299
outDir
:
./output
useMySQL
:
false
server
:
null
# server name array if specific servers
MySQLConfig
:
host
:
mysql
user
:
tx3
...
...
src/fetcher.ts
View file @
1b749299
...
...
@@ -41,6 +41,7 @@ export const servers = [
export
interface
Config
{
outDir
:
string
;
server
:
string
[];
useMySQL
:
boolean
,
MySQLConfig
:
mysql
.
PoolConfig
,
proxy
:
ProxyConfig
...
...
src/run.ts
View file @
1b749299
...
...
@@ -7,7 +7,10 @@ let fetcher;
async
function
runServer
(
server
:
string
)
{
const
users
=
await
fetcher
.
fetchListFromServer
(
server
);
await
fs
.
promises
.
writeFile
(
`./output/servers/
${
server
}
.json`
,
JSON
.
stringify
(
users
,
null
,
2
));
await
fs
.
promises
.
writeFile
(
`./output/servers/
${
server
}
.json`
,
JSON
.
stringify
({
date
:
fetcher
.
date
,
data
:
users
},
null
,
2
));
return
users
;
}
...
...
@@ -22,8 +25,8 @@ async function main() {
const
config
:
Config
=
yaml
.
parse
(
await
fs
.
promises
.
readFile
(
"
./config.yaml
"
,
"
utf8
"
));
fetcher
=
new
Tx3Fetcher
(
config
);
await
fetcher
.
init
();
if
(
process
.
env
.
SERVER
)
{
await
runServer
(
servers
[
parseInt
(
process
.
env
.
SERVER
)]
);
if
(
config
.
server
)
{
await
Promise
.
all
(
config
.
server
.
map
(
runServer
)
);
return
;
}
const
userListWithServer
=
await
Promise
.
all
(
servers
.
map
(
runServer
));
...
...
@@ -31,7 +34,10 @@ async function main() {
for
(
let
i
=
0
;
i
<
servers
.
length
;
++
i
)
{
allServersList
[
servers
[
i
]]
=
userListWithServer
[
i
];
}
await
fs
.
promises
.
writeFile
(
`./output/all.json`
,
JSON
.
stringify
(
allServersList
,
null
,
2
));
await
fs
.
promises
.
writeFile
(
`./output/all.json`
,
JSON
.
stringify
({
date
:
fetcher
.
date
,
data
:
allServersList
},
null
,
2
));
process
.
exit
();
}
main
();
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment