Create templates to quickly answer FAQs or store snippets for re-use.
Hi Aurel, thanks for posting this great express example. I'm having some issues getting going with the import express from "express" command. When I switch it to a const express = require('express') it seems to work. I believe this is due to the fact that NodeJS does not currently support ES6 import statements, is that correct? Or am I out of date on that thinking? Love the simplicity of this first tutorial and glad I was introduced to pug. It's a pretty cool little module!
import express from "express"
const express = require('express')
Patrick, if you are interested, I wrote a tutorial on how I quickly make use of babel (and webpack) to get ES6 working. You can read about it here
Yes you are right.
I use babel behind the scenes which allows me to use import. and other ES6 features.
Have you tried cloning the project, it is configured for ES6 features to work
I had not cloned it yet, but it makes sense now. Thanks for clarifying the 'issue' I was seeing.
Wow, this was great! I've been wanting to learn more about the MEAN stack forever and this seems like the most concise, straightforward tutorial I've seen!
Is there an easy way to support a large number of endpoints, say, a bunch of UserIDs that load their recent scores from a game?
To be honest I don't understand the question (most likely my bad). Would something like this help /?userID=94564,5464,46464 then you take the number and split them.
If my tutorial on Building a RESTful API with Express and MongoDB doesn't answer it, then I'm happy to help if you could give me some more info!
I think that tutorial does answer it. Now I'm just trying to get this example to work on my Digital Ocean server :) Trying to figure out this Babel stuff to be able to run 'import' :) haha. Lots of fun and learning.
This is amongst the best guides I have seen. I used express quite some ago and restarted recently, this guide did just it’s purpose to get me refreshed.
Express is top-notch, clean, nothing quite like it, it’s almost in every piece of nodejs tech. But as it scales, this app.use invocations will start to form a heap of unnecessary code. So just yesterday I finally decided I have enough and wrote a module that handles this totally, and abstract away all this, true to what an express app should be, totally clean.
This is a fantastic tutorial. I have one question: can we generate static pages for each of the three artists and deploy them in the public folder? That way, we could upload the content of the public folder to a hosting account and serve static pages. What would be the best way to do this? Thanks!
Unless I'm missing something I do not think you'd use this configuration (these tools) for static pages!
Unless you use static page generators (or create your own, kind of how I did here though my aim was to generate markdown files) I don't think there's any other way.
This is definitely one of the best intros to Express that I've read. I want to thank you so much for the time you invested on putting this together for us.
It did really clear some doubts that I had, I am about to read your next article Building a RESTful API with Express and MongoDB
Great intro to express, thanks for writing
Thanks for sharing! For the sake of being explicit you should add "Pug" to the title ie; "Creating a basic website with Express.js and Pug.js"
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.