Stores images to MongoDB utilizing multer. This solution is easy to extend to uploading multiple files at once. Todo: 1. gridFS for bigger than 16Mb pics.
npm package manager and mongodb uri
/photo-gallery/server>npm install
/photo-gallery/client>npm install
create .env
file with content:
MONGODB_URI=mongodb://127.0.0.1:27017
PORT=8000
NODE_ENV=developtment
fix urlPrefix in client/src/util/config.js (see comments)...
option A usage in production mode:
- set
NODE_ENV=production
- build and run
/photo-gallery/client>npm run build
/photo-gallery/client>cp -r build ../server
/photo-gallery/server>node server.js
and open http://localhost:8000/ in browser. Now folder ./server has all what you need to deploy this on a live system
option B usage in development mode:
/photo-gallery/server>node server.js
/photo-gallery/client>npm start