g5l / phone-book-backend

Backend build using Node.js, Prisma and SQLite for the phone-book project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Phone Book Backend

This is a simple CRUD (Create, Read, Update, Delete) API for a phonebook application. It's built with Node.js, Prisma, TypeScript, and SQLite. The API allows you to manage a list of contacts, where each contact has an id, name, and phone data.

Prerequisites

Before you start, ensure you have these installed on your system:

  1. Node.js and npm (Node Package Manager)
  2. TypeScript
  3. Prisma
  4. SQLite

Setup

To set up the project on your local machine:

  1. Clone the repository:
git clone https://github.com/yourusername/phonebook-api.git
cd phonebook-api
  1. Install the dependencies:
npm install
  1. Generate the Prisma client:
npx prisma generate
  1. Run the API:
npx ts-node index.ts

Your API should now be running on http://localhost:3000.

Usage

Here are some examples of how you can use the API:

  • Create a new contact:
curl -X POST -H "Content-Type: application/json" -d '{"name":"John Doe", "phone":"1234567890"}' http://localhost:3000/contacts
  • Get all contacts:
curl http://localhost:3000/contacts
  • Update a contact:
curl -X PUT -H "Content-Type: application/json" -d '{"name":"Jane Doe", "phone":"0987654321"}' http://localhost:3000/contacts/1
  • Delete a contact:
curl -X DELETE http://localhost:3000/contacts/1

About

Backend build using Node.js, Prisma and SQLite for the phone-book project


Languages

Language:TypeScript 98.2%Language:JavaScript 1.8%