Hi, first, thank you for all the work.
I'm settings up realTime (using pubSub from redwood).
I manage to get think working in some way : frontend subscribe and publish successfully.
My trouble come on 2 situations :
- when using my publishService from a
api/src/function/<endpoint>, mycontextdoesnt havepubSubattribut in it. So i cannot publish...
Here is how i create my function
import type { APIGatewayEvent } from 'aws-lambda'
import { useRequireAuth } from '@redwoodjs/graphql-server'
import { getCurrentUser, isAuthenticated, authDecoder } from 'src/lib/auth'
import { commitProject } from 'src/lib/commitFunction'
/**
* The handler function processes HTTP request events.
*
* @typedef { import('aws-lambda').APIGatewayEvent } APIGatewayEvent
* @typedef { import('aws-lambda').Context } Context
* @param { APIGatewayEvent } event - Information from the invoker.
* @param { Context } _context - Contains invocation, function, and environment info.
*/
const myHandler = async (event: APIGatewayEvent) => {
if (!isAuthenticated()) {
return { statusCode: 403 }
}
const user = context.currentUser
const body = event.body ? JSON.parse(event.body) : null
if (!body) {
throw new Error('Invalid body')
}
const res = await commitProject(body, user.username)
if (res) {
return res
}
return {
statusCode: 200,
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(body),
}
}
export const handler = useRequireAuth({
handlerFn: myHandler,
getCurrentUser,
authDecoder,
})
I got currentUser without trouble, but not the pubSub inside ...
The 2nd point is :
- I would like to
publishfrom abackgroundJob, how to do it ? Sincecontextis not available neither. I need this because i have a periodic backgroundJob that willpublish....
Thank you !!