Initial Commit
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
module.exports = {
|
||||
integrations: {
|
||||
boilerplate: {
|
||||
location: '@vue-storefront/integration-boilerplate-api/server',
|
||||
configuration: {},
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
const { createServer } = require("@vue-storefront/middleware");
|
||||
const { integrations } = require("./middleware.config");
|
||||
const cors = require("cors");
|
||||
|
||||
(async () => {
|
||||
const app = await createServer({ integrations });
|
||||
const host = process.argv[2] ?? "0.0.0.0";
|
||||
const port = process.argv[3] ?? 8181;
|
||||
const CORS_MIDDLEWARE_NAME = "corsMiddleware";
|
||||
|
||||
const corsMiddleware = app._router.stack.find(
|
||||
(middleware) => middleware.name === CORS_MIDDLEWARE_NAME
|
||||
);
|
||||
|
||||
corsMiddleware.handle = cors({
|
||||
origin: [
|
||||
"http://localhost:3000",
|
||||
...(process.env.MIDDLEWARE_ALLOWED_ORIGINS?.split(",") ?? []),
|
||||
],
|
||||
credentials: true,
|
||||
});
|
||||
|
||||
app.listen(port, host, () => {
|
||||
console.log(`Middleware started: ${host}:${port}`);
|
||||
});
|
||||
})();
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "@vue-storefront/integration-boilerplate-playground",
|
||||
"private": true,
|
||||
"version": "0.1.0",
|
||||
"engines": {
|
||||
"node": ">=16.x"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "nodemon --watch node middleware.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@vue-storefront/middleware": "3.0.1",
|
||||
"@vue-storefront/integration-boilerplate-api": "*",
|
||||
"cors": "^2.8.5"
|
||||
},
|
||||
"files": [
|
||||
"lib/**/*",
|
||||
"server/**/*"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user