Secbone / koa-session2

Middleware for Koa2 to get/set session
MIT License
152 stars 30 forks source link

Refactoring store to use native Map and no decoding #26

Closed tinovyatkin closed 7 years ago

tinovyatkin commented 7 years ago
  1. You basically simulating native javascript Map object via keys of object - that's bad, it's node 7x already, let's use native Map

  2. Re-export Store from main file to avoid referencing internal project files when extending Store.

  3. You actually don't need encode & decode session data for in-memory storage, so, dropped it. When extending Store developer must do store specific value sanitation anyway.

tinovyatkin commented 7 years ago

Also, in Redis store example I'm using SET EX to automatically drop expired sessions

tinovyatkin commented 7 years ago

Also removed async in default store methods, as they are all sync actually. You can await for sync function value, so, not a problem with overring it to async get or async set

Secbone commented 7 years ago

That is great! Thank you so much! 👍