Skip to content

rash-27/csea-backend-alumni

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CSEA Web Development - CRUD API

This is a solution to the API - CRUD.(Slightly Modifed From Orginal Problem Statement)

Table of contents

Overview

Problem Description

The task involves creating a RESTful API to facilitate Alumni Affairs, where alumni can register, log in, update, and delete their information. Additionally, the API allows current college students to view profiles of registered alumni. Try to implement as many of these.

Theses are routes defined in Problem Statement

  • Alumni Registration (POST)
  • Alumni Login (POST)
  • Alumni Profile Update (PUT)
  • Alumni Deactivation (DELETE)
  • View Alumni Profiles (GET)

Challenges

The main challenge in this problem is the verification of students. Authenticating and authorizing alumni and students is a moderate challenge in this problem.

Enhancements

Apart from Alumni, I created other models for Admin and Student. Admins are like Institute Administrative staff; they can create and deactivate students from the database. Students cannot register by themselves; they can only log in and update their data. Registered and authorized students could get access to all alumni details. Registered and authorized alumni can also get all other alumni details.

There is no registration for Admins. They are already added to the database.

More Routes

Admin Routes

  • Admin Login (POST)
  • Admin StudentRegister (POST)
  • Admin DeleteStudent (DELETE)

Student Routes

  • Student Login (POST)
  • Student Details Update (PUT)
  • All Alumni Details (GET)

My process

Built with

Tools and Technologies

  • NodeJS A JavaScript Runtime Built on Chrome's V8 JavaScript Engine
  • Express.js A Fast, Unopinionated, and Minimalist Web Framework for Node.js
  • MongoDB A Source-available and Document-oriented NoSQL Database

Node Packages

  • Mongoose An Object Data Modeling (ODM) Library for MongoDB and Node.js
  • JsonWebToken An implementation of JSON Web Tokens.
  • Lodash A modern JavaScript utility library delivering modularity, performance & extras.
  • Bcrypt A library to help you hash passwords.
  • Joi The most powerful schema description language and data validator for JavaScript.
  • config Node-config organizes hierarchical configurations for your app deployments.

Continued development

  • Add Unit Tests and Integration Tests - Writing tests in programming is crucial for ensuring code quality and functionality. Unit tests help verify individual components function as expected, catching bugs early. Integration tests confirm different parts of the system work together correctly, identifying issues that may arise from their interaction. Tests provide a safety net for future changes, making sure updates or refactoring don't break existing functionality. They also serve as documentation, illustrating how the code is supposed to work. Overall, testing contributes to building reliable, maintainable software.
  • Add winston logger - A logger for just about everything.For logging errors, info messages, debug messages etc ...
  • Impliment More Validation using Joi - The most powerful schema description language and data validator for JavaScript.

About Project

Project Structure

Project is Structured in Industry Standards in Clean and Readable Code. Following good practices like DRY, KISS, YAGNI, etc. Tip

├── config(Contains all configuration files)
│   └── default.json
|   └── custom-environment-variables.json
├── middlewares(Contains all middlewares)
│   ├── adminAuth.js
│   ├── alumniAuth.js
│   └── globalCatch.js
|   └── studentAuth.js
|   └── invalidRoute.js
|   └── validateObjectId.js
├── models(Contains all models)
│   ├── admin.js
│   ├── alumni.js
│   └── student.js
├── package.json(Contains all dependencies)
├── routes(Contains all routehandlers)
│   ├── admin.js
│   ├── alumni.js
│   └── student.js
├── startup(Contains all startup files)
│   ├── config.js
│   ├── db.js
│   └── routes.js
├── index.js(Entry Point)
├── README.md(Readme File)

Author

Set up Locally

Prerequisites

Installation

  • Clone the repo
    git clone
  • Go to the project directory
    cd csea-backend-alumni
  • Install NPM packages
    npm install
  • If Linux or Mac
    export jwtPrivateKey=yourPrivateKey
    export port=yourPortNumber
    export database=yourMongoDBConnectionString
  • If Windows
    set jwtPrivateKey=yourPrivateKey
    set port=yourPortNumber
    set database=yourMongoDBConnectionString
  • Run the server
    node index.js

Suggestions

  • While running the server on your machine you need fake admin data which you can get from here.Password for all fake data of admin is password itself.After setting up the mongoDB connection string, you can add fake admin data to your database by many ways .One way I suuest is to use MongoDB Compass to import the data from JSON file import to your admin database collection.
  • You can use Postman to test the API
  • You can use MongoDB Compass to view the database

About

CSEA Web Development Tasks,

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%