All Projects → aaron5670 → ExpressJS-SocketIO-Boilerplate

aaron5670 / ExpressJS-SocketIO-Boilerplate

Licence: other
📦 Simple Express.js & Socket.io Boilerplate

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to ExpressJS-SocketIO-Boilerplate

node-express-mongo-passport-jwt-typescript
A Node.js back end web application with REST API, user JWT authentication and MongoDB data storage using TypeScript
Stars: ✭ 51 (+64.52%)
Mutual labels:  passport, node-js, passportjs, express-js
express-boilerplate
ExpressJS boilerplate with Socket.IO, Mongoose for scalable projects.
Stars: ✭ 83 (+167.74%)
Mutual labels:  socket, socket-io, node-js, express-js
MERN-BUS-APP
This is a MFRP (My first Real Project) assigned to me during my internship at Cognizant. Made with MERN Stack technology.
Stars: ✭ 92 (+196.77%)
Mutual labels:  node-js, passportjs, express-js
teaching-nodejs-expressjs-framework-spring-2019-2020
Complete Node-Express Application
Stars: ✭ 16 (-48.39%)
Mutual labels:  node-js, express-js, nodejs-server
express-mongo-jwt-boilerplate
Express Mongo JsonWebToken boilerplate
Stars: ✭ 100 (+222.58%)
Mutual labels:  boilerplate-template, auth, passport
Oksocket
An blocking socket client for Android applications.
Stars: ✭ 2,359 (+7509.68%)
Mutual labels:  socket, socket-io, socket-server
HIMS
Hospital Information Management System create using Node Js
Stars: ✭ 41 (+32.26%)
Mutual labels:  node-js, passportjs, express-js
aioudp
Asyncio UDP server
Stars: ✭ 21 (-32.26%)
Mutual labels:  socket, socket-io, socket-server
RRQMSocket
TouchSocket是.Net(包括 C# 、VB.Net、F#)的一个整合性的、超轻量级的网络通信框架。包含了 tcp、udp、ssl、http、websocket、rpc、jsonrpc、webapi、xmlrpc等一系列的通信模块。一键式解决 TCP 黏分包问题,udp大数据包分片组合问题等。使用协议模板,可快速实现「固定包头」、「固定长度」、「区间字符」等一系列的数据报文解析。
Stars: ✭ 286 (+822.58%)
Mutual labels:  socket, socket-io
socket.io-client-core
High-Performance Socket.IO client in C#
Stars: ✭ 70 (+125.81%)
Mutual labels:  socket, socket-io
fridaybot
Slack bot for https://spb-frontend.slack.com
Stars: ✭ 29 (-6.45%)
Mutual labels:  socket-io, node-js
socketChat
💬 A real-time messaging application built using Socket.IO and Express
Stars: ✭ 31 (+0%)
Mutual labels:  socket-io, express-js
vue3-chat
2021👨‍🎓Vue2/3全家桶 + Koa+Socket+Vant3前后端分离移动端聊天应用。vue+node全栈入门项目
Stars: ✭ 46 (+48.39%)
Mutual labels:  socket, socket-io
babyfoot
Simple CQRS/ES Node+Express+TypeScript REST API
Stars: ✭ 14 (-54.84%)
Mutual labels:  node-js, express-js
express-ts-api-boilerplate
Express TypeScript API Boilerplate
Stars: ✭ 15 (-51.61%)
Mutual labels:  express-js, nodejs-server
angular-chat
Angular v.9, Node.js, Nest.js v.6, Mongoose, Socket.io, Passport, Angular Universal SSR (in progress...)
Stars: ✭ 35 (+12.9%)
Mutual labels:  socket, socket-io
mern-ecommerce
MERN Stack ecommerce site
Stars: ✭ 122 (+293.55%)
Mutual labels:  node-js, express-js
socketio
No description or website provided.
Stars: ✭ 23 (-25.81%)
Mutual labels:  socket, socket-io
BotBlock.org
BotBlock - The List of Discord Bot Lists and Services
Stars: ✭ 29 (-6.45%)
Mutual labels:  node-js, express-js
CleanArchitecture-SocketIO
CleanArchitecture with SocketIo 📡
Stars: ✭ 32 (+3.23%)
Mutual labels:  socket, socket-io

📦 Express.js & Socket.io Boilerplate

Simple Express.js & Socket.io Boilerplate.

Features

  • Express 4.16
  • Mongoose 5.7
  • Passport.js with Bcrypt.js
    • Login endpoint
    • Register endpoint
    • Username availability check endpoint
    • Authenticated endpoint
    • Logout endpoint
  • Socket.io integration for real-time, bidirectional and event-based communication.
  • Generates automatically API docs based on Express existing routes with Swagger UI.
  • Social login / register integration.

📝 Getting Started

git clone https://github.com/aaron5670/ExpressJS-SocketIO-Boilerplate.git

cd expressjs-socketio-boilerplate

npm install

// Optional: if you want dummy data, then run this seed file
node seed.js

node server.js

Create Socket.io connection

Install on your client-side (web) application the module socket.io-client.

npm install socket.io-client

Then create a connection with the following code:

// with ES6 import
import io from 'socket.io-client';
 
const socket = io('http://localhost:3005');

For more info you can read the official Socket.io documentation:

📓 How to document the Swagger UI endpoint API

/**
 * @typedef ResponseJSON
 * @property {string} username - user's username - eg: janet
 * @property {string} message - message - eg: This is a authenticated route!
 */
/**
 * Dashboard endpoint only allowed for authenticated users
 * @route GET /api/v1/auth/dashboard
 * @group Auth
 * @returns {ResponseJSON.model} 200
 * @produces application/json
 */
router.get('/dashboard', authenticationMiddleware(), (req, res) => {
    return res.json({
        username: req.session.passport.user.username,
        message: 'This is a authenticated route!'
    });
});

If you are running this boilerplate on you localhost you can see the Swagger UI documentation on: http://localhost:3005/api-docs/.

Note: Check if your port number is the same as your configuration.

📌 Swagger UI example

Swagger UI Docs

🚀 Endpoints

The following endpoints are available

Login

url:    /api/v1/auth/login
method: POST

This request expects the following body:

{
  "username": "jane", 
  "password": "securepassword1"
}

It will response the client the following object after a successful login:

{
  "success": true,
  "username": "jane",
  "message": "Successful login, welcome!"
}

Register

url:    /api/v1/auth/register
method: POST

This request expects the following body:

{
  "name": "John Doe",
  "username": "john",
  "password": "password123"
}

It will response the client the following object after a successful register:

{
  "success": true,
  "message": "User is successfully registered!"
}

Username availability check

url:             /api/v1/auth/username-availability
method:          GET
query parameter: username

This request expects a request like:

https://localhost:3005/api/v1/auth/username-availability?username=john

It will response the client the following object after a successful request:

{
  "usernameAlreadyInUsage": true
}

Logout

url:    /api/v1/auth/logout
method: GET

It will response the client the following object after a successful request:

{
  "success": true
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].