Make generated Express apps production-ready#40
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem & Solution Overview
Generated Express apps are now production-ready:
.envvia dotenv, and the mongoose config usesMONGODB_URI(falling back to a local DB)./healthendpoint returning{ status: 'ok' }.SIGINT/SIGTERM(closes the server, and the Mongo connection for--db).0.0.0.0so it works in Docker.start,dev, andtestscripts.node --test+ supertest) hitting/healthand/.These apply to the Express templates only; Node apps are unchanged.
Testing Done
npm test: 231 passing (8 new integration tests covering the health endpoint, dotenv/export, 0.0.0.0 + signal handlers, error middleware, the start/dev/test scripts + supertest, the generated test file,MONGODB_URI, and that node apps don't get the express scaffolding).npm run test:package(release smoke): from the installed tarball, generates an Express app, installs it, runs the generated app's ownnpm test, boots it, asserts 200 on/and/health, and confirms a clean exit-0 shutdown onSIGTERM.npm test2/2,/health200, graceful SIGTERM).