MCPcopy Create free account
hub / github.com/tinyhttp/tinyhttp / getSession

Method getSession

packages/session/src/index.ts:683–702  ·  view source on GitHub ↗

* Get session from the store. * @param id Session ID

(id: string)

Source from the content-addressed store, hash-verified

681 * @param id Session ID
682 */
683 private getSession(id: string) {
684 const sess = this.sessions[id]
685
686 if (!sess) return
687
688 const sessJSON = JSON.parse(sess)
689
690 if (sessJSON.cookie) {
691 let expires: Date
692 if (!(sessJSON.cookie.expires instanceof Date)) expires = new Date(sessJSON.cookie.expires)
693 else expires = sessJSON.cookie.expires
694
695 if (expires && expires <= new Date(Date.now())) {
696 delete this.sessions[id]
697 return
698 }
699 }
700
701 return sessJSON
702 }
703}

Callers 3

allMethod · 0.95
getMethod · 0.95
touchMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected