Skip to content

Commit

Permalink
Merge pull request #16 from MarioSimou/main
Browse files Browse the repository at this point in the history
feat: add getSession utility in order to access a session on the server
  • Loading branch information
PatrickHeneise authored May 31, 2023
2 parents 6308467 + ee05e8c commit 4b52cdb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"require": "./src/index.jsx",
"solid": "./src/index.jsx"
},
"./api/*": "./src/api/*"
"./api/*": "./src/api/*",
"./server": "./src/server/index.js"
},
"main": "src/index.js",
"types": "./src/index.d.ts",
Expand Down
7 changes: 7 additions & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ declare module '@zentered/auth0-solid-start/api/logout' {
export default function (req: APIEvent['request']): void
}

declare module '@zentered/auth0-solid-start/server' {
import type { ServerFunctionEvent } from 'solid-start/server'
import type { Session } from 'solid-start/session/sessions'

export function getSession(event: ServerFunctionEvent): Promise<Session>
}

declare module '@zentered/auth0-solid-start' {
import { Accessor, JSX } from 'solid-js'
import type { WebAuth } from 'auth0-js'
Expand Down
3 changes: 3 additions & 0 deletions src/server/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { storage } from '../session'
export const getSession = async (event) =>
storage.getSession(event.request.headers.get('Cookie'))

0 comments on commit 4b52cdb

Please sign in to comment.