RESTful ROUTES table

Name Path HTML Verb Purpose Mongoose Method
INDEX /blogs GET List all blogs Blog.find()
New /blogs/new GET Show new blog form N/A
Create /blogs POST Create a new blog, then redirect somewhere Blog.create()
Show /blogs/:id GET Show info about one specific blog Blog.findById()
Edit /blogs/:id/edit GET Show edit form for one blog Blog.findById()
Update /blogs/:id PUT Update a particular blog, then redirect somewhere Blog.findByIdAndUpdate()
Destroy /blogs/:id DELETE Delete a particular blog, then redirect somewhere Blog.findByIdAndRemove()

 

# Sanitize(바람직하지 못한 부분을 삭제하다. 살균하다) blog body

# Style Index # Update REST Table

1. Sanitizer (block '<'script> tag from userside(req.body)

1) install sanitizer npm install express-sanitizer --save

2) call and config

const expressSanitizer = require("express-sanitizer"), app.use(expressSanitizer()); 
// Only requirement is expressSanitizer should be used after bodyParser

3) Apply sanitizer for CREATE and UPDATE

 

2. Edit index.ejs

1) Put all contents in the center

2) Other design

 

 

+ Recent posts