Skip to content

Separate out concerns in app.js #146

Description

@tbtommyb

Each of your handlers in app.js is doing quite a bit while database.js is only wrapping Airtable.

A good practice is to try and expose as little as possible of each bit of your app. So e.g. app.get("/api/get-station/:station" would be responsible for validating that station is a valid parameter and then it would call database.getStation(station) and returning either JSON or a useful error. Within the database module you'd have functions that would access the various things from Airtable.

This means that the server is only responsible for communicating with the client and all of the business logic is separate. Ideally the business logic shouldn't 'know' that it's in a web server. This also means you can change database or web server without having to rewrite everything.

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions