Skip to content

GiorgiZanqaidze/e-commerce-express-1.1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Express SQL API with Prisma

This is an Express API project that uses Prisma ORM to interact with an SQL database. It’s set up to manage data efficiently with an SQL backend.

📋 Table of Contents

⚙️ Prerequisites

  • Node.js (v14+)
  • Prisma CLI (for database management)
  • SQL Database (PostgreSQL, MySQL, SQLite, or compatible with Prisma)

📥 Installation

  1. Clone the repository:

    git clone <repository-url>
    cd <project-directory>
  2. Install dependencies:

    npm install

🔧 Configuration

  1. Set up your environment variables by creating a .env file in the root directory:

    DATABASE_URL="mysql://USER:PASSWORD@localhost:3306/DATABASE_NAME"
    

    Replace USER, PASSWORD, and DATABASE_NAME with your SQL credentials.

  2. Configure the Prisma schema in prisma/schema.prisma:

    datasource db {
      provider = "mysql" // or your database provider
      url      = env("DATABASE_URL")
    }

🗄️ Database Setup

  1. Run migrations to set up your database tables:

    npx prisma migrate dev --name init
  2. Generate Prisma client:

    npx prisma generate
  3. Optional: Seed your database (if you have a seed script):

    npm run seed

📜 Scripts

  • npm run dev – Start the server in development mode with hot reloading.
  • npm run start – Start the server in production mode.
  • npx prisma studio – Open Prisma Studio for database management.
  • npx prisma migrate dev – Create a new migration.
  • npx prisma db push – Push schema changes directly to the database.

💻 Usage

  1. Start the server:

    npm run dev
  2. Use an API client like Postman or Insomnia to interact with the endpoints (examples below).

📂 Folder Structure

project-root
├── prisma
│   ├── schema.prisma       # Prisma schema file
│   └── migrations          # Migration files
├── src
│   ├── controllers         # Route controllers
│   ├── routes              # API routes
│   ├── middlewares         # Middleware functions
│   ├── services            # Business logic
│   └── index.js            # Server entry point
├── .env                    # Environment variables
└── package.json            # Dependencies and scripts

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published