express-ts-starter

Stars
0

About the Project

Built With

Getting Started

To get a local copy up and running, please follow these simple steps.

Prerequisites

Here is what you need to be able to run the project.

  • Node.js (Version: >=18.x)
  • PostgreSQL
  • pnpm (recommended)

If you want to enable any of the available integrations, you may want to obtain additional credentials for each one. More details on this can be found below under the integrations section.

Development

Setup

  1. Clone the repo into a public GitHub repository (or fork https://github.com/dammy001/express-ts-starter/fork).

    git clone https://github.com/dammy001/express-ts-starter.git
    

    If you are on windows, run the following command on gitbash with admin privileges: > git clone -c core.symlinks=true https://github.com/dammy001/express-ts-starter.git

  2. Go to the project folder

    cd express-ts-starter
    
  3. Install packages with pnpm

    pnpm i
    
  4. Set up your .env file

    • Duplicate .env.example to .env
    • Use openssl rand -base64 32 to generate a key and add it under SECRET_KEY in the .env file.

Quick start with pnpm docker:compose

  • Requires Docker and Docker Compose to be installed
  • Will start a local Postgres and Redis instance with a few test users.
pnpm docker:compose

Manual setup

  1. Configure environment variables in the .env file. Replace <user>, <pass>, <db-host>, and <db-port> with their applicable values

    DATABASE_URL='postgresql://<user>:<pass>@<db-host>:<db-port>'
    
    1. Download and install postgres in your local (if you don't have it already).

    2. Create your own local db by executing createDB <DB name>

    3. Now open your psql shell with the DB you created: psql -h localhost -U postgres -d <DB name>

    4. Now extract all the info and add it to your DATABASE_URL. The url would look something like this postgresql://postgres:postgres@localhost:5432/Your-DB-Name.

  2. Set up the database using the Prisma schema (found in packages/prisma/schema.prisma)

    In a development environment, run:

    pnpm db:migrate
    

    In a production environment, run:

    pnpm db:deploy
    
  3. Run (in development mode)

    pnpm run dev
    

Setting up your first user

  1. Open Prisma Studio to look at or modify the database content:

    pnpm run db:studio
    
  2. Click on the User model to add a new user record.

  3. Fill out the fields email, userName, firstName, lastName and click Save 1 Record to create your first user.

    You might want to adjust this behavior to your needs in the prisma/schema.prisma file.

E2E-Testing

# In a terminal just run:
pnpm test