@newageerp/node-sessions
v1.0.10
Published
## ENV CRM_SESSION_BACKEND_V3=https://***
Downloads
83
Readme
Node Sessions
ENV
CRM_SESSION_BACKEND_V3=https://***
USAGE BROWSER
add key value by session ID
import { keyValueBrowser } from '@newageerp/node-sessions'
keyValueBrowser.addKeyValueByAnalyticsIdBrowser({
dataKey: 'unique key',
dataValue: {}
})
add key value by order ID
import { keyValueBrowser } from '@newageerp/node-sessions'
keyValueBrowser.addKeyValueByUuidBrowser({
uuid,
dataKey: 'unique key',
dataValue: {}
})
get value by session ID
import { keyValueBrowser } from '@newageerp/node-sessions'
const dataValue = await keyValueBrowser.getKeyValueByAnalyticsIdBrowser({
dataKey: 'unique key',
})
get value by order ID
import { keyValueBrowser } from '@newageerp/node-sessions'
const dataValue = keyValueBrowser.getKeyValueByUuidBrowser({
uuid,
dataKey: 'unique key',
})
USAGE NEXTJS
get value by session ID
import { keyValueNext } from '@newageerp/node-sessions'
const dataValue = await keyValueNext.getKeyValueByAnalyticsIdNext({
dataKey: 'unique key',
})
middleware
import { NextRequest, NextResponse } from 'next/server'
import { keyValueNext } from '@newageerp/node-sessions'
const PROJECT = 'PROJECT_NAME'
// This function can be marked `async` if using `await` inside
export async function middleware(req: NextRequest) {
const keyValueResp = await keyValueNext.checkForRoutes(req, PROJECT)
if (keyValueResp) {
return keyValueResp
}
}
// See "Matching Paths" below to learn more
export const config = {
matcher: '/api/:path*',
}