[express-mysql-session] Improve typings (#43436)

* [express-mysql-session] Improve typings

* [express-mysql-session] Revert unneeded changes

* [express-mysql-session] Update version header

* Revert "[express-mysql-session] Update version header"

This reverts commit a6a15b97f6496603370df36dfdcdffb5ad0a601f.

* [express-mysql-session] Use better name in all() callback
This commit is contained in:
Jeroen Akkerman 2020-03-30 16:51:36 -07:00 committed by GitHub
parent ff1063a5ee
commit d08665f370
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 9 deletions

View File

@ -9,8 +9,15 @@ const options = {
user: 'root',
password: '',
database: 'session_test',
schema: {
columnNames: {
data: 'content',
},
},
};
const sessionStore = new MySQLStore(options);
sessionStore.close();
sessionStore.get('my-session-id', (error, session) => {});
sessionStore.all();

View File

@ -1,6 +1,8 @@
// Type definitions for express-mysql-session 2.1
// Project: https://github.com/chill117/express-mysql-session#readme
// Definitions by: Akim95 <https://github.com/Akim95>, Sebastian Krüger <https://github.com/mathe42>
// Definitions by: Akim95 <https://github.com/Akim95>
// Sebastian Krüger <https://github.com/mathe42>
// Ionaru <https://github.com/Ionaru>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import * as expressSession from 'express-session';
@ -20,17 +22,19 @@ declare namespace MySQLStore {
expiration?: number;
createDatabaseTable?: boolean;
connectionLimit?: number;
schema?: Schema;
schema?: Partial<Schema>;
}
interface Schema {
tableName: string;
columnNames: ColumnNames;
columnNames: Partial<ColumnNames>;
}
interface ColumnNames {
session_id: string;
expires: string;
data: string;
}
type MySQLStore = MySQLStoreClass;
}
declare class MySQLStoreClass {
@ -38,6 +42,10 @@ declare class MySQLStoreClass {
setDefaultOptions(): void;
setOptions(options: MySQLStore.Options): void;
validateOptions(options: MySQLStore.Options): void;
createDatabaseTable(callback?: (error: any) => void): void;
get(sessionId: string, callback?: (error: any, session: any) => void): void;
@ -50,19 +58,17 @@ declare class MySQLStoreClass {
length(callback?: (error: any, count: any) => void): void;
all(callback?: (error: any, sessions: any) => void): void;
clear(callback?: (error: any) => void): void;
clearExpiredSessions(callback?: (error: any) => void): void;
query(sql: string, params: any, callback?: (error: any, rows: any, fields: any) => void): void;
setExpirationInterval(interval: number): void;
clearExpirationInterval(): void;
close(callback?: () => void): void;
default(object: any, defaultValues: any, options?: any): void;
clone(object: any): void;
isObject(value: any): void;
}