rahimratnani / express-typescript-starter

A boilerplate for building RESTful APIs using Node.js, TypeScript, Express, and Prisma.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Express TypeScript Starter

A boilerplate for building RESTful APIs using Node.js, TypeScript, Express, and Prisma.

Getting Started

Prerequisites

  • Node version 18.0.0 or above
  • A PostgreSQL database server running

Clone the repo

$ git clone --depth 1 git@github.com:rahimratnani/express-typescript-starter.git
$ cd express-typescript-starter
$ npx rimraf ./.git

Install the dependencies

$ npm install

Set the environment variables

$ cp .env.example .env

# open .env and modify the environment variables

Environment variables:

  • PORT: Your node server will run on this port. Default is 3000
  • NODE_ENV: Default is development
  • DATABASE_URL: Connection URL of PostgreSQL

Create and seed the database

$ npx prisma migrate dev

This command will,

  • Create a new PostgreSQL database with User and Post tables that are defined in src/prisma/schema.prisma
  • Trigger seeding. The seed file in src/prisma/seed.ts will be executed and the database will be populated with the sample data.

Start the REST API server

$ npm run dev

License

MIT License

About

A boilerplate for building RESTful APIs using Node.js, TypeScript, Express, and Prisma.

License:MIT License


Languages

Language:TypeScript 98.5%Language:Shell 1.5%