-
-
Notifications
You must be signed in to change notification settings - Fork 685
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(fs): support standalone domain for fs bucket;
- Loading branch information
Showing
12 changed files
with
129 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* @Author: Maslow<[email protected]> | ||
* @Date: 2021-07-30 10:30:29 | ||
* @LastEditTime: 2021-12-24 13:34:48 | ||
* @LastEditTime: 2021-12-27 11:18:10 | ||
* @Description: | ||
*/ | ||
|
||
|
@@ -11,22 +11,23 @@ import { v4 as uuidv4 } from 'uuid' | |
import Config from './config' | ||
import { router } from './router/index' | ||
import { logger } from './lib/logger' | ||
import { DatabaseAgent } from './lib/db-agent' | ||
|
||
const server = express() | ||
server.use(express.json({ | ||
const app = express() | ||
app.use(express.json({ | ||
limit: '10000kb' | ||
}) as any) | ||
|
||
|
||
server.all('*', function (_req, res, next) { | ||
app.all('*', function (_req, res, next) { | ||
res.header('X-Powered-By', 'LaF Server') | ||
next() | ||
}) | ||
|
||
/** | ||
* Parsing bearer token | ||
*/ | ||
server.use(function (req, _res, next) { | ||
app.use(function (req, _res, next) { | ||
const token = splitBearerToken(req.headers['authorization'] ?? '') | ||
const auth = parseToken(token) || null | ||
req['auth'] = auth | ||
|
@@ -37,9 +38,9 @@ server.use(function (req, _res, next) { | |
next() | ||
}) | ||
|
||
server.use(router) | ||
app.use(router) | ||
|
||
server.listen(Config.PORT, () => logger.info(`listened on ${Config.PORT}`)) | ||
const server = app.listen(Config.PORT, () => logger.info(`listened on ${Config.PORT}`)) | ||
|
||
|
||
process.on('unhandledRejection', (reason, promise) => { | ||
|
@@ -48,4 +49,15 @@ process.on('unhandledRejection', (reason, promise) => { | |
|
||
process.on('uncaughtException', err => { | ||
logger.error(`Caught uncaughtException:`, err) | ||
}) | ||
}) | ||
|
||
|
||
process.on('SIGTERM', gracefullyExit) | ||
process.on('SIGINT', gracefullyExit) | ||
|
||
async function gracefullyExit() { | ||
DatabaseAgent.sys_accessor.close() | ||
server.close(async () => { | ||
logger.info('process gracefully exited!') | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* @Author: Maslow<[email protected]> | ||
* @Date: 2021-08-30 15:22:34 | ||
* @LastEditTime: 2021-09-17 16:30:27 | ||
* @LastEditTime: 2021-12-27 11:39:53 | ||
* @Description: | ||
*/ | ||
|
||
|
@@ -76,6 +76,8 @@ export async function handleGetApplicationByAppid(req: Request, res: Response) { | |
|
||
const app_deploy_host = Config.APP_SERVICE_DEPLOY_HOST | ||
const app_deploy_url_schema = Config.APP_SERVICE_DEPLOY_URL_SCHEMA | ||
const storage_deploy_host = Config.STORAGE_SERVICE_CONFIG.deploy_host | ||
const storage_deploy_url_schema = Config.STORAGE_SERVICE_CONFIG.schema | ||
|
||
app.config = undefined | ||
return res.send({ | ||
|
@@ -86,7 +88,9 @@ export async function handleGetApplicationByAppid(req: Request, res: Response) { | |
debug_token, | ||
file_token, | ||
app_deploy_host, | ||
app_deploy_url_schema | ||
app_deploy_url_schema, | ||
storage_deploy_host, | ||
storage_deploy_url_schema | ||
} | ||
}) | ||
} |