programs, automated test or batch scripts, and to be developed and tested in isolation from its eventual run-time devices and databases." Alistair Cockburn Creator of Hexagonal architecture
main = require('./main') export async function handler(event) { // Create instance of SNS notification repository const notification = new EventBridgeRepository( process.env.topic ) // Invoke main function with all dependencies await main(event, parseApiEvent, notification) return httpResponse() }
mdb = new MongoDbRepository(something) const ddb = new DynamoDbRepository(somethingElse) const user1 = mdb.getUser(userId) const user2 = ddb.getUser(userId) expect(user1).toEqual(user2) // They are equal! For example, this:
costs low (or at least reasonable) • Hexagonal architecture is a nice fit for serverless apps • Test your integrations (and app in general) • Testing is not enough, you'll need monitoring and error tracking for your serverless apps