1
0
Fork 0
mirror of https://github.com/seejohnrun/haste-server.git synced 2024-11-01 03:21:21 +00:00

fix lint issues of not added packages

This commit is contained in:
Yusuf Yilmaz 2022-06-08 14:26:00 +02:00
parent f8d61db716
commit 1698bfe0ec
8 changed files with 41 additions and 25 deletions

View file

@ -27,6 +27,7 @@
"@types/aws-sdk": "^2.7.0", "@types/aws-sdk": "^2.7.0",
"@types/busboy": "^1.5.0", "@types/busboy": "^1.5.0",
"@types/express": "^4.17.13", "@types/express": "^4.17.13",
"@types/google-cloud__datastore": "^1.3.6",
"@types/jest": "^27.5.1", "@types/jest": "^27.5.1",
"@types/memcached": "^2.2.7", "@types/memcached": "^2.2.7",
"@types/mongodb": "^4.0.7", "@types/mongodb": "^4.0.7",

View file

@ -1,5 +1,5 @@
import * as winston from 'winston' import * as winston from 'winston'
import AWS from 'aws-sdk' import AWS = require('aws-sdk')
import type { AmazonStoreConfig } from 'src/types/config' import type { AmazonStoreConfig } from 'src/types/config'
import { Callback } from 'src/types/callback' import { Callback } from 'src/types/callback'
import { Store } from '.' import { Store } from '.'

View file

