I am actually a flutter developer and have configured an existing project whose admin panel is built in VUE.js and mobile app is built in flutter. I have configured this app many times for clients but can't do it for the last time.
This hosted VUE.app is making problem and this is not. Both's code are same except some of the library changes however both were deployed with some of the deprecation warnings to firebase ( I will provide those warnings if necessary).
Admin panel has two parts i.e BACKEND & FRONTEND
Backend:
Index.js where the api cloud function lies which is deployed on firebase-functions.
const functions = require('firebase-functions');
const api = require('./src/api');
const runtimeOpts = {
timeoutSeconds: 300,
memory: '1GB',
};
exports.api = functions
.runWith(runtimeOpts)
.https.onRequest(api);
And this is the api's index being called from above index.js
const express = require('express');
const cors = require('cors');
const app = express();
const authFirebaseService = require('../auth/authFirebaseService');
const authMiddleware = require('../auth/authMiddleware');
const {
init: databaseInit,
middleware: databaseMiddleware,
} = require('../database/databaseInit');
const bodyParser = require('body-parser');
databaseInit().catch((error) => console.error(error));
authFirebaseService.init();
app.use(databaseMiddleware);
app.use(authMiddleware);
app.use(bodyParser.json());
app.use(cors({ origin: true }));
const routes = express.Router();
require('./auditLog')(routes);
require('./auth')(routes);
require('./iam')(routes);
require('./settings')(routes);
require('./customers')(routes);
require('./suppliers')(routes);
require('./staff')(routes);
require('./products')(routes);
require('./brands')(routes);
require('./categories')(routes);
require('./expenses')(routes);
require('./expenseCategory')(routes);
require('./assets')(routes);
require('./devices')(routes);
require('./notice')(routes);
require('./sales')(routes);
require('./purchases')(routes);
require('./returns')(routes);
require('./stockAdjustments')(routes);
require('./units')(routes);
require('./giftCard')(routes);
require('./coupon')(routes);
require('./damages')(routes);
require('./leave')(routes);
require('./leaveType')(routes);
require('./allowanceAndDeduction')(routes);
require('./payroll')(routes);
require('./attendance')(routes);
require('./taxClass')(routes);
require('./todo')(routes);
require('./documents')(routes);
require('./paymentMethods')(routes);
require('./documentTypes')(routes);
require('./memos')(routes);
require('./currency')(routes);
require('./holiday')(routes);
require('./stall')(routes);
require('./variation')(routes);
require('./productLogs')(routes);
require('./stockTransfer')(routes);
require('./deviceSessions')(routes);
require('./productCount')(routes);
require('./productValue')(routes);
require('./register')(routes);
require('./commissions')(routes);
require('./transactions')(routes);
require('./priceChange')(routes);
app.use('/api', routes);
module.exports = app;
package.json:
{
"name": "app-backend",
"description": "Backend",
"scripts": {
"serve": "firebase serve --only functions",
"shell": "firebase functions:shell",
"start": "nodemon ./server.js",
"logs": "firebase functions:log",
"test": "nodemon --exec 'cross-env NODE_ENV=test mocha ./src/**/*.test.js --exit || exit 1'",
"predeploy:development": "firebase use development && firebase functions:config:set env.value=\"development\"",
"deploy:development": "firebase deploy --only functions",
"deploy:appengine:development": "gcloud app deploy app-engine.development.yaml --project <insert project id here>",
"predeploy:production": "firebase use production && firebase functions:config:set env.value=\"production\"",
"deploy:production": "firebase deploy --only functions",
"deploy:appengine:production": "gcloud app deploy app-engine.production.yaml --project <insert project id here>"
},
"dependencies": {
"cors": "2.8.5",
"express": "4.16.4",
"firebase-admin": "7.0.0",
"firebase-functions": "2.2.0",
"graphql": "14.1.1",
"graphql-fields": "2.0.1",
"graphql-iso-date": "3.6.1",
"graphql-tools": "4.0.4",
"graphql-type-json": "0.2.1",
"lodash": "^4.17.15",
"moment": "2.24.0",
"nodemailer": "5.1.1"
},
"engines": {
"node": "16"
},
"private": true,
"devDependencies": {
"cross-env": "5.2.0",
"firebase-functions-test": "0.1.6",
"mocha": "^6.2.2",
"node-mocks-http": "1.7.3",
"nodemon": "1.18.10"
},
"version": "1.0.0",
"main": "index.js",
"author": "Bilal Saeed",
"license": "ISC"
}
Frontend:
package.json
{
"name": "frontend",
"version": "0.1.0",
"private": true,
"scripts": {
"start": "npm run start:localhost",
"start:localhost": "vue-cli-service serve --mode localhost --port 8081",
"build:localhost": "vue-cli-service build --mode localhost",
"start:development": "vue-cli-service serve --mode development --port 8081",
"build:development": "vue-cli-service build --mode development",
"deploy:development": "firebase use development && npm run build:development && firebase deploy --only hosting,storage",
"start:production": "vue-cli-service serve --mode production --port 8081",
"build:production": "vue-cli-service build --mode production",
"deploy:production": "firebase use production && npm run build:production && firebase deploy --only hosting,storage",
"lint": "vue-cli-service lint"
},
"dependencies": {
"axios": "^0.19.0",
"chart.js": "2.7.3",
"element-ui": "2.5.4",
"file-saver": "2.0.1",
"filesize": "4.1.2",
"firebase": "^9.9.1",
"lodash": "^4.17.15",
"md5": "2.2.1",
"moment": "2.24.0",
"nprogress": "0.2.0",
"portal-vue": "2.1.6",
"qs": "6.7.0",
"uuid": "7.0.3",
"vue": "2.6.7",
"vue-router": "3.0.2",
"vuex": "3.1.0",
"xlsx": "0.14.1",
"yup": "0.26.10"
},
"devDependencies": {
"#vue/cli-plugin-babel": "3.4.1",
"#vue/cli-plugin-eslint": "3.4.1",
"#vue/cli-service": "3.4.1",
"#vue/eslint-config-prettier": "4.0.1",
"babel-eslint": "10.0.1",
"eslint": "5.14.1",
"eslint-plugin-vue": "5.2.2",
"vue-cli-plugin-element": "1.0.1",
"vue-template-compiler": "2.6.7"
},
"main": ".eslintrc.js",
"author": "Bilal Saeed",
"license": "ISC",
"description": ""
}
I have no experience with configuration of VUE.js app, just read the provided manual for installation of software and whenever I faced any bug during configuration, I googled it. But in this case, I'm not having any error.
Related
I'm trying to create a fullstack app template with react, babel, and webpack. However, when I start up the app using nodemon, any changes I make to react components when saved are not reflected on my localhost. Not even my css changes show up.
Attached is my package.json. I typically use npm start to serve to local host 8080.
{
"name": "reactappscratch",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "nodemon --watch src --exec 'webpack-dev-server --mode development --hot --open'",
"build": "webpack --mode production",
"dev": "nodemon --watch server --exec 'npm run start:webpack'",
"start:webpack": "webpack --watch --mode development"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"#emotion/react": "^11.10.5",
"#emotion/styled": "^11.10.5",
"#mui/material": "^5.11.7",
"css-loader": "^6.7.3",
"morgan": "^1.10.0",
"pg": "^8.9.0",
"style-loader": "^3.3.1"
},
"devDependencies": {
"#babel/core": "^7.20.12",
"#babel/preset-env": "^7.20.2",
"#babel/preset-react": "^7.18.6",
"babel-loader": "^9.1.2",
"express": "^4.18.2",
"nodemon": "^2.0.20",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"webpack": "^5.75.0",
"webpack-cli": "^5.0.1",
"webpack-dev-server": "^4.11.1"
}
}
I have a react + express project where I do server side rendering. My folder structure is like this
root
client
build
node_modules
public
src
package.json
node_modules
routes
server.js
package.json
I have two Heroku dynos app-dev and app-prod and I use app-dev for development and app-prod for production and their environments have been set to dev and prod accordingly. My package.json looks like this
{
"name": "name",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server",
"server": "nodemon server",
"client": "npm start --prefix client",
"build": "cd client/ && npm install && npm run build",
"dev": "concurrently \"npm run server\" \"npm run client\""
},
"author": "",
"license": "ISC",
"dependencies": {
"body-parser": "^1.18.3",
"chalk": "^4.1.1",
"concurrently": "^6.1.0",
"connect-mongo": "^3.2.0",
"cookie-parser": "^1.4.3",
"cookie-session": "^2.0.0-beta.3",
"cors": "^2.8.5",
"dotenv": "^10.0.0",
"express": "^4.16.4",
"express-session": "^1.15.6",
"express-validator": "^6.11.1",
"mongoose": "^5.4.1",
"mongoose-findorcreate": "^3.0.0",
"morgan": "^1.10.0",
"passport": "^0.4.0",
"passport-google-oauth": "^2.0.0",
"passport-google-oauth20": "^2.0.0",
"passport-twitter": "^1.0.4",
"redux-thunk": "^2.3.0",
"http-proxy-middleware": "^2.0.0"
}
}
Now I have got a constants file in my client/src folder that had these
// Constants.js
const prod = {
url: {
SS_API_URL: 'https://prod.example.com',
},
keys:{
SS_CLIENT_ID: 'prodClientId',
SS_X_API_KEY: 'prodApiKey',
}
};
const dev = {
url: {
SS_API_URL: 'https://dev.example.com',
},
keys:{
SS_CLIENT_ID: 'devClientId',
SS_X_API_KEY: 'devApiKey',
}
};
export const config = process.env.NODE_ENV === 'development' ? dev : prod;
Now when I upload to Heroku (app-dev) and it builds it, after that it seems to be using the prod.example.com instead of dev.example.com API endpoint. Since the NODE_ENV is development I thought it would take the SS_API_URL for dev but it is taking the SS_API_URL for prod
You can add this variable on settings menu, "Config Vars", inside your heroku project. So you add NODE_ENV and value "production".
My app's front-end is Reactjs and backend is Node js. I used express server and graphql-express server. I deployed my app successfully. But it starts with data is loading and then nothing shows. But if I run locally npm start then the heroku app is start working.
This is the error I get it in browser
This is my server's package json file. If i run in terminal npm run dev. It opens my react js app.
{
"name": "backend",
"version": "1.0.0",
"description": "personish vol 2",
"main": "server.js",
"scripts": {
"start": "node server.js",
"server": "node server.js",
"client": "npm start --prefix client",
"dev": "concurrently \"npm run server\" \"npm run client\""
},
"author": "Alak",
"license": "ISC",
"dependencies": {
"concurrently": "^5.0.2",
"cors": "^2.8.5",
"express": "^4.17.1",
"express-graphql": "^0.9.0",
"graphql": "^14.5.8",
"pg": "^7.15.1",
"pg-hstore": "^2.3.3",
"sequelize": "^5.21.3"
}
}
This is my react's package json
{
"name": "client",
"version": "0.1.0",
"private": true,
"engines": {
"node": "13.3.0",
"npm": "6.13.0"
},
"dependencies": {
"#testing-library/jest-dom": "^4.2.4",
"#testing-library/react": "^9.3.2",
"#testing-library/user-event": "^7.1.2",
"apollo-boost": "^0.4.7",
"axios": "^0.19.0",
"firebase": "^7.6.1",
"graphql": "^14.5.8",
"pg": "^7.15.1",
"react": "^16.12.0",
"react-apollo": "^3.1.3",
"react-dom": "^16.12.0",
"react-dropzone": "^10.2.1",
"react-redux": "^7.1.3",
"react-redux-firebase": "^3.0.5",
"react-router-dom": "^5.1.2",
"react-scripts": "3.3.0",
"redux": "^4.0.4",
"redux-firestore": "^0.11.0",
"redux-thunk": "^2.3.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
This is my express and graphql-express server.
const express = require("express");
const app = express();
const graphqlHTTP = require("express-graphql");
const schema = require("./schema");
const cors = require("cors");
const path = require("path");
app.use(cors());
app.use(
"/graphql",
graphqlHTTP({
schema,
pretty: true,
graphiql: true
})
);
app.use(express.static(path.join(__dirname, "build")));
app.get("/*", (req, res) => {
res.sendFile(path.join(__dirname, "build", "index.html"));
});
const port = process.env.PORT || 8081;
app.listen(port, () =>
console.log(`✅ Example app listening on port ${port}!`)
);
This is my react's app file. Where I use Apollo boost to connect with react app and node js app. I think the error comes from here, dont know how to fix it
import React from "react";
import { ApolloClient, HttpLink, InMemoryCache } from "apollo-boost";
import { ApolloProvider } from "react-apollo";
const client = new ApolloClient({
link: new HttpLink({
uri: "http://localhost:8081/graphql"
}),
cache: new InMemoryCache()
});
This is my heroku app
https://databaseapp2020.herokuapp.com/
your heroku dyno/app would have a name, you would use that to hit your graphql from say a graphiql playground on your laptop, or your react-app... if your heroku app was actually named databaseapp2020 and running then you would use the following assuming your cors was setup properly in the dyno environment variables
https://databaseapp2020.herokuapp.com/graphql
Hi is there anyone who has tried to deploy nuxt app to Google App Engine. I have tried from nuxt regular and express template, it shows 502 Bad Gateway. I don't modify anything from create-nuxt-app command. My app.yaml file contains
runtime: nodejs
env: flex
Is there anything wrong with my setup or maybe there are some additional setup I have to do?
Here is my package.json
{
"name": "nuxt-pwa-vuetify-starter",
"version": "1.0.0",
"description": "Nuxt.js + PWA + Vuetify.js starter project",
"author": "Jefry Dewangga <jefrydco#gmail.com>",
"private": true,
"homepage": "https://github.com/jefrydco/nuxt-pwa-vuetify-starter#readme",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/jefrydco/nuxt-pwa-vuetify-starter"
},
"keywords": [
"nuxt",
"nuxt.js",
"nuxtjs",
"nuxt pwa",
"vue",
"vue.js",
"vuejs",
"vue universal",
"vue ssr",
"vue pwa",
"vuetify",
"vuetify.js",
"vuetifyjs"
],
"engines": {
"node": ">=8.0.0",
"npm": ">=5.0.0"
},
"scripts": {
"dev": "cross-env NODE_ENV=development nodemon server/index.js --watch server",
"build": "nuxt build",
"prestart": "npm run build",
"start": "cross-env NODE_ENV=production node server/index.js",
"generate": "nuxt generate"
},
"dependencies": {
"#nuxtjs/axios": "^5.0.1",
"#nuxtjs/browserconfig": "0.0.7",
"#nuxtjs/component-cache": "^1.1.1",
"#nuxtjs/dotenv": "^1.1.0",
"#nuxtjs/google-analytics": "^2.0.2",
"#nuxtjs/pwa": "^2.0.5",
"#nuxtjs/sentry": "^1.0.1",
"#nuxtjs/sitemap": "0.0.3",
"babel-plugin-transform-imports": "^1.4.1",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.6.1",
"babel-preset-stage-0": "^6.24.1",
"babel-runtime": "^6.26.0",
"cross-env": "^5.1.3",
"express": "^4.16.2",
"morgan": "^1.9.0",
"node-sass": "^4.7.2",
"nodemon": "^1.17.1",
"nuxt": "^1.3.0",
"pug": "^2.0.0-rc.4",
"sass-loader": "^6.0.7",
"stylus": "^0.54.5",
"stylus-loader": "^3.0.2",
"vuetify": "^1.0.3"
},
"devDependencies": {
"babel-eslint": "^8.2.2",
"eslint": "^4.18.1",
"eslint-config-standard": "^10.2.1",
"eslint-loader": "^1.9.0",
"eslint-plugin-html": "^4.0.2",
"eslint-plugin-import": "^2.9.0",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-promise": "^3.6.0",
"eslint-plugin-standard": "^3.0.1"
}
}
and here is my app server index.js,
const express = require('express')
const { Nuxt, Builder } = require('nuxt')
const app = express()
const host = process.env.HOST || '127.0.0.1'
const port = process.env.PORT || 8080
app.set('port', port)
// Import and Set Nuxt.js options
let config = require('../nuxt.config.js')
config.dev = !(process.env.NODE_ENV === 'production')
async function start () {
// Init Nuxt.js
const nuxt = new Nuxt(config)
// Build only in dev mode
if (config.dev) {
const builder = new Builder(nuxt)
await builder.build()
}
// Give nuxt middleware to express
app.use(nuxt.render)
// Listen the server
app.listen(port, host)
console.log('Server listening on http://' + host + ':' + port) // eslint-disable-line no-console
}
start()
Below worked for me.
package.json
"start": "npm install --save cross-env && nuxt build && cross-env NODE_ENV=production node server/index.js",
This install cross-env before serving and nuxt build is a required command in production.
Plus I've changes in server.js
Add health route to express:
app.get('/_ah/health', (req, res) => {
res.status(200)
res.send({hello:'world'})
})
Listen to only port
// app.listen(host,port)
app.listen(port)
I'm a big Google App Engine newbie here. Struggling to deploy my first app onto the platform. When I try to, I get the following error message:
The command '/bin/sh -c npm install --unsafe-perm || ((if [ -f npm-debug.log ]; then cat npm-debug.log; fi) && false)' returned a non-zero code: 1
ERROR
ERROR: build step "gcr.io/cloud-builders/docker#sha256:b085f9e5583624eace9c9ba45097afc12123cf5f145703c693c32264c90bbbe0" failed: exit status 1
ERROR: gcloud crashed (AttributeError): 'module' object has no attribute 'HttpErrorPayload'
app.yaml:
env: flex
runtime: nodejs
package.json:
{
"name": "react-boilerplate",
"version": "1.0.0",
"description": "Minimal boilerplate for react",
"main": "index.js",
"scripts": {
"dev": "webpack-dev-server --progress --inline --colors --hot --config ./webpack.config.js",
"postinstall": "NODE_ENV='production' webpack -p",
"start": "node server.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"babel": {
"presets": [
"es2015",
"react",
"stage-2"
]
},
"engines": {
"node": "6.11.0",
"npm": "3.10.10"
},
"devDependencies": {
"babel-core": "^6.24.1",
"babel-loader": "^7.0.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"css-loader": "^0.28.0",
"node-sass": "^4.5.2",
"sass-loader": "^6.0.5",
"style-loader": "^0.16.1",
"webpack": "^3.0.0",
"webpack-dev-server": "^2.4.5"
},
"dependencies": {
"axios": "^0.16.2",
"d3": "^4.9.1",
"react": "^15.5.4",
"react-dom": "^15.5.4",
"react-redux": "^5.0.5",
"redux": "^3.7.1",
"redux-thunk": "^2.2.0"
}
}
server.js:
const express = require('express');
const path = require('path');
const port = process.env.PORT || 8080;
const app = express();
app.use(express.static(__dirname));
app.get('*', (req, res) => {
res.sendFile(path.resolve(__dirname, 'index.html'));
});
app.listen(port);
console.log('Server started');
This is what my folder directory looks like:
Am I doing right?
Was able to solve this by moving all the modules in devDependencies to dependencies!