Skip to content

This is a server built with Node.js and TypeScript. It provides a platform for families to manage their daily activities and promote better communication and organization.

License

Notifications You must be signed in to change notification settings

lucasreis64/familypeace-backend

Repository files navigation

Family Peace - Backend

This is a BackEnd Application built with Node.js and TypeScript. It provides a platform for families to manage their daily activities and promote better communication and organization.

Getting Started

  1. Clone this repository
  2. Install all dependencies
npm i
  1. Create a PostgreSQL database with whatever name you want
  2. Configure the .env.development file using the .env.example file (see "Running application locally or inside docker section" for details)
  3. Run all migrations
npm run migration:run
  1. Seed db
npm run dev:seed
  1. Run the back-end in a development environment:
npm run dev

How to run tests

  1. Follow the steps in the last section
  2. Configure the .env.test file using the .env.example file (see "Running application locally or inside docker" section for details)
  3. Run all migrations
npm run migration:run
  1. Run test: (locally)
npm run test

Building and starting for production

npm run build
npm start

Running migrations or generate prisma clients

Before running migrations make sure you have a postgres db running based on .env.development or .env.test file for each environment. You can start a postgres instance by typing npm run dev:postgres or npm run test:postgres. The host name is the name of the postgres container inside docker-compose file if you are running the application inside a docker container or localhost if you are running it locally.

You can operate on databases for different environments, but it is necessary to populate correct env variables for each environment first, so in order to perform db operations type the following commands:

  • npm run dev:migration:run - run migrations for development environment by loading envs from .env.development file. It uses dotenv-cli to load envs from .env.development file.

  • npm run test:migration:run - the same, but for test environment

  • npm run dev:migration:generate -- --name ATOMIC_OPERATION_NAME - generate and run migration and prisma client for development environment by loading envs from .env.development file. Replace ATOMIC_OPERATION_NAME by the name of the migration you want to generate.

Switching between environments

In order to switch between development and test environments you need to shutdown the current postgres instance if it is running and start the new one.

If you are in development environment:

npm run dev:postgres:down

And then

npm run test:postgres

If you are in test environment:

npm run test:postgres:down

And then

npm run dev:postgres

Technologies

  • Node.js
  • TypeScript
  • Express
  • Prisma
  • PostgreSQL

License

This project is licensed under the MIT License.

About

This is a server built with Node.js and TypeScript. It provides a platform for families to manage their daily activities and promote better communication and organization.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published