Boilerplate application for Node/Express on Google Cloud App Engine
Google Cloud Platform project setup and the Google Quickstart "Before You Begin" steps followed.
You'll also need to change the projectId
in /config/default.js
to your Google project id.
npm install
npm run dev
- Develop! 🎉
npm run verify
to ensure your changes didn't break anything!
We prefer to use [Mocha] combined with [Sinon] and [Chance] to unit test our applications. You can auto-run the tests using a tool called [Nodemon] which will auto-run the tests. Some helpful commands to use when you want to run a specfic set of tests are
nodemon --watch test --exec "Describe Block"
for this sample project you could use
nodemon --watch test --exec "Index Router"
which would run all the tests under
describe('Index Router', () => {
test('should run this test', () => {});
describe('GET /', () => {
test('should also run this test', () => {});
});
});
Logs for this application can be found in your GAE log page. There aren't many options for logging to Google Cloud that are still actively maintained other than the @google-cloud/logging
package, so this project takes advantage of that. It follows the same interace as console
so it won't be hard to swap to.
gcloud app deploy
gcloud app browse
Create a service account that you'll use to deploy the application with after it has been built. It will need the following IAM roles:
- App Engine Admin
- Cloud Build Editor
- Storage Admin
- Service Account User
After you've downloaded the credentials, copy the entire contents into an environment variable called GCP_SA_KEY
in your repositories' actions' secrets.
The first build in Github Actions will fail and it will tell you to enable the App Engine Admin API, do that and re-run