/neith

Primary LanguageTypeScript

Technologies

The app uses:

  • Postgres for the database
  • trpc for the API layer
  • knex for queries
  • Vite for development and Vitest for testing
  • Tailwind for styling
  • Cypress for End to End and Component Testing
  • Vue.js with the Composition API and <script setup> for the syntax
  • Express for the HTTP server

Getting Started

This project just uses plain old npm. Clone it and run npm install. You'll also need to create a database.

Database

The schema is managed with knex.

Creating a Database

  • Create a database (by default we assume your database is called notifier_test).
    • You can run createdb notifier_test to create, and dropdb notifier_test to delete it).
  • Update knexfile.js with your credentials.
  • Run npm run db:migrate to run the migrations.

Development

The development process is managed by Gulp. You only need to run npx gulp dev to get started. You may need some environment variables, depending on how you configured your database, etc:

NODE_ENV=development POSTGRES_DB=notifier_test POSTGRES_PASSWORD=<password> POSTGRES_USER=lachlan npx gulp dev

Adding a Migration

If you need to add a new table or modify an exist one, do so via a migration.

  • Run npm db:make <name>
  • Example: npx knex migrate:make addOrganizationTable
  • Fill out the up and down migrations
  • Write a test for both!

Testing a Migration

See here for an example. You should use the testMigration function.

import { expect } from "vitest";
import { testMigration } from "./utils";

testMigration("20221220105733_addOrganizationTable", (verify) => {
  verify.up(async (client) => {
    // verify update works
  });

  verify.down(async (client) => {
    // verify rollback works
  });
});

Tests

  • Run the Cypress End to End test with npm run test:e2e.
  • Run the Node.js tests (eg, migrations etc) with npm run test:component
  • Run the Component tests with npm run test:unit

Deployment

  • Build the server and frontend with npm run build.
  • To start the server, cd src/server and run NODE_ENV=production POSTGRES_USER=<user> POSTGRES_PASSWORD=<password> EMAIL_USER=<user> EMAIL_PASSWORD=<password> node express.js.