Skip to content

Commit

Permalink
Add TypeScript definition (#46)
Browse files Browse the repository at this point in the history
Co-authored-by: Renée <renee@kooi.me>
  • Loading branch information
kidonng and goto-bus-stop committed Mar 20, 2023
1 parent 7938e5d commit 8cb72f6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var KeyvFirestore = require('keyv-firestore')

const keyv = new Keyv({
store: new KeyvFirestore({
// REQUIRED: the project id to use
// the project id to use
projectId: 'my-firebase-project',
// REQUIRED: the root collection to store things in
collection: 'firestore-db-collection'
Expand Down
19 changes: 19 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {Store} from 'keyv'

declare class KeyvFirestore<Value = any> implements Store<Value> {
constructor(options: {
projectId?: string
collection: string
// https://github.com/googleapis/nodejs-firestore/blob/207c9359e369b6838f026fd62ff56df39332dcff/dev/src/index.ts#L513-L518
credentials?: {
client_email: string
private_key: string
}
})
get(key: string): Value | Promise<Value | undefined> | undefined
set(key: string, value: Value, ttl?: number): any
delete(key: string): boolean | Promise<boolean>
clear(): void | Promise<void>
}

export = KeyvFirestore
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"devDependencies": {
"@keyv/test-suite": "^1.6.11",
"ava": "^5.2.0",
"keyv": "^4.0.0",
"standard": "^17.0.0"
},
"homepage": "https://github.com/goto-bus-stop/keyv-firestore",
Expand All @@ -24,6 +23,7 @@
],
"license": "Apache-2.0",
"main": "index.js",
"types": "index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/goto-bus-stop/keyv-firestore.git"
Expand All @@ -33,6 +33,9 @@
"test:lint": "standard",
"test": "standard && ava"
},
"peerDependencies": {
"keyv": "^3.0.0 || ^4.0.0"
},
"dependencies": {
"@google-cloud/firestore": "^6.5.0"
}
Expand Down

0 comments on commit 8cb72f6

Please sign in to comment.