2021-05-11 20:16:03 +03:00
|
|
|
const webpack = require("webpack");
|
2021-05-12 00:24:47 +03:00
|
|
|
const fetch = require("node-fetch");
|
2021-06-02 21:52:15 +03:00
|
|
|
const Dotenv = require("dotenv-webpack");
|
2021-05-31 06:26:01 +03:00
|
|
|
|
2021-06-10 01:05:02 +03:00
|
|
|
const IS_CORP_TMP = (process.env.VUE_APP_IS_CORP || false);
|
|
|
|
const IS_CORP = JSON.stringify(IS_CORP_TMP);
|
|
|
|
|
2021-06-02 21:52:15 +03:00
|
|
|
const STORE_ID = (process.env.VUE_APP_STORE_ID || "Redmond");
|
2021-06-02 21:19:22 +03:00
|
|
|
const SITE_TYPE = (process.env.VUE_APP_SITE_TYPE || "Pharmacy");
|
2021-09-30 00:28:34 +03:00
|
|
|
const SITE_TITLE = (process.env.VUE_APP_SITE_TITLE || "Red Dog Bodega :: Market fresh food, pharmaceuticals, and fireworks!");
|
2021-06-02 21:19:22 +03:00
|
|
|
const MAKELINE_BASE_URL = (process.env.VUE_APP_MAKELINE_BASE_URL || "http://austin.makeline.brianredmond.io");
|
|
|
|
const ACCOUNTING_BASE_URL = (process.env.VUE_APP_ACCOUNTING_BASE_URL || "http://austin.accounting.brianredmond.io");
|
2021-06-01 21:50:01 +03:00
|
|
|
|
2021-05-31 06:26:01 +03:00
|
|
|
let variables = {
|
2021-06-02 21:19:22 +03:00
|
|
|
IS_CORP: IS_CORP,
|
2021-05-31 06:26:01 +03:00
|
|
|
STORE_ID: STORE_ID,
|
|
|
|
SITE_TYPE: SITE_TYPE,
|
2021-06-01 21:50:01 +03:00
|
|
|
SITE_TITLE: SITE_TITLE,
|
|
|
|
ACCOUNTING_BASE_URL: ACCOUNTING_BASE_URL,
|
|
|
|
MAKELINE_BASE_URL: MAKELINE_BASE_URL
|
|
|
|
}
|
2021-05-31 06:26:01 +03:00
|
|
|
|
2021-06-01 21:50:01 +03:00
|
|
|
let MAKELINE_SERVICE = MAKELINE_BASE_URL + "/orders/" + STORE_ID
|
2021-06-10 01:05:02 +03:00
|
|
|
|
2021-05-13 00:26:16 +03:00
|
|
|
|
2021-06-02 21:52:15 +03:00
|
|
|
if (process.env.NODE_ENV === "production"){
|
|
|
|
console.log("setting PROD environment variables")
|
2021-05-13 00:26:16 +03:00
|
|
|
}else{
|
2021-06-02 21:52:15 +03:00
|
|
|
console.log("setting DEV environment variables")
|
2021-05-13 00:26:16 +03:00
|
|
|
}
|
|
|
|
|
2021-05-11 20:16:03 +03:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
lintOnSave: false,
|
|
|
|
configureWebpack: {
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
2021-05-17 18:05:51 +03:00
|
|
|
// "chart.js": "chart.js/dist/chart.js"
|
2021-05-11 20:16:03 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new webpack.optimize.LimitChunkCountPlugin({
|
|
|
|
maxChunks: 6
|
2021-06-02 21:52:15 +03:00
|
|
|
}),
|
|
|
|
new Dotenv({
|
|
|
|
path: ".env", // Path to .env file (this is the default)
|
|
|
|
safe: false, // load .env.example (defaults to "false" which does not use dotenv-safe)
|
|
|
|
})
|
2021-05-11 20:16:03 +03:00
|
|
|
]
|
|
|
|
},
|
|
|
|
devServer: {
|
|
|
|
headers: {
|
|
|
|
"Access-Control-Allow-Origin": "*",
|
|
|
|
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
|
|
|
|
"Access-Control-Allow-Headers":
|
|
|
|
"X-Requested-With, content-type, Authorization"
|
|
|
|
},
|
|
|
|
disableHostCheck: true,
|
2021-05-18 19:21:26 +03:00
|
|
|
host: "0.0.0.0",
|
|
|
|
public: "0.0.0.0:8080",
|
2021-05-11 20:16:03 +03:00
|
|
|
port: 8080,
|
2021-05-13 00:26:16 +03:00
|
|
|
before: (app)=> {
|
|
|
|
|
2021-06-02 21:52:15 +03:00
|
|
|
app.get("/variables", (req, res)=>{
|
2021-05-31 06:26:01 +03:00
|
|
|
res.json({e: -1, payload:variables}).status(200)
|
|
|
|
})
|
|
|
|
|
2021-06-02 21:52:15 +03:00
|
|
|
app.get("/orders/inflight", (req, res)=>{
|
2021-05-13 00:26:16 +03:00
|
|
|
|
|
|
|
fetch(MAKELINE_SERVICE)
|
2021-05-12 00:24:47 +03:00
|
|
|
.then(response => response.json())
|
|
|
|
.then(data => {
|
2021-06-02 21:52:15 +03:00
|
|
|
if( data.length >= 10){
|
|
|
|
res.json({e: 0, payload:data.slice(data.length-10, data.length)}).status(200)
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
res.json({e: 0, payload:data}).status(200)
|
|
|
|
}
|
|
|
|
|
2021-05-19 23:29:54 +03:00
|
|
|
})
|
|
|
|
.catch(error=>{
|
2021-06-02 21:52:15 +03:00
|
|
|
console.log("error", error)
|
2021-05-31 06:26:01 +03:00
|
|
|
res.json({e: -1, payload: {}})
|
2021-05-12 00:24:47 +03:00
|
|
|
})
|
2021-05-13 00:26:16 +03:00
|
|
|
|
2021-05-12 00:24:47 +03:00
|
|
|
})
|
2021-05-12 19:07:35 +03:00
|
|
|
|
2021-06-02 21:52:15 +03:00
|
|
|
app.get("/orders/metrics", (req, res)=>{
|
2021-06-10 01:05:02 +03:00
|
|
|
var metricsUrl = ACCOUNTING_BASE_URL + "/OrderMetrics?StoreId=" + STORE_ID
|
|
|
|
if(IS_CORP === true || IS_CORP === "true"){
|
|
|
|
metricsUrl = ACCOUNTING_BASE_URL + "/OrderMetrics"
|
|
|
|
}
|
|
|
|
|
|
|
|
fetch(metricsUrl)
|
2021-05-12 19:07:35 +03:00
|
|
|
.then(response => response.json())
|
|
|
|
.then(data => {
|
2021-05-19 23:29:54 +03:00
|
|
|
res.json({e: 0, payload:data}).status(200)
|
|
|
|
})
|
|
|
|
.catch(error=>{
|
2021-06-02 21:52:15 +03:00
|
|
|
console.log("error", error)
|
2021-05-25 23:54:01 +03:00
|
|
|
res.json({e: -1, payload: {}})
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|
|
|
|
|
2021-06-02 21:52:15 +03:00
|
|
|
app.get("/orders/count/minute", (req, res)=>{
|
2021-05-25 23:54:01 +03:00
|
|
|
|
2021-06-10 01:05:02 +03:00
|
|
|
fetch(ACCOUNTING_BASE_URL + "/Orders/Minute/PT20M?StoreId=" + STORE_ID)
|
2021-05-25 23:54:01 +03:00
|
|
|
.then(response => response.json())
|
|
|
|
.then(data => {
|
|
|
|
res.json({e: 0, payload:data}).status(200)
|
|
|
|
})
|
|
|
|
.catch(error=>{
|
2021-06-02 21:52:15 +03:00
|
|
|
console.log("error", error)
|
2021-05-25 23:54:01 +03:00
|
|
|
res.json({e: -1, payload: {}})
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|
|
|
|
|
2021-06-11 00:21:44 +03:00
|
|
|
app.get("/corp/salesprofitbranch", (req, res)=>{
|
2021-05-25 23:54:01 +03:00
|
|
|
|
2021-06-10 01:05:02 +03:00
|
|
|
fetch(ACCOUNTING_BASE_URL + "/Corp/SalesProfit/PerStore")
|
|
|
|
.then(response => response.json())
|
|
|
|
.then(data => {
|
|
|
|
res.json({e: 0, payload:data}).status(200)
|
|
|
|
})
|
|
|
|
.catch(error=>{
|
|
|
|
console.log("error", error)
|
|
|
|
res.json({e: -1, payload: {}})
|
|
|
|
})
|
2021-05-25 23:54:01 +03:00
|
|
|
|
2021-06-10 01:05:02 +03:00
|
|
|
})
|
2021-06-11 00:21:44 +03:00
|
|
|
|
|
|
|
app.get("/corp/salesprofitcorp", (req, res)=>{
|
|
|
|
|
|
|
|
fetch(ACCOUNTING_BASE_URL + "/Corp/SalesProfit/Total")
|
|
|
|
.then(response => response.json())
|
|
|
|
.then(data => {
|
|
|
|
res.json({e: 0, payload:data}).status(200)
|
|
|
|
})
|
|
|
|
.catch(error=>{
|
|
|
|
console.log("error", error)
|
|
|
|
res.json({e: -1, payload: {}})
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
app.get("/corp/stores", (req, res)=>{
|
|
|
|
|
|
|
|
fetch(ACCOUNTING_BASE_URL + "/Corp/Stores")
|
|
|
|
.then(response => response.json())
|
|
|
|
.then(data => {
|
|
|
|
res.json({e: 0, payload:data}).status(200)
|
|
|
|
})
|
|
|
|
.catch(error=>{
|
|
|
|
console.log("error", error)
|
|
|
|
res.json({e: -1, payload: {}})
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|
2021-05-12 00:24:47 +03:00
|
|
|
|
2021-05-11 20:16:03 +03:00
|
|
|
}
|
|
|
|
// proxy: devUrls,
|
|
|
|
},
|
|
|
|
pluginOptions: {
|
|
|
|
i18n: {
|
|
|
|
locale: "en",
|
|
|
|
fallbackLocale: "en",
|
|
|
|
localeDir: "locales",
|
|
|
|
enableInSFC: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
css: {
|
|
|
|
sourceMap: process.env.NODE_ENV !== "production"
|
|
|
|
}
|
|
|
|
};
|