Learn how to build the foundation of a simple Node.js and Express app by creating a user interface and API.
Brought to you by @dan-auth0
Learn how to build the foundation of a simple Node.js and Express app by creating a user interface and API.
Brought to you by @dan-auth0
Itās exciting to create stylish yet secure NodeJS apps. Let me know what you liked, or didnāt like, about this first part. In the next part, Iāll show you how to easily add authentication to this app using Auth0
Thank you dan-auth0, great article for a beginner, I am very excited about the next part with the Auth0 authentication!
Is the second part already release?
Thanks for reading, @gaborh! I am glad that you liked it. Hereās the link to the second part:
It is, @johndavemanuel. Hereās the link:
I hope that you like it.
Great!
Thanks for your response!
Let us know at any time in the future, if you have any questions about those!
hi dan,
great tutorial. i am picking up a good bit from it so far and am looking forward to moving on to the āgoodā part with authentication. however, i am a bit stuck when it comes to the css for the site. iāve just replaced the basic style.css (with the aqua background) with that contained in the gist. when i save and browsersync reloads the content is all loaded below the page, as in, i have to scroll down past a white screen to see what would be the header āWHATABYTEā text. by trial and error i was able to narrow the issue down to this part of the css:
html, body,
#root {
height: 100%;
width: 100%;
}
with that commented out, the page loads almost as expected. as soon as i uncomment and save; back to a white page.
i can narrow it further down to the single line:
height: 100%;
the issue is with the height commented out everything is a little bit s-t-r-e-t-c-h-e-d out. i am not too confident about moving on to images with this artifact in place. also, in your example image it appears the h1, h3, etc text is on the left hand side of the page, while i am seeing it centered across the middle.
i have tried this in both chrome & safari just to be certain itās not safari (my preferred browser) acting like a jerk in this case.
does this ring any bells? can you suggest anything i can change to get the desired effect? for now i will carry on with the height commented out, but i have a feeling that things are going to be heading downhill from here.
-c.
I had a bit of trouble getting browser-sync running. If I run the app with
nodemon ./index.js
Then Iām able to browse to port 8000 and see the basic page through Pug. However, if I use the prescribed
browser-sync start --proxy=localhost:8000 --files='**/*.css, **/*.pug, **/*.js' --ignore=node_modules --reload-delay 10 --no-ui --no-notify
then the browser endlessly spins with āLoadingā¦ā.
Digging deeper, it looks like Iām successfully connecting to BrowserSync. I can telnet to port 3000, and I can issue a raw HTTP command like GET / HTTP 1.1
, but the session hangs and never responds.
This happened on two different systems with fresh Node and NPM installs. Adding a --logLevel=debug flag didnāt reveal anything obviously amiss.
What might I be doing wrong? How can I go about troubleshooting this?
Iāll investigate and get back to you! Thanks for reading the post.
Iāll be working on the comments on this thread today. Iāll investigate and get back to you. Thanks for reading the post.
Update:
Howdy, @haiemh! I just re-ran the steps up to adding the custom stylesheet and I didnāt get any errors. The only things that comes to mind is the port maybe being used by something else. Stopping anything running on the ports may help, or a system restart.
I recommend using the link that BrowserSync shows in the console for Local
:
[Browsersync] Proxying: http://localhost:8000
[Browsersync] Access URLs:
-------------------------------
Local: http://localhost:3000
External: http://<Your IP address>:3000
That should work. Are you still having this problem? What version of BrowserSync got installed in your project? The one I installed today is "browser-sync": "^2.26.7",
and itās working fine.
Howdy, @craigz! I re-ran the steps up to when the custom stylesheet is added and everything is working as expected I am not sure what could be happening on your end. Another teammate also tested this prior to the post going live and we reported no issues.
Are you still having the problem? Would you like to share a repo with the code you got so far? What operating system are you using?
Best regards!
hi @dan-auth0, thanks for getting back to me. iāve created a repo on GitHub for the project located at: github link.
when you load the page at localhost:3000 the screen is all white, however if you scroll down, youāll see the image followed by the text and finally the button. i just completely replaced my version of public/style.css with the text of the gist and updated to the point of adding the graphic so there should be none of my ātroubleshootingā evident to be the reason things arenāt working. (i had never got it working anyhow, however i was able to greatly reduce the whitespace at the top of the page; but then the graphic was a 4 pixel tall strip. not much better!)
i am working on a mac (mojave) and have tried this in the chrome browser as well as safari with similar results.
iām curious to hear how it works for you after youāve had a chance to check it out. thanks again.
-c.
@craigz Thank you for sharing the repo! It helps tremendously. I found the source of trouble for your project:
Thatās the tricky part of Pug, white spacing controls structuring:
div.View.WelcomeView
h1.Banner WHATABYTE
The Banner
element gets pushed down because itās a sibling of the WelcomeView
element. If you indent it, it becomes its child
At that point in the tutorial, the index.pug
template should look like this:
extends layout
block layout-content
div.View.WelcomeView
h1.Banner WHATABYTE
div.Message
div.Title
h3 Making the Best
h1 Food For Devs
span.Details Access the WHATABYTE Team Portal
div.NavButtons
if isAuthenticated
a(href="/user")
div.NavButton Just dive in!
else
a(href="/login")
div.NavButton Log in
Please let me know if that fixes the issue
hi @dan-auth0,
so much closer now. the parent-child relationship now appears to work correctly and the image loads in the way i would expect. the only remaining issue is that the entire page remains pushed down an entire page of whitespace. so the initial page load is all white and unless you know to scroll down a page, it appears there is nothing there. i had entirely focused on the css as that is entirely unknown to me, iād not even thought about what pug was doing there. iāll focus on that a bit more and see how it goes. iāll update here if i manage to work things out, otherwise if you have any other ideas as to why the whitespace, let me know. iāve updated the repo with the changes to index.pug.
thanks again for taking a look at this.
-c.
Check out this line:
block layout-content
needs to be indented to become the child of div#root
legend! that did the trick. thanks so much i am looking forward to moving along with this tutorial. cheers.
Cool, glad it worked
Let us know @craigz if you have any more questions!