Repository: Yoctol/bottender
Pull request #853 (2020-08-03 08:49:05)

Move getSessionStore to shared folder
Move getSessionStore to shared folder

codecov-commenter: # [Codecov](https://codecov.io/gh/Yoctol/bottender/pull/853?src=pr&el=h1) Report
> Merging [#853](https://codecov.io/gh/Yoctol/bottender/pull/853?src=pr&el=desc) into [release/1.5](https://codecov.io/gh/Yoctol/bottender/commit/d8f80ba2db84f0d486738a48a496e916e8f17b6b&el=desc) will **not change** coverage.
> The diff coverage is `90.00%`.

[![Impacted file tree graph](https://codecov.io/gh/Yoctol/bottender/pull/853/graphs/tree.svg?width=650&height=150&src=pr&token=JX3EGtxYH3)](https://codecov.io/gh/Yoctol/bottender/pull/853?src=pr&el=tree)

```diff
@@             Coverage Diff              @@
##           release/1.5     #853   +/-   ##
============================================
  Coverage        84.04%   84.04%           
============================================
  Files              120      120           
  Lines             6243     6243           
  Branches          1612     1612           
============================================
  Hits              5247     5247           
  Misses             992      992           
  Partials             4        4           
```


| [Impacted Files](https://codecov.io/gh/Yoctol/bottender/pull/853?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [packages/bottender/src/shared/getSessionStore.ts](https://codecov.io/gh/Yoctol/bottender/pull/853/diff?src=pr&el=tree#diff-cGFja2FnZXMvYm90dGVuZGVyL3NyYy9zaGFyZWQvZ2V0U2Vzc2lvblN0b3JlLnRz) | `86.48% <83.33%> (ø)` | |
| [packages/bottender/src/index.ts](https://codecov.io/gh/Yoctol/bottender/pull/853/diff?src=pr&el=tree#diff-cGFja2FnZXMvYm90dGVuZGVyL3NyYy9pbmRleC50cw==) | `100.00% <100.00%> (ø)` | |
| [packages/bottender/src/initializeServer.ts](https://codecov.io/gh/Yoctol/bottender/pull/853/diff?src=pr&el=tree#diff-cGFja2FnZXMvYm90dGVuZGVyL3NyYy9pbml0aWFsaXplU2VydmVyLnRz) | `27.65% <100.00%> (ø)` | |
| [packages/bottender/src/server/Server.ts](https://codecov.io/gh/Yoctol/bottender/pull/853/diff?src=pr&el=tree#diff-cGFja2FnZXMvYm90dGVuZGVyL3NyYy9zZXJ2ZXIvU2VydmVyLnRz) | `67.30% <100.00%> (ø)` | |
| [packages/bottender/src/shared/getClient.ts](https://codecov.io/gh/Yoctol/bottender/pull/853/diff?src=pr&el=tree#diff-cGFja2FnZXMvYm90dGVuZGVyL3NyYy9zaGFyZWQvZ2V0Q2xpZW50LnRz) | `52.63% <100.00%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/Yoctol/bottender/pull/853?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/Yoctol/bottender/pull/853?src=pr&el=footer). Last update [d8f80ba...ad23811](https://codecov.io/gh/Yoctol/bottender/pull/853?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/packages/bottender/src/index.ts b/packages/bottender/src/index.ts
index 7bd0b705..7f213bca 100644
--- a/packages/bottender/src/index.ts
+++ b/packages/bottender/src/index.ts
@@ -12,7 +12,7 @@ export { bottender };
 export { default as Bot } from './bot/Bot';
 export { Connector } from './bot/Connector';
 export { default as Context } from './context/Context';
-export { default as getSessionStore } from './getSessionStore';
+export { default as getSessionStore } from './shared/getSessionStore';
 export { default as getClient } from './shared/getClient';
 
 /* Action */
diff --git a/packages/bottender/src/initializeServer.ts b/packages/bottender/src/initializeServer.ts
index da81407e..39346bd1 100644
--- a/packages/bottender/src/initializeServer.ts
+++ b/packages/bottender/src/initializeServer.ts
@@ -12,7 +12,7 @@ import TelegramBot from './telegram/TelegramBot';
 import ViberBot from './viber/ViberBot';
 import WhatsappBot from './whatsapp/WhatsappBot';
 import getBottenderConfig from './shared/getBottenderConfig';
-import getSessionStore from './getSessionStore';
+import getSessionStore from './shared/getSessionStore';
 import { Action, BottenderConfig, Channel, Plugin } from './types';
 
 const BOT_MAP = {
diff --git a/packages/bottender/src/server/Server.ts b/packages/bottender/src/server/Server.ts
index a328c6d8..e14e569f 100644
--- a/packages/bottender/src/server/Server.ts
+++ b/packages/bottender/src/server/Server.ts
@@ -10,7 +10,7 @@ import { pascalcase } from 'messaging-api-common';
 
 import Bot from '../bot/Bot';
 import getBottenderConfig from '../shared/getBottenderConfig';
-import getSessionStore from '../getSessionStore';
+import getSessionStore from '../shared/getSessionStore';
 import { Action, BottenderConfig, Plugin, RequestContext } from '../types';
 
 export type ServerOptions = {
diff --git a/packages/bottender/src/shared/getClient.ts b/packages/bottender/src/shared/getClient.ts
index dd60aaa1..58410e35 100644
--- a/packages/bottender/src/shared/getClient.ts
+++ b/packages/bottender/src/shared/getClient.ts
@@ -11,10 +11,10 @@ import TelegramBot from '../telegram/TelegramBot';
 import TwilioClient from '../whatsapp/TwilioClient';
 import ViberBot from '../viber/ViberBot';
 import WhatsappBot from '../whatsapp/WhatsappBot';
-import getSessionStore from '../getSessionStore';
 import { Channel } from '../types';
 
 import getBottenderConfig from './getBottenderConfig';
+import getSessionStore from './getSessionStore';
 
 const BOT_MAP = {
   messenger: MessengerBot,
diff --git a/packages/bottender/src/getSessionStore.ts b/packages/bottender/src/shared/getSessionStore.ts
similarity index 74%
rename from packages/bottender/src/getSessionStore.ts
rename to packages/bottender/src/shared/getSessionStore.ts
index d4e5deae..2df02a57 100644
--- a/packages/bottender/src/getSessionStore.ts
+++ b/packages/bottender/src/shared/getSessionStore.ts
@@ -1,7 +1,8 @@
 import warning from 'warning';
 
-import SessionStore from './session/SessionStore';
-import getBottenderConfig from './shared/getBottenderConfig';
+import SessionStore from '../session/SessionStore';
+
+import getBottenderConfig from './getBottenderConfig';
 
 function getSessionStore(): SessionStore {
   const { session } = getBottenderConfig();
@@ -12,7 +13,7 @@ function getSessionStore(): SessionStore {
 
   switch (sessionDriver) {
     case 'memory': {
-      const MemorySessionStore = require('./session/MemorySessionStore')
+      const MemorySessionStore = require('../session/MemorySessionStore')
         .default;
 
       return new MemorySessionStore(
@@ -21,7 +22,7 @@ function getSessionStore(): SessionStore {
       );
     }
     case 'file': {
-      const FileSessionStore = require('./session/FileSessionStore').default;
+      const FileSessionStore = require('../session/FileSessionStore').default;
 
       return new FileSessionStore(
         storesConfig.file || {},
@@ -29,7 +30,7 @@ function getSessionStore(): SessionStore {
       );
     }
     case 'mongo': {
-      const MongoSessionStore = require('./session/MongoSessionStore').default;
+      const MongoSessionStore = require('../session/MongoSessionStore').default;
 
       return new MongoSessionStore(
         storesConfig.mongo || {},
@@ -37,7 +38,7 @@ function getSessionStore(): SessionStore {
       );
     }
     case 'redis': {
-      const RedisSessionStore = require('./session/RedisSessionStore').default;
+      const RedisSessionStore = require('../session/RedisSessionStore').default;
 
       return new RedisSessionStore(
         storesConfig.redis || {},
@@ -57,7 +58,7 @@ function getSessionStore(): SessionStore {
         false,
         `Received unknown driver: ${sessionDriver}, so fallback it to \`memory\` driver.`
       );
-      const MemorySessionStore = require('./session/MemorySessionStore')
+      const MemorySessionStore = require('../session/MemorySessionStore')
         .default;
 
       return new MemorySessionStore(


Test patch:
diff --git a/packages/bottender/src/__tests__/getSessionStore.spec.ts b/packages/bottender/src/shared/__tests__/getSessionStore.spec.ts
similarity index 91%
rename from packages/bottender/src/__tests__/getSessionStore.spec.ts
rename to packages/bottender/src/shared/__tests__/getSessionStore.spec.ts
index b99e733f..8db5f253 100644
--- a/packages/bottender/src/__tests__/getSessionStore.spec.ts
+++ b/packages/bottender/src/shared/__tests__/getSessionStore.spec.ts
@@ -1,9 +1,9 @@
-import MemorySessionStore from '../session/MemorySessionStore';
-import getBottenderConfig from '../shared/getBottenderConfig';
+import MemorySessionStore from '../../session/MemorySessionStore';
+import getBottenderConfig from '../getBottenderConfig';
 import getSessionStore from '../getSessionStore';
-import { SessionDriver } from '../types';
+import { SessionDriver } from '../../types';
 
-jest.mock('../shared/getBottenderConfig');
+jest.mock('../getBottenderConfig');
 
 const getBottenderConfigMocked = getBottenderConfig as jest.MockedFunction<
   typeof getBottenderConfig