8000 GitHub - EODavis/Contacts-api · GitHub
[go: up one dir, main page]

Skip to content

About

No description, website, or topics provided.

Resources

Stars

4 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contacts API

A RESTful API for managing contacts, built with Node.js, Express, and SQLite. Project 4 in a sequential backend engineering learning journey — the first project in the series with real persistent storage instead of an in-memory array.

Features

  • Full CRUD for contacts (Create, Read, Update, Delete)
  • Persistent storage via SQLite (data survives server restarts)
  • Async/await throughout, with try/catch + centralized error handling
  • Parameterized SQL queries (SQL-injection safe)
  • Email format validation
  • Clean MVC-style structure (config / routes / controllers / models)

Tech Stack

  • Node.js
  • Express
  • SQLite (via sqlite3 + sqlite)

Getting Started

npm install
npm run dev

Server runs on http://localhost:3003. A data.db SQLite file is created automatically on first run.

API Endpoints

Method Endpoint Description
GET /api/contacts Get all contacts
GET /api/contacts/:id Get a single contact
POST /api/contacts Create a new contact
PUT /api/contacts/:id Update a contact
DELETE /api/contacts/:id Delete a contact

Example request body (POST/PUT)

{
  "name": "Jane Doe",
  "email": "jane@example.com",
  "phone": "555-1234"
}

Project Structure

src/ ├── config/ - Database connection setup ├── models/ - SQL queries (async) ├── controllers/ - Request handling, validation, error routing ├── routes/ - URL-to-controller mapping └── middleware/ - Centralized error handling

This project introduces

  • A real SQLite database with a persistent .db file
  • Async/await across the model and controller layers
  • try/catch + next(err) in every controller function, routing failures to the (unchanged) centralized error handler

About

No description, website, or topics provided.

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0