DoSomething / bertly

🔗 A serverless link shortener.
https://dosome.click/wq544
MIT License
2 stars 1 forks source link

Configure framework & local development for Bertly 2.0. #58

Closed DFurnes closed 4 years ago

DFurnes commented 4 years ago

What's this PR do?

This pull request kicks off the Bertly 2.0 rewrite in Node.js & DynamoDB. This just sets up all the things we'll need for development later on... our "framework", if you will!

Here's where we'll end up (with the functions themselves to come in follow-up PRs):

Screen Shot 2020-05-11 at 6 05 58 PM

How should this be reviewed?

This pull request is broken up into commits to separate some of the noisier "cruft" (setting up the local development environment, file structure, and server) from the "meat" of the application:

🐭 Adds an EditorConfig, because we didn't have one! a5a9cda

⚙️ Updates .env.example and adds a config/ directory. This follows the pattern we've established in DoSomething/graphql, and makes it easier to understand what configuration options this app offers at a glance. f2874c6

💰 Adds dependencies & configures Babel (mainly for ES Modules) & Prettier. 38c7025

🐚 Adds the basic Express application shell & middleware. This is exported and used by our three different "entry points" – interactive local development, the Jest test suite, and Lambda functions. Also includes basic 404 & error handler middleware. 8d60b4f

💻 Adds a "local" entry point & configures local-dynamo server so that we can run this without messing with real AWS resources. This database is persisted in bootstrap/storage/database/ between runs. 667a0b4

🚥 Configures Jest's test runner & adds some helpers for writing functional tests for this application (where we make a HTTP request & assert something happened). I've also added a simple dropTable and fresh helpers for testing, inspired by Laravel. a2d46d4

Any background context you want to provide?

Originally had the actual endpoints & database model in here as well, but removed those for follow-up PRs in order to keep this a bit more manageable to review.

Relevant tickets

References Pivotal #169047065.

Checklist

DFurnes commented 4 years ago

Tests were running awfully slow – was able to get them up to speed in d551214 by swapping Jest's test environment to node (rather than the default jsdom, which spins up a virtual DOM environment) & sharing a single local-dynamo server between all test runs.

Before:

Screen Shot 2020-05-11 at 6 25 09 PM

After:

Screen Shot 2020-05-11 at 6 25 29 PM

sheyd commented 4 years ago

@DFurnes Added a bunch of n00b questions, and want to do two things before giving this the 👍:

The second thing shouldn't be a blocker to approval though.

DFurnes commented 4 years ago

Setup locally to test the setup

This will probably not be all too exciting, since there aren't any endpoints to actually use. But I'd be happy to pair with you on setting this up once I get one of the follow-up PRs pushed!