Skip to content

Commit

Permalink
Hotfix for id with length 1
Browse files Browse the repository at this point in the history
  • Loading branch information
gslack-app committed Apr 29, 2020
1 parent 677a097 commit 47eb3ff
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 20 deletions.
4 changes: 0 additions & 4 deletions app-init.gs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,4 @@ function clearDataCache() {

function clearSystemCache() {
return app.clearSystemCache();
}

function generateSwaggerDoc() {
return app.generateSwaggerDoc();
}
8 changes: 4 additions & 4 deletions core/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions www/api-gatekeeper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ export class ApiGatekeeper extends HttpFilter {
// Authorization check
let patterns = {
'get': [
/^\/api\/(?<resource>[^\s\/]{2,36})\/?(?<id>[^\s\/]{2,36})?(\/|$)/i
/^\/api\/(?<resource>[^\s\/]{1,36})\/?(?<id>[^\s\/]{1,36})?(\/|$)/i
],
'post': [
/^\/api\/(?<action>(create))\/(?<resource>[^\s\/]{2,36})(\/|$)/i,
/^\/api\/(?<action>(update|delete))\/(?<resource>[^\s\/]{2,36})\/?(?<id>[^\s\/]{2,36})?(\/|$)/i,
/^\/api\/bulk\/(?<action>(create|update|delete))\/(?<resource>[^\s\/]{2,36})(\/|$)/i
/^\/api\/(?<action>(create))\/(?<resource>[^\s\/]{1,36})(\/|$)/i,
/^\/api\/(?<action>(update|delete))\/(?<resource>[^\s\/]{1,36})\/?(?<id>[^\s\/]{1,36})?(\/|$)/i,
/^\/api\/bulk\/(?<action>(create|update|delete))\/(?<resource>[^\s\/]{1,36})(\/|$)/i
]
};
let authorized = false;
Expand Down
16 changes: 8 additions & 8 deletions www/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -175,16 +173,16 @@ function getConfig(): WebConfig {
method: 'GET',
handler: 'ApiServlet',
patterns: [
/^\/api\/(?<resource>[^\s\/]{2,36})\/?(?<id>[^\s\/]{2,36})?(\/|$)/i
/^\/api\/(?<resource>[^\s\/]{1,36})\/?(?<id>[^\s\/]{1,36})?(\/|$)/i
]
},
{
method: 'POST',
handler: 'ApiServlet',
patterns: [
/^\/api\/(?<action>(create))\/(?<resource>[^\s\/]{2,36})(\/|$)/i,
/^\/api\/(?<action>(update|delete))\/(?<resource>[^\s\/]{2,36})\/?(?<id>[^\s\/]{2,36})?(\/|$)/i,
/^\/api\/bulk\/(?<action>(create|update|delete))\/(?<resource>[^\s\/]{2,36})(\/|$)/i
/^\/api\/(?<action>(create))\/(?<resource>[^\s\/]{1,36})(\/|$)/i,
/^\/api\/(?<action>(update|delete))\/(?<resource>[^\s\/]{1,36})\/?(?<id>[^\s\/]{1,36})?(\/|$)/i,
/^\/api\/bulk\/(?<action>(create|update|delete))\/(?<resource>[^\s\/]{1,36})(\/|$)/i
]
}
],
Expand Down Expand Up @@ -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'] },
Expand Down

0 comments on commit 47eb3ff

Please sign in to comment.