Run Node app locally and serve static file handlers from app.yaml?

46 views
Skip to first unread message

Ryan B

unread,
Jul 12, 2018, 2:14:31 AM7/12/18
to Google App Engine
hi all! the docs for Node currently say use to npm start, ie "your local environment with the development tools that you usually use," to run an app locally:


this works fine for URLs handled by Node, but it doesn't serve static files handled by app.yaml, so testing an app manually locally is difficult (or impossible) since it won't have static HTML, CSS, JS, etc.

other language runtimes use eg dev_appserver to serve both dynamic and static file handlers. are there plans for anything similar for Node?

Kenworth (Google Cloud Platform)

unread,
Jul 12, 2018, 12:20:30 PM7/12/18
to google-a...@googlegroups.com
This is currently possible. Here is an example to help you get started:


npm start app.standard.yaml


Ryan B

unread,
Jul 12, 2018, 1:27:58 PM7/12/18
to Google App Engine
thanks, kenworth!

looks like the key part of that example is these lines in app.js:

// Use the built-in express middleware for serving static files from './public'
app
.use('/static', express.static('public'));

that does indeed get the static files serving. it still ignores the static file handlers in app.yaml, though, and just duplicates them via express in app.js instead. that's ok, but it's unfortunate for larger applications with many different static file handlers in app.yaml, since you have to duplicate them all, and they'll inevitably skew when you change them.

if this is expected, i'm happy to file a feature request on the issue tracker! just let me know.

Steren Giannini

unread,
Jul 12, 2018, 4:39:26 PM7/12/18
to google-a...@googlegroups.com
Hi Ryan,

The feedback we receive was that Node.js developers expect to start their application with "npm start" more than with "dev_appserver.py".

Replicating the handlers in your web framework is indeed the recommendation that we give in our static handler documentation.

That being said, we are currently exploring an optional solution to run your Node.js App Engine app in a local emulator that would emulate the static handlers.

In am curious, can you share more about why your application uses many different static handlers?

Steren

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengi...@googlegroups.com.
To post to this group, send email to google-a...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/60e8d17a-61b1-4bf7-aced-f669092fcbf6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ryan B

unread,
Jul 12, 2018, 7:13:03 PM7/12/18
to Google App Engine
thanks, steren! makes sense.

i'm actually trying the Node runtime for the first time, on a small personal project, so i don't actually have the "lots of static file handlers in Node" use case yet. i'm just sensitive to DRY and seeing duplicated things skew over time.

thanks again!
Reply all
Reply to author
Forward
0 new messages