async-labs / saas

Build your own SaaS business with SaaS boilerplate. Productive stack: React, Material-UI, Next, MobX, WebSockets, Express, Node, Mongoose, MongoDB. Written with TypeScript.
https://saas-app.async-await.com
MIT License
4.06k stars 674 forks source link

Can't modify the session (Chapter 5) #177

Closed rohidas-gowda closed 2 years ago

rohidas-gowda commented 2 years ago

In the chapter 5, In "save session to database" section

req.session.foo = 'bar';

is giving following error

Property 'foo' does not exist on type 'Session & Partial<SessionData>' 

So I am not able to modify the sessions. The error path:

book/5-begin/api/server/api/public.ts
rohidas-gowda commented 2 years ago

Here is the repo I get the error: https://github.com/rohidas-gowda/saas/blob/master/book/1-begin/api/server/api/public.ts At line 10

klyburke commented 2 years ago

@rohidas-gowda Thanks for reporting and sharing your code base.

I tested your code and see the problem. As a quick solution to get the code running, you can write //@ts-ignore above the line req.session.foo = 'bar';.

That worked for me, but I will look into a better solution, if it makes sense for this example in the book.

rohidas-gowda commented 2 years ago

Thanks @klyburke