- Create
./.env.development
file- Add config
PGDATABASE=database_name
with yourdatabase_name
- Add config
- Create
./.env.test
file- Add config
PGDATABASE=test_database_name
with yourtest_database_name
- Add config
- Create
./src/db/setup.sql
using this template where you need to set yourdatabase_name
andtest_database_name
DROP DATABASE IF EXISTS test_database_name;
DROP DATABASE IF EXISTS database_name;
CREATE DATABASE test_database_name;
CREATE DATABASE database_name;
npm run setup-dbs
npm run seed
- Server should return errors wrapped in error object.
Example
{ error: { status: 404, msg: '404 Not Found' } }
- Server should return data wrapped in named object.
Example
{ topics: [ { description: 'The man, the Mitch, the legend', slug: 'mitch' }, ... ] }
- Use Spotify approach - https://github.com/spotify/should-up
(Example: https://google.github.io/styleguide/jsguide.html)
- Avoid
SELECT * FROM topics;
useSELECT slug, description FROM topics;
- Reasons:
- Maintenance Issues:
- Schema Changes: If the table schema changes, your application might break.
- Model Compatibility: If you’re using an ORM (Object-Relational Mapping), changes to the table structure can impact your models.
- Security Risks:
- Sensitive Data: If new sensitive columns are added, they’ll be included.
- Maintenance Issues:
- Reasons: