mirror of
https://github.com/sasjs/server.git
synced 2026-01-09 15:30:05 +00:00
38 lines
872 B
TypeScript
38 lines
872 B
TypeScript
import express from 'express'
|
|
import { Request, Security, Route, Tags, Example, Get } from 'tsoa'
|
|
|
|
export interface InfoResponse {
|
|
mode: string
|
|
cors: string
|
|
whiteList: string[]
|
|
protocol: 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'
|
|
})
|
|
@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(' ') ?? [],
|
|
protocol: process.env.PROTOCOL ?? 'http'
|
|
}
|
|
return response
|
|
}
|
|
}
|