Simple image gallery built with Express, EJS and MongoDB (Mongoose). Upload, view, update and delete images.
Live demo: https://gallery-7io0.onrender.com/
- Deployed on Render
- Verify uptime before sharing(free version).
- Upload images (multer) and store file metadata in MongoDB.
- View gallery and single image details.
- Update image and delete images.
- Basic test for the home route.
- Install dependencies
npm install- Environment
- Copy
.env.exampleto.envand set your MongoDB credentials (or use the included.env). - Connection URIs are built from env vars in ._config.js or
server.js.
Key env vars used:
- MONGO_USERNAME, MONGO_PASSWORD, MONGO_CLUSTER, MONGO_DB_DEV, MONGO_DB_TEST
- Run the app
node server.js
# or (dev)
node server.js
# or
npm start - Run tests
npm testRun tests locally:
npm install
npm testCheckout the test branch (steps)
- If you don't have the upstream remote set, add it (only do this once):
git remote add upstream <UPSTREAM_REPO_URL >- Fetch remote branches:
git fetch upstream
# or, if the branch is on origin: to chech this do git remote -v
git fetch origin- Create a local branch that tracks the remote test branch:
git checkout -b test upstream/test- If the test branch already exists locally:
git checkout test
# update from upstream
git pull upstream test
# or
git pull origin test- Run the test the test branch:
npm testNotes:
- Replace <UPSTREAM_REPO_URL> with the repo URL(from the where you forked the repo).
- Use
git branch -ato list remote branches if you need to confirm the test branch name. - You can aswell use
git remote -vto check the remote repository.
- server.js — app entry, connects to MongoDB and exports
app - package.json — scripts and dependencies
- ._config.js — helper to build Mongo URIs from env
- .env / .env.example — environment examples
- App listens on
process.env.PORT || 5000in server.js. Jenkinsfileincluded for CI/deploy examples.
- Uploaded images stored under
public/images/(ignored by Git). - Max upload size in routes/upload.js is 1MB — adjust
limits.fileSizeas needed.
- Mongo connection errors: verify env values and network access to your cluster. See ._config.js and server.js.
- Tests failing: ensure test DB is reachable or mock DB for CI. Test uses test/serverTest.js.
ISC
- Name: Paul Muchiri
- Email: pmc.ac.ke@gmail.com
- GitHub: https://github.com/pmc-muchiri/
This project was forked from jonnygovish/gallery.