wip
This commit is contained in:
@@ -147,7 +147,6 @@ class GrpcClient {
|
||||
const protoDescriptor = grpc.loadPackageDefinition(packageDefinition)
|
||||
const messageProto = protoDescriptor.message as any
|
||||
this.messageClient = new messageProto.MessageService('localhost:8070', grpc.credentials.createInsecure())
|
||||
// console.log(this.messageClient)
|
||||
}
|
||||
|
||||
// User
|
||||
|
||||
@@ -23,25 +23,13 @@ export async function login(req: Request) {
|
||||
const accessToken = await createAccessToken(user.id, user.email)
|
||||
|
||||
const expires = new Date(Date.now() + config.cookieExpiry * 1000)
|
||||
// const sessionCookie = new Bun.Cookie('token', accessToken.token, {
|
||||
// path: '/',
|
||||
// expires: expires,
|
||||
// maxAge: config.cookieExpiry,
|
||||
// httpOnly: true,
|
||||
// secure: true,
|
||||
// sameSite: 'strict',
|
||||
// })
|
||||
|
||||
return Response.json(
|
||||
{
|
||||
accessToken: accessToken.token,
|
||||
tokenType: 'Bearer',
|
||||
expires: expires,
|
||||
},
|
||||
{
|
||||
status: HttpStatusCodes.CREATED,
|
||||
// headers: { 'Set-Cookie': sessionCookie.toString() }
|
||||
},
|
||||
{ status: HttpStatusCodes.CREATED },
|
||||
)
|
||||
} catch (error) {
|
||||
console.log({ error })
|
||||
|
||||
@@ -23,7 +23,7 @@ const server = Bun.serve({
|
||||
async open(ws) {
|
||||
try {
|
||||
const ipAddr = ws.remoteAddress
|
||||
// console.log('ipAddr', ipAddr)
|
||||
console.log('ipAddr', ipAddr)
|
||||
|
||||
const user = ws.data
|
||||
|
||||
@@ -69,8 +69,8 @@ const server = Bun.serve({
|
||||
}
|
||||
|
||||
if (o.type === 'GET_MESSAGES') {
|
||||
const messages = await client.listMessage({ user_id: ws.data.userId, chat_id: o.data.chat_id, page: 1 })
|
||||
server.publish(o.data.chat_id, JSON.stringify({ type: 'MESSAGES', ...messages }))
|
||||
const messages = await client.listMessage({ user_id: ws.data.userId, chat_id: o.data.chatId, page: 1 })
|
||||
server.publish(o.data.chatId, JSON.stringify({ type: 'MESSAGES', ...messages }))
|
||||
}
|
||||
|
||||
if (o.type === 'GET_USERS') {
|
||||
|
||||
@@ -21,7 +21,7 @@ export type LoginDto = { email: string }
|
||||
interface ListMessages {
|
||||
type: 'GET_MESSAGES'
|
||||
data: {
|
||||
chat_id: string
|
||||
chatId: string
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user