You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. Download and Install MongoDB
2. sudo mkdir -p /data/db ( Create database directory locally)
3. sudo chmod -R go+w /data/db ( Danger for production, /data/db is owned by root user, change mode to your current user)
4.
Router
1. Create routers folder
2. Bring Model into specific route
// Load Models
require("../models/Idea");
const Idea = mongoose.model("ideas");
3. Load all routes into app.js
// Load Router
const ideas = require("./routes/ideas");
const users = require("./routes/users");
4. Use route inside app.js
// Use routes
app.use("/ideas", ideas);
app.use("/users", users);
Create Public Folder for Project
1. Create public folder (public/css, public/img, public/js)
2. Bring path module into app.js (path is core node module)
3. Create static folder inside app.js
// Static Folder
app.use(express.static(path.join(__dirname, "public")));
4. Use assets
{{!-- public static assets folder, no need to put full address --}}
<img src="/img/logo.png" />