Skip to content

otakmager/be-cms

Repository files navigation

Contact Management System (BE-CMS)

This is a backend application for a Contact Management System, built with Node.js, Express, TypeScript, and Prisma. It provides a RESTful API for user authentication and managing contacts, along with an admin endpoint for API statistics.

Features

  • User Authentication: Register new users and log in with existing credentials.
  • Contact Management (CRUD):
    • Create new contacts.
    • Retrieve a list of all contacts (with pagination and search).
    • Get details of a specific contact by ID.
    • Update existing contacts.
    • Delete contacts.
  • Admin API Statistics: An authenticated endpoint to view API usage statistics.
  • JWT-based Authorization: Secure API endpoints using JSON Web Tokens.
  • Logging: Structured logging using pino.
  • API Documentation: Automatically generated API documentation using Swagger.

Technologies Used

  • Backend: Node.js, Express.js
  • Language: TypeScript
  • Database ORM: Prisma
  • Database: MariaDB (or any other supported by Prisma)
  • Authentication: JWT (JSON Web Tokens)
  • Logging: Pino
  • API Documentation: Swagger
  • Testing: Jest, Supertest
  • Code Quality: Prettier

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

  • Node.js (v20.x or higher recommended)
  • DBMS

Installation

  1. Clone the repository:

    git clone https://github.com/otakmager/be-cms.git
  2. Install dependencies:

    npm install

Environment Variables

Create a .env file in the root directory of the project based on .env.example file.

Database Setup

  1. Generate Prisma Client:

    npm run gen
  2. Run database migrations:

    npm run migrate

    Follow the prompts to apply the migrations.

Running the Application

Development Mode

To run the application in development mode with hot-reloading:

npm run dev

The API will be available at http://localhost:3000 (default).

Production Mode

  1. Build the project:
    npm run build
  2. Start the server:
    npm start

API Documentation

Once the server is running, you can access the API documentation (Swagger UI) at: http://localhost:3000/docs

Running Tests

To run all unit tests:

npm test

To run tests and view coverage report:

npm test -- --coverage

About

Backend application for a Contact Management System

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors