Skip to content

AliBalash/node-websocket-api

Repository files navigation

Node WebSocket API

Node WebSocket API is an Express and Socket.IO backend for exhibition-form operations with JWT authentication, role-based access control, image uploads, and real-time admin notifications.

Highlights

  • Express 5 backend
  • JWT-based authentication
  • Role-based permissions for admin, expert, and promoter
  • MySQL-backed form storage
  • Socket.IO notifications for create, update, and delete events
  • Docker Compose setup with MySQL and phpMyAdmin

Tech Stack

  • Node.js
  • Express
  • Socket.IO
  • MySQL
  • JWT
  • Joi
  • Multer
  • Docker Compose

Project Structure

  • backend/server.js: application bootstrap and route registration
  • backend/routes/auth.js: login and registration endpoints
  • backend/routes/forms.js: protected form-management routes
  • backend/controllers/: auth and form business logic
  • backend/services/: auth middleware, upload handling, and socket integration
  • docker-compose.yml: local stack for backend, MySQL, and phpMyAdmin

Features

  • User registration and login
  • Protected form submission
  • Admin-only listing, update, and delete operations
  • File upload support for form records
  • Real-time admin events for form lifecycle changes

Getting Started

Prerequisites

  • Node.js
  • Docker with Compose plugin

Setup

  1. Clone the repository.
  2. Copy the environment templates:
cp .env.example .env
cp backend/.env.example backend/.env
  1. Start the local stack:
docker compose up --build
  1. Or run only the backend locally:
cd backend
npm install
npm run dev

Environment Variables

Root .env.example:

  • PORT
  • PHPMYADMIN_PORT
  • MYSQL_ROOT_PASSWORD
  • MYSQL_DATABASE
  • MYSQL_USER
  • MYSQL_PASSWORD

Backend backend/.env.example:

  • PORT
  • JWT_SECRET
  • DB_HOST
  • DB_USER
  • DB_PASSWORD
  • DB_NAME

API Overview

  • POST /api/login
  • POST /api/register
  • GET /api/forms
  • POST /api/forms
  • PUT /api/forms/:id
  • DELETE /api/forms/:id

Development

docker compose up --build
cd backend && npm run dev

Testing

No automated test suite has been added yet.

Current validation is primarily done through local API checks, database-backed integration testing, and Socket.IO event verification.

Security Notes

  • Keep JWT_SECRET private and set it through environment files only
  • Do not commit real .env files
  • Restrict admin-only routes to trusted users

License

No license has been specified yet.

Author

Developed by Ali Balash.

About

Express and Socket.IO backend for exhibition-form workflows with JWT auth, MySQL storage, and Dockerized local setup.

Topics

Resources

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages