Skip to content

yumikodev/express-prisma-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Express prisma template

A basic template for Backend with Express, Prisma and TypeScript.

Endpoints

Method Route Body Description
GET /cats null Get all the cats.
GET /cats/:id null Get a cat by id.
POST /cats Body Create a cat.
PATCH /cats/:id Body Update a cat by id.
DELETE /cats/:id null Delete a cat by id.

Create Cat Body

{
  "name": "Catalina",
  "age": 8,
  "race": "Van turco", // idk
}

Update Cat Body

{
  "name": "Catalina", // Optional
  "age": 8, // Optional
  "race": "Van turco", // Optional
}

Configuration

  1. Create a .env file with the following content:

    DATABASE_URL="Your database URL here"
  2. Configure the Prisma provider (in ./prisma/schema.prisma).

    datasource db {
      provider = "sqlite"
      ...
    }
  3. Install the dependencies.

    npm install # If you're using npm
    yarn install # If you're using yarn
    pnpm install # If you're using pnpm
    bun install # If you're using bun
  4. Migrate your prisma schema (Only if your use a SQL database).

    npx prisma migrate dev --name init
  5. Start the server

    • In development

      npm run dev # or with yarn, pnpm, bun
    • In production

      npm run build # Compile TS
      npm start

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published