Skip to content

Commit

Permalink
重构为typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
realhuhu committed Aug 2, 2024
1 parent 880df05 commit e4613cd
Show file tree
Hide file tree
Showing 60 changed files with 2,456 additions and 2,257 deletions.
3 changes: 2 additions & 1 deletion node-proxy/.env
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
RUN_MODE=DEV
RUN_MODE=DEV
LOG_LEVEL=debug
5 changes: 2 additions & 3 deletions node-proxy/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ module.exports = {

function prettierrc() {
const prettierrc_id = require.resolve('./.prettierrc')
var stat = fs.statSync(prettierrc_id)
const stat = fs.statSync(prettierrc_id)
if (stat.mtimeMs > (process.prettierrc_file_mtimeMs || 0)) {
process.prettierrc_file_mtimeMs = stat.mtimeMs
require.cache[prettierrc_id] = undefined
}
const conf = require('./.prettierrc')
return conf
return require('./.prettierrc')
}
344 changes: 0 additions & 344 deletions node-proxy/app.js

This file was deleted.

32 changes: 32 additions & 0 deletions node-proxy/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import path from 'path'
import http from 'http'

import Koa from 'koa'
import serve from 'koa-static'

import { logger } from '@/common/logger'
import alisRouter from '@/router/alist'
import otherRouter from '@/router/other'
import webdavRouter from '@/router/webdav'
import staticRouter from '@/router/static'
import webuiRouter from '@/router/webui'
import { exceptionMiddleware, loggerMiddleware } from '@/middleware/common'

const app = new Koa()

app.use(loggerMiddleware)
app.use(exceptionMiddleware)
app.use(serve(path.dirname(process.argv[1]), { root: 'public' }))
app.use(alisRouter.routes())
app.use(webuiRouter.routes())
app.use(webdavRouter.routes())
app.use(staticRouter.routes())
app.use(otherRouter.routes())

const server = http.createServer(app.callback())
server.maxConnections = 1000
server.listen(5343, () => logger.info('服务启动成功: ' + 5343))

setInterval(() => {
logger.debug('server_connections', server.connections, Date.now())
}, 600 * 1000)
Loading

0 comments on commit e4613cd

Please sign in to comment.