Skip to content

mdnoyonhossain/blood-donation-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Blood Donation Server

The Blood Donation Application Server is a robust server-side application designed to facilitate blood donation processes efficiently. It provides user authentication and authorization features using JSON Web Tokens (JWT) to ensure secure access to its functionalities.

The main purpose of the application is to connect blood donors with those in need by enabling users to find blood donors and request blood donations. Users can register an account, update their profiles, and participate in blood donation requests seamlessly.

Table of Contents

Key Features

Every route within the system is safeguarded through JWT token verification and role based authorization, guaranteeing secure access and protection against unauthorized usage.

Database Tables:

  1. user: Responsible for storing user information securely, facilitating a reliable authentication system.

  2. request: Manages blood donation requests, tracking donor and requester information, as well as request status.

  3. profile: Stores user profile information, including bio, age, and last donation date

Technology Used

  • Express.js
  • Prisma
  • JWT (JSON Web Tokens)
  • Bcrypt
  • Zod
  • Dev Tools
    • TypeScript
    • ts-node-dev

API Documentation

This documentation, generated with Postman.

  https://documenter.getpostman.com/view/15069256/2sA35MzzC9

Or,

Click API Documentation

Live Server Test

To test the live API endpoints, I prefer using Postman for testing with better user experience.

Live API

https://blood-donation-server-orpin.vercel.app/

API Endpoints

for user

  • POST /api/register
  • POST /api/login

for profile

  • GET /api/my-profile
  • PUT /api/my-profile

for request

  • POST /api/donation-request
  • GET /api/donation-request
  • GET /api/donor-list
  • PUT /api/donation-request/:requestId

Getting Started

These instructions will help you set up and run the application on your local machine.

Prerequisites

  • Node.js and npm installed on your machine.

Installation locally

  1. Clone the repository:
https://github.com/mdnoyonhossain/blood-donation-server.git
  1. Navigate to the project directory:
cd blood-donation-server
  1. Install dependencies:
npm install
  1. Create a .env file in the root directory and configure environment variables:
DATABASE_URL=...
PORT=...
JWT_ACCESS_SECRET=...
JWT_ACCESS_EXPIRES_IN=...
SALT_ROUNDS=...

Running the Application

  1. Convert the typescript file to javascript file
npm run build
  1. Running typescript in development environment
npm run start
  1. Running javascript in production environment
node ./dist/server.js