forked from Shopify/shopify-express
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
30 lines (25 loc) · 896 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const PropTypes = require('prop-types');
const createRouter = require('./routes');
const createMiddleware = require('./middleware');
const {MemoryStrategy} = require('./strategies');
const ShopifyConfigTypes = {
apiKey: PropTypes.string.isRequired,
host: PropTypes.string.isRequired,
secret: PropTypes.string.isRequired,
scope: PropTypes.arrayOf(PropTypes.string).isRequired,
afterAuth: PropTypes.func.isRequired,
shopStore: PropTypes.object,
accessMode: PropTypes.oneOf(['offline', 'online']),
};
const defaults = {
shopStore: new MemoryStrategy(),
accessMode: 'offline'
};
module.exports = function shopify(shopifyConfig) {
PropTypes.checkPropTypes(ShopifyConfigTypes, shopifyConfig, 'option', 'ShopifyExpress');
const config = Object.assign({}, defaults, shopifyConfig);
return {
middleware: createMiddleware(config),
routes: createRouter(config),
};
};