npm init
npm i express ejs express-ejs-layouts
express: Server
ejs: Template
express-ejs-layouts: Layout, a kind of Twig
npm i --save-dev nodemon
nodemon: Autorefresh for the server
In "package.json", modify the "scripts" properties by adding : "start": "node server.js" // For prod "devStart": "nodemon server.js" // For dev
npm i mongoose
mongoose: to connect to the database
npm i --save-dev dotenv
dotenv: to available environment variable
npm i body-parser
body-parser: to parse easily our data from ejs
Maybe useless...
npm i multer
multer: handle file import
npm i method-override
method-override: allow to add new method in addition to post and get
https://pqina.nl/filepond/ To store images in base64 in the database
node-sass -w . -o .
Right click on index.html and choose "Open with LiveServer"
// First time only
git init
git add .
git commit -m "Blablabla"
git remote add origin https://github.com/GBMan/Mybrary.git
git push -u origin master
Each time
git add .
git commit -m "Blablabla"
git push
... and see Heroku
https://devcenter.heroku.com/articles/heroku-cli
Reload the computer
heroku login
Open a web page in a browser for connection
heroku git:remote -a gb-mybrary // One time
git push heroku master // Each time
Push the last git project version git on Heroku.
Go to "Settings" Click on "Config Vars" In the "Key" field fill "DATABASE_URL" In the "Value" field fill the MongoDB Atlas connection String (see below)
Create an account - Once Create a cluster Click on "Connect" Create a user Choose "Connect your Application" Copy the "Connection String" Paste it in the "Value" field for environment variables in Heroku ! Replace by the MongoDB user name ! Replace by the MongoDB user password
Go to Security -> Network Access Click "Add IP address" Set "0.0.0.0/0" top open all or just our app heroku IP address