mirror of
https://github.com/sasjs/server.git
synced 2025-12-10 19:34:34 +00:00
40 lines
929 B
TypeScript
40 lines
929 B
TypeScript
import { Route, Tags, Example, Get } from 'tsoa'
|
|
|
|
export interface InfoResponse {
|
|
mode: string
|
|
cors: string
|
|
whiteList: string[]
|
|
protocol: string
|
|
runTimes: string[]
|
|
}
|
|
|
|
@Route('SASjsApi/info')
|
|
@Tags('Info')
|
|
export class InfoController {
|
|
/**
|
|
* @summary Get server info (mode, cors, whiteList, protocol).
|
|
*
|
|
*/
|
|
@Example<InfoResponse>({
|
|
mode: 'desktop',
|
|
cors: 'enable',
|
|
whiteList: ['http://example.com', 'http://example2.com'],
|
|
protocol: 'http',
|
|
runTimes: ['sas', 'js']
|
|
})
|
|
@Get('/')
|
|
public info(): InfoResponse {
|
|
const response = {
|
|
mode: process.env.MODE ?? 'desktop',
|
|
cors:
|
|
process.env.CORS ||
|
|
(process.env.MODE === 'server' ? 'disable' : 'enable'),
|
|
whiteList:
|
|
process.env.WHITELIST?.split(' ')?.filter((url) => !!url) ?? [],
|
|
protocol: process.env.PROTOCOL ?? 'http',
|
|
runTimes: process.runTimes
|
|
}
|
|
return response
|
|
}
|
|
}
|