mirror of
https://github.com/seejohnrun/haste-server.git
synced 2025-12-20 09:41:28 +00:00
convert optional fiels to required fields
This commit is contained in:
@@ -12,11 +12,11 @@ class DocumentHandler {
|
||||
|
||||
maxLength?: number
|
||||
|
||||
public store?: Store
|
||||
public store: Store
|
||||
|
||||
keyGenerator: KeyGenerator
|
||||
|
||||
config?: Config
|
||||
config: Config
|
||||
|
||||
constructor(options: Document) {
|
||||
this.keyLength = options.keyLength || constants.DEFAULT_KEY_LENGTH
|
||||
@@ -28,9 +28,9 @@ class DocumentHandler {
|
||||
|
||||
public handleGet(request: Request, response: Response) {
|
||||
const key = request.params.id.split('.')[0]
|
||||
const skipExpire = !!this.config?.documents[key]
|
||||
const skipExpire = !!this.config.documents[key]
|
||||
|
||||
this.store?.get(
|
||||
this.store.get(
|
||||
key,
|
||||
ret => {
|
||||
if (ret) {
|
||||
@@ -74,7 +74,7 @@ class DocumentHandler {
|
||||
}
|
||||
// And then save if we should
|
||||
this.chooseKey(key => {
|
||||
this.store?.set(key, buffer, res => {
|
||||
this.store.set(key, buffer, res => {
|
||||
if (res) {
|
||||
winston.verbose('added document', { key })
|
||||
response.writeHead(200, { 'content-type': 'application/json' })
|
||||
@@ -123,9 +123,9 @@ class DocumentHandler {
|
||||
|
||||
public handleRawGet(request: Request, response: Response) {
|
||||
const key = request.params.id.split('.')[0]
|
||||
const skipExpire = !!this.config?.documents[key]
|
||||
const skipExpire = !!this.config.documents[key]
|
||||
|
||||
this.store?.get(
|
||||
this.store.get(
|
||||
key,
|
||||
ret => {
|
||||
if (ret) {
|
||||
@@ -157,7 +157,7 @@ class DocumentHandler {
|
||||
|
||||
if (!key) return
|
||||
|
||||
this.store?.get(
|
||||
this.store.get(
|
||||
key,
|
||||
(ret: string | boolean) => {
|
||||
if (ret) {
|
||||
|
||||
Reference in New Issue
Block a user