- 1st express CRUD app
- based on RESTful comments tutorial by Colt Steele (paid)
restCommentsDemo.mp4
- create: get /comments/new -> post /comments
- readall: get /comments
- readone: get /comments/:id
- update: get /comments/:id/edit -> patch /comments/:id
- delete: delete /comments/:id
- initiate npm project (potentially install requirements):
npm init -y
- install express:
npm install express
- install ejs (template language):
npm install ejs
- (install nodemon (if not already installed globally):
npm install -g nodemon
(so that you don't need to restart server after every edit)) - (install bootstap (or other frontend toolkit))
- (install express
method-override
to handle put, patch, delete, etc. methods)
- setup default express app
- define express routes (
app.get()
,app.post()
, etc.) - create & specify path to static files:
public/css
&public/js
- specify which kind of data server can receive/handle:
express.urlencoded
/express.json
(for http methods beyond GET) - enable usage of HTTP methods beyond GET & POST (
method-override
) - enable usage of ejs
- create & specify path to
views
(including partials;):/views/partials
- build ejs templates & partials (HTML/ejs)
- define & connect style sheet(s) in
public/css
- (include/connect frontend toolkit (bootstrap, tailwind, bulma, material, ...))
- include partials in views ejs files
- browser can only handle GET & POST
- use
method-override
middleware to modify query parameters of post requests in to send data via different HTTP methods (e.g. DELETE, PATCH, etc.)
- use
- (hoppscotch.io for API testing)
- EJS for templating
- expressJs for routing!?
- nodemon (during development)