==== A full CRUD app built for Citizen Scientists for viewing and cataloging existing pollinator gardens in a local area. Complete with community and educational resources.
- Home Page can show species sightings/observations or locations of pollinator gardens or plants.
- Give user access to add plants and pollinators to their own GARDEN page.
- Complete with meta data.
- Allow users to add their garden to garden INDEX/HOME page.
Will require two models. Gardens and garden contents
- Give user access to education resources on pollinators and pollinator plants for their region.
- ADD Google maps API to plot locations of gardens and species sightings.
- Allow users to add photos from their phone.
npm init
npm i express
npm i ejs
npm i method-override
npm i mongoose
npm i express-session
npm i bcrypt
npm i bootstrap
npm i jquery
npm i popper.js
npm i multer
TUTORIAL: https://www.youtube.com/watch?v=srPXMt1Q0nY
- Install
multer
to parse form data bodies (fortype=file
).
npm i multer
- Require
multer
in the controller and initialize it withupload
. Set the destination touploads
const multer = require('multer');
const upload = multer({dest: 'uploads/'});
- Pass MIDDLEWARE into POST route to handle incoming request.
3.1. Add
enctype="multipart/form-data"
to your form tag.
router.post('/', upload.single('image'), (req,res) => {
res.send(req.body);
})
- Can now access
req.file
from form data. - TIP: Make sure the form input name is the same as the name passed through
upload.single()
.
upload.single('image')
Upload Image: <input type="file" name="image"><br>
- Add a
storage
method and update theupload
method to reflect.
const storage = multer.diskStorage({
destination: (req, file, cb) => {
cb(null, './uploads');
},
filename: (req, file, cb) => {
cb(null, new Date().toISOString() + file.originalname)
}
});
const upload = multer({storage: storage});
- Edit model to store image info in mongoDB.
- Set the object image to the path of the image.
- Make uploads publicly available.
- The My Garden page is an index view of species.
- The Home page is an index view of all gardens and species/sightings.
- Species and sightings are created through the same model.
- Give users their own garden access.
- Home page with common plants and pollinators that can be added to a user's garden.
- STYLING and Mobile Optimization.
- Location populates to location field.
- Locations shown on map.
- Connecting sightings.