Skip to content

Backend Development

En Rong edited this page Nov 19, 2022 · 1 revision

Getting Started

Refer to our main wiki page on the setup instructions.

Stack

Area Choice What is it
Language TypeScript Statically typed JavaScript
Backend Framework Nest.js A progressive Node.js framework for building efficient, reliable and scalable server-side applications.
ORM Objection.js An SQL-friendly ORM (Object Relation Mapping) for Node.js
SQL Query Builder Knex.js Build SQL queries for App logic and migrations
Database PostgreSQL Popular open source relational database

Testing

We currently have a rough set of end-to-end (e2e) tests for the backend:

  • You can run them via yarn test:e2e --force-exit
  • TODO: Let's aim to get our backend test coverage up with more comprehensive testing

Creating a new database migration file

  • cd to the backend directory
  • yarn migrate:make <migration-description>
  • You can refer to the past migration files on how to write these migrations using Knex.js
  • Run yarn migrate after completing the migration file.
  • You might find these additional commands useful during development:
    • npx knex migrate:down: Undos the last migration that was run
    • npx knex migrate:up: Runs the next chronological migration that has yet to be run

Creating a new database seed file

  • cd to the backend directory
  • yarn seed:make <seed-file-name>
  • You can refer to the past seed files on how to write these database seeds using Knex.js
  • Run yarn seed after completing the seed file
    • WARNING: run this with caution as yarn seed will wipe your existing database table entries for the corresponding seeded tables