Skip to content

Commit

Permalink
remove sessionExists method, not actually used
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs224 committed Sep 22, 2023
1 parent fa68dca commit 44610c8
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 38 deletions.
4 changes: 0 additions & 4 deletions src/stores/MemoryStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ export default class MemoryStore implements Store {
this.data = new Map
}

sessionExists(sessionId : string) {
return this.data.has(sessionId)
}

getSessionById(sessionId : string) {
return this.data.has(sessionId) ? this.data.get(sessionId)! : null
}
Expand Down
6 changes: 0 additions & 6 deletions src/stores/MongoStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ export default class MongoStore implements Store {
this.sessions = db.collection(collectionName)
}

async sessionExists(sessionId : string) {
const session = await this.sessions.findOne({ id: sessionId })

return session ? true : false
}

async getSessionById(sessionId : string) {
const session = await this.sessions.findOne({ id: sessionId })

Expand Down
5 changes: 0 additions & 5 deletions src/stores/PostgresStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ export default class PostgresStore implements Store {
await this.sql`create table if not exists ${this.sql(this.tableName)} (id varchar(21) not null primary key, data varchar)`;
}

async sessionExists(sessionId: string) {
const result = await this.sql`select data from ${this.sql(this.tableName)} where id = ${sessionId}`
return result.length > 0 ? true : false
}

async getSessionById(sessionId: string) {
const result = await this.sql`select data from ${this.sql(this.tableName)} where id = ${sessionId}`
return result.length > 0 ? JSON.parse(result[0].data) as SessionData : null
Expand Down
5 changes: 0 additions & 5 deletions src/stores/RedisStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ export default class RedisStore implements Store {
this.db = db
}

async sessionExists(sessionId : string) {
const session = await this.db.get(this.keyPrefix + sessionId)
return session ? true : false
}

async getSessionById(sessionId : string) {
const session = await this.db.get(this.keyPrefix + sessionId)

Expand Down
10 changes: 0 additions & 10 deletions src/stores/SqliteStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,6 @@ export default class SqliteStore implements Store {
this.db.query(`CREATE TABLE IF NOT EXISTS ${this.tableName} (id TEXT, data TEXT)`)
}

sessionExists(sessionId : string) {
let session = ''

for (const [sess] of this.db.query<string[]>(`SELECT data FROM ${this.tableName} WHERE id = ?`, [sessionId])) {
session = sess
}

return session ? true : false;
}

getSessionById(sessionId : string) {
let session = ''

Expand Down
1 change: 0 additions & 1 deletion src/stores/Store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { Context } from '../../deps.ts'
import type { SessionData } from '../Session.ts'

export default interface Store {
sessionExists(sessionId?: string) : Promise<boolean> | boolean
getSessionById(sessionId?: string) : Promise<SessionData | null> | SessionData | null
createSession(sessionId: string, initialData: SessionData) : Promise<void> | void
persistSessionData(sessionId: string, sessionData: SessionData) : Promise<void> | void
Expand Down
7 changes: 0 additions & 7 deletions src/stores/WebdisStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ export default class WebdisStore implements Store {
this.keyPrefix = options.keyPrefix || 'session_'
}

async sessionExists(sessionId : string) {
const payload = await fetch(this.url + '/GET/' + this.keyPrefix + sessionId)
const payloadJSON = await payload.json()
const session = payloadJSON.GET
return session ? true : false
}

async getSessionById(sessionId : string) {
const payload = await fetch(this.url + '/GET/' + this.keyPrefix + sessionId)
const payloadJSON = await payload.json()
Expand Down

0 comments on commit 44610c8

Please sign in to comment.