diff --git a/types/keyv__mongo/index.d.ts b/types/keyv__mongo/index.d.ts new file mode 100644 index 0000000000..f468f3530b --- /dev/null +++ b/types/keyv__mongo/index.d.ts @@ -0,0 +1,33 @@ +// Type definitions for @keyv/mongo 1.0 +// Project: https://github.com/lukechilds/keyv-mongo +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +/// + +import { Store } from 'keyv'; +import { EventEmitter } from 'events'; + +export = KeyvMongo; + +declare class KeyvMongo extends EventEmitter implements Store { + readonly ttlSupport: false; + namespace?: string; + + constructor(uri?: string); + constructor(options?: KeyvMongo.Options); // tslint:disable-line:unified-signatures + + get(key: string): Promise; + set(key: string, value: TValue, ttl?: number): Promise; + delete(key: string): Promise; + clear(): Promise; +} + +declare namespace KeyvMongo { + interface Options { + uri?: string; + url?: string; + collection?: string; + } +} diff --git a/types/keyv__mongo/keyv__mongo-tests.ts b/types/keyv__mongo/keyv__mongo-tests.ts new file mode 100644 index 0000000000..6e8d1ea971 --- /dev/null +++ b/types/keyv__mongo/keyv__mongo-tests.ts @@ -0,0 +1,12 @@ +import Keyv = require('keyv'); +import KeyvMongo = require('@keyv/mongo'); + +new Keyv('mongodb://user:pass@localhost:27017/dbname', { collection: 'cache' }); + +new KeyvMongo({ uri: 'mongodb://user:pass@localhost:27017/dbname' }); +new KeyvMongo({ url: 'mongodb://user:pass@localhost:27017/dbname' }); +new KeyvMongo({ collection: 'cache' }); +new KeyvMongo('mongodb://user:pass@localhost:27017/dbname'); + +const mongo = new KeyvMongo('mongodb://user:pass@localhost:27017/dbname'); +new Keyv({ store: mongo }); diff --git a/types/keyv__mongo/tsconfig.json b/types/keyv__mongo/tsconfig.json new file mode 100644 index 0000000000..ca38c4e787 --- /dev/null +++ b/types/keyv__mongo/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "paths": { + "@keyv/mongo": [ + "keyv__mongo" + ] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "keyv__mongo-tests.ts" + ] +} diff --git a/types/keyv__mongo/tslint.json b/types/keyv__mongo/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/keyv__mongo/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }