Adds Middleware API (#40)

* Adds test project

* Adds e2e for end-2-end tests

* Update gitignore

* Update loaders

* Creates test project

* v0.1.27

* Upgrade

* dependency fixes

* Load project plugins in the plugin loader

* Issue with instanceof

* Fixes versioning issues

* Adds medusa middleware api

* Adds documentation

* Fixes tests
This commit is contained in:
Sebastian Rindom authored and GitHub committed 2020-05-01 13:33:03 +02:00
1 parent 964e26e310
commit 516bc7675d
46 files changed
+10163 -977

No files matched your search

@@ -0,0 +1,18 @@
import Module from "module"
import path from "path"
const fallback = filename => {
const mod = new Module(filename)
mod.filename = filename
mod.paths = Module._nodeModulePaths(path.dirname(filename))
mod._compile(`module.exports = require;`, filename)
return mod.exports
}
// Polyfill Node's `Module.createRequireFromPath` if not present (added in Node v10.12.0)
const createRequireFromPath =
Module.createRequire || Module.createRequireFromPath || fallback
export default createRequireFromPath
@@ -0,0 +1,23 @@
import path from "path"
/**
* Attempts to resolve the config file in a given root directory.
* @param {string} rootDir - the directory to find the config file in.
* @param {string} configName - the name of the config file.
* @return {object} an object containing the config module and its path.
*/
function getConfigFile(rootDir, configName) {
const configPath = path.join(rootDir, configName)
let configFilePath = ``
let configModule
try {
configFilePath = require.resolve(configPath)
configModule = require(configFilePath)
} catch (err) {
return {}
}
return { configModule, configFilePath }
}
export default getConfigFile
+2
View File
@@ -1,2 +1,4 @@
export { default as Validator } from "./validator"
export { default as MedusaError } from "./errors"
export { default as getConfigFile } from "./get-config-file"
export { default as createRequireFromPath } from "./create-require-from-path"