@ -1,4 +1,4 @@
import { Datastore, PathType } from '@google-cloud/datastore' import Datastore = require('@google-cloud/datastore')
import * as winston from 'winston' import * as winston from 'winston'
import type { Callback } from 'src/types/callback' import type { Callback } from 'src/types/callback'
@ -19,7 +19,7 @@ class GoogleDatastoreDocumentStore extends Store {
// Save file in a key // Save file in a key
set = ( set = (
key: PathType, key: string,
data: string, data: string,
callback: Callback, callback: Callback,
skipExpire?: boolean skipExpire?: boolean
@ -56,13 +56,13 @@ class GoogleDatastoreDocumentStore extends Store {
} }
// Get a file from a key // Get a file from a key
get = (key: PathType, callback: Callback, skipExpire?: boolean): void => { get = (key: string, callback: Callback, skipExpire?: boolean): void => {
const taskKey = this.datastore.key([this.kind, key]) const taskKey = this.datastore.key([this.kind, key])
this.datastore this.datastore
.get(taskKey) .get(taskKey)
.then(entity => { .then(entity => {
if (skipExpire || entity[0].expiration == null) { if (skipExpire || entity[0]?.expiration == null) {
callback(entity[0].value) callback(entity[0].value)
} else if (entity[0].expiration < new Date()) { } else if (entity[0].expiration < new Date()) {
winston.info('document expired', { winston.info('document expired', {
@ -78,7 +78,7 @@ class GoogleDatastoreDocumentStore extends Store {
data: [ data: [
{ {
name: 'value', name: 'value',
value: entity[0].value, value: entity[0]?.value,
excludeFromIndexes: true excludeFromIndexes: true
}, },
{ {
@ -95,7 +95,7 @@ class GoogleDatastoreDocumentStore extends Store {
.catch(err => { .catch(err => {
winston.error('failed to update expiration', { error: err }) winston.error('failed to update expiration', { error: err })
}) })
callback(entity[0].value) callback(entity[0]?.value)
} }
}) })
.catch(err => { .catch(err => {

View file

@ -1,11 +1,13 @@
import * as winston from 'winston' import * as winston from 'winston'
import { MongoClient } from 'mongodb' import mongodb = require('mongodb')
import type { Callback } from 'src/types/callback' import type { Callback } from 'src/types/callback'
import type { MongoStoreConfig } from 'src/types/config' import type { MongoStoreConfig } from 'src/types/config'
import { Store } from '.' import { Store } from '.'
type ConnectCallback = (error?: Error, db?: MongoClient) => void const { MongoClient } = mongodb
type ConnectCallback = (error?: Error, db?: mongodb.MongoClient) => void
class MongoDocumentStore extends Store { class MongoDocumentStore extends Store {
connectionUrl: string connectionUrl: string

View file

@ -1,19 +1,21 @@
import * as winston from 'winston' import * as winston from 'winston'
import { Pool, PoolClient } from 'pg' import Pg = require('pg')
import type { Callback } from 'src/types/callback' import type { Callback } from 'src/types/callback'
import type { PostgresStoreConfig } from 'src/types/config' import type { PostgresStoreConfig } from 'src/types/config'
import { Store } from '.' import { Store } from '.'
const { Pool } = Pg
type ConnectCallback = ( type ConnectCallback = (
error?: Error, error?: Error,
client?: PoolClient, client?: Pg.PoolClient,
done?: () => void done?: () => void
) => void ) => void
// A postgres document store // A postgres document store
class PostgresDocumentStore extends Store { class PostgresDocumentStore extends Store {
pool: Pool pool: Pg.Pool
constructor(options: PostgresStoreConfig) { constructor(options: PostgresStoreConfig) {
super(options) super(options)
@ -23,14 +25,16 @@ class PostgresDocumentStore extends Store {
// A connection wrapper // A connection wrapper
safeConnect = (callback: ConnectCallback) => { safeConnect = (callback: ConnectCallback) => {
this.pool.connect((error: Error, client: PoolClient, done: () => void) => { this.pool.connect(
if (error) { (error: Error, client: Pg.PoolClient, done: () => void) => {
winston.error('error connecting to postgres', { error }) if (error) {
callback(error) winston.error('error connecting to postgres', { error })
} else { callback(error)
callback(undefined, client, done) } else {
callback(undefined, client, done)
}
} }
}) )
} }
// Get a given key's data // Get a given key's data

View file

@ -1,11 +1,13 @@
import * as winston from 'winston' import * as winston from 'winston'
import { createClient } from 'redis' import redis = require('redis')
import { bool } from 'aws-sdk/clients/redshiftdata'
import type { Callback } from 'src/types/callback' import type { Callback } from 'src/types/callback'
import { RedisStoreConfig } from 'src/types/config' import { RedisStoreConfig } from 'src/types/config'
import { Store } from '.' import { Store } from '.'
export type RedisClientType = ReturnType<typeof createClient> const { createClient } = redis
export type RedisClientType = ReturnType<typeof redis.createClient>
// For storing in redis // For storing in redis
// options[type] = redis // options[type] = redis
@ -68,7 +70,7 @@ class RedisDocumentStore extends Store {
}) })
} }
getExpire = (skipExpire?: bool) => (!skipExpire ? { EX: this.expire } : {}) getExpire = (skipExpire?: boolean) => (!skipExpire ? { EX: this.expire } : {})
get = (key: string, callback: Callback): void => { get = (key: string, callback: Callback): void => {
this.client this.client

View file

@ -1,7 +1,7 @@
import * as winston from 'winston' import * as winston from 'winston'
import * as crypto from 'crypto' import * as crypto from 'crypto'
import rethink, { RethinkClient } from 'rethinkdbdash' import rethink = require('rethinkdbdash')
import type { RethinkDbStoreConfig } from 'src/types/config' import type { RethinkDbStoreConfig } from 'src/types/config'
import type { Callback } from 'src/types/callback' import type { Callback } from 'src/types/callback'
@ -14,7 +14,7 @@ const md5 = (str: string) => {
} }
class RethinkDBStore extends Store { class RethinkDBStore extends Store {
client: RethinkClient client: rethink.RethinkClient
constructor(options: RethinkDbStoreConfig) { constructor(options: RethinkDbStoreConfig) {
super(options) super(options)

View file

@ -763,6 +763,13 @@
"@types/minimatch" "*" "@types/minimatch" "*"
"@types/node" "*" "@types/node" "*"
"@types/google-cloud__datastore@^1.3.6":
version "1.3.6"
resolved "https://registry.yarnpkg.com/@types/google-cloud__datastore/-/google-cloud__datastore-1.3.6.tgz#33b2c65c1b797279e57ed5ac96966bebb9c6500b"
integrity sha512-92yEN/b5tkdNT+9l0BscP5uUQLk9h+aHH21TkHi7ITbXnRIPBs2lmV5dbmDVKkQRXHLiCdLv0zfk8xgfYqSGpg==
dependencies:
"@types/node" "*"
"@types/graceful-fs@^4.1.3": "@types/graceful-fs@^4.1.3":
version "4.1.5" version "4.1.5"
resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.5.tgz#21ffba0d98da4350db64891f92a9e5db3cdb4e15" resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.5.tgz#21ffba0d98da4350db64891f92a9e5db3cdb4e15"