1
0
mirror of https://github.com/sasjs/server.git synced 2026-04-10 07:33:13 +00:00

fix(api-cdrive-oller): throw erow error when file not found

This commit is contained in:
2021-10-25 05:51:46 +00:00
parent 70a8aaf600
commit 03d1d60660
4 changed files with 45 additions and 21 deletions

View File

@@ -0,0 +1,19 @@
import { fileExists, readFile, createFile } from '@sasjs/utils'
export class DriveController {
async readFile(filePath: string) {
await this.validateFilePath(filePath)
return await readFile(filePath)
}
async updateFile(filePath: string, fileContent: string) {
await this.validateFilePath(filePath)
return await createFile(filePath, fileContent)
}
private async validateFilePath(filePath: string) {
if (!(await fileExists(filePath))) {
throw 'DriveController: File does not exists.'
}
}
}

View File

@@ -1,5 +1,5 @@
export * from './deploy'
export * from './sasjsDrive'
export * from './Drive'
export * from './Session'
export * from './Execution'
export * from './FileUploadController'

View File

@@ -1,15 +0,0 @@
import { fileExists, readFile, createFile } from '@sasjs/utils'
export class SASjsDriveController {
async readFile(filePath: string) {
if (await fileExists(filePath)) {
return await readFile(filePath)
}
}
async updateFile(filePath: string, fileContent: string) {
if (await fileExists(filePath)) {
return await createFile(filePath, fileContent)
}
}
}