diff --git a/app-init.gs b/app-init.gs index 3117561..509c302 100644 --- a/app-init.gs +++ b/app-init.gs @@ -24,8 +24,4 @@ function clearDataCache() { function clearSystemCache() { return app.clearSystemCache(); -} - -function generateSwaggerDoc() { - return app.generateSwaggerDoc(); } \ No newline at end of file diff --git a/core/common.ts b/core/common.ts index a88811b..2d48409 100644 --- a/core/common.ts +++ b/core/common.ts @@ -4,8 +4,8 @@ import { ServletRequest, ServletResponse, Filter, NotFoundHandler, LogLevel, ILo export class SimpleLogger implements ILogger { private minLevel: LogLevel; - constructor() { - this.minLevel = LogLevel.INFO; + constructor({ logLevel }: any) { + this.minLevel = logLevel || LogLevel.INFO; } setLogLevel(level: LogLevel): void { @@ -37,8 +37,8 @@ export class SimpleLogger implements ILogger { export class StackdriverLogger implements ILogger { private minLevel: LogLevel; - constructor() { - this.minLevel = LogLevel.INFO; + constructor({ logLevel }: any) { + this.minLevel = logLevel || LogLevel.INFO; } setLogLevel(level: LogLevel): void { diff --git a/www/api-gatekeeper.ts b/www/api-gatekeeper.ts index 26c7cee..839b909 100644 --- a/www/api-gatekeeper.ts +++ b/www/api-gatekeeper.ts @@ -61,12 +61,12 @@ export class ApiGatekeeper extends HttpFilter { // Authorization check let patterns = { 'get': [ - /^\/api\/(?[^\s\/]{2,36})\/?(?[^\s\/]{2,36})?(\/|$)/i + /^\/api\/(?[^\s\/]{1,36})\/?(?[^\s\/]{1,36})?(\/|$)/i ], 'post': [ - /^\/api\/(?(create))\/(?[^\s\/]{2,36})(\/|$)/i, - /^\/api\/(?(update|delete))\/(?[^\s\/]{2,36})\/?(?[^\s\/]{2,36})?(\/|$)/i, - /^\/api\/bulk\/(?(create|update|delete))\/(?[^\s\/]{2,36})(\/|$)/i + /^\/api\/(?(create))\/(?[^\s\/]{1,36})(\/|$)/i, + /^\/api\/(?(update|delete))\/(?[^\s\/]{1,36})\/?(?[^\s\/]{1,36})?(\/|$)/i, + /^\/api\/bulk\/(?(create|update|delete))\/(?[^\s\/]{1,36})(\/|$)/i ] }; let authorized = false; diff --git a/www/app.ts b/www/app.ts index 52c75f1..9199072 100644 --- a/www/app.ts +++ b/www/app.ts @@ -55,9 +55,8 @@ export function onOpen(e: any): void { var menuItems = [ { name: 'Authorize', functionName: 'authorizeScript' }, { name: 'Initialize Settings', functionName: 'initSettings' }, - { name: 'Clear System Cache', functionName: 'clearSystemCache' }, null, - { name: 'Generate Swagger Document', functionName: 'generateSwaggerDoc' } + { name: 'Clear System Cache', functionName: 'clearSystemCache' } ]; spreadsheet.addMenu(appName, menuItems); } @@ -147,7 +146,6 @@ export function generateSwaggerDoc(): SwaggerV2 { } function getConfig(): WebConfig { - let logLevel: any = PropertiesService.getScriptProperties().getProperty('app.logLevel') || LogLevel.INFO; let defaultRole: any = PropertiesService.getScriptProperties().getProperty('app.defaultRole'); let noFormat: any = PropertiesService.getScriptProperties().getProperty('app.query.no_format'); let limit: any = PropertiesService.getScriptProperties().getProperty('app.query.limit'); @@ -175,16 +173,16 @@ function getConfig(): WebConfig { method: 'GET', handler: 'ApiServlet', patterns: [ - /^\/api\/(?[^\s\/]{2,36})\/?(?[^\s\/]{2,36})?(\/|$)/i + /^\/api\/(?[^\s\/]{1,36})\/?(?[^\s\/]{1,36})?(\/|$)/i ] }, { method: 'POST', handler: 'ApiServlet', patterns: [ - /^\/api\/(?(create))\/(?[^\s\/]{2,36})(\/|$)/i, - /^\/api\/(?(update|delete))\/(?[^\s\/]{2,36})\/?(?[^\s\/]{2,36})?(\/|$)/i, - /^\/api\/bulk\/(?(create|update|delete))\/(?[^\s\/]{2,36})(\/|$)/i + /^\/api\/(?(create))\/(?[^\s\/]{1,36})(\/|$)/i, + /^\/api\/(?(update|delete))\/(?[^\s\/]{1,36})\/?(?[^\s\/]{1,36})?(\/|$)/i, + /^\/api\/bulk\/(?(create|update|delete))\/(?[^\s\/]{1,36})(\/|$)/i ] } ], @@ -214,12 +212,14 @@ function getConfig(): WebConfig { }; function getDI(): DependencyInjection { + let logLevel: any = PropertiesService.getScriptProperties().getProperty('app.logLevel') || LogLevel.INFO; return new DependencyInjection([ + { name: 'logLevel', useValue: logLevel }, { name: 'ServletRequest', useClass: HttpServletRequest }, { name: 'ServletResponse', useClass: HttpServletResponse }, { name: 'NotFoundHandler', useClass: ApiNotFoundHandler }, { name: 'IConfiguration', useClass: Configuration }, - { name: 'ILogger', useClass: StackdriverLogger, singleton: true }, + { name: 'ILogger', useClass: StackdriverLogger, deps: ['logLevel'], singleton: true }, { name: 'ICache', useClass: CacheProvider, deps: ['ILogger'] }, { name: 'IDataAdapter', useClass: SpreadsheetAdapter, deps: ['ICache'] }, { name: 'IQueryAdapter', useClass: QueryAdapter, deps: ['ILogger'] },