Global

Members

# avatar_url

URL to user's profile avatar image

View Source models/User.js, line 35

# display_name

User's display name shown in the dashboard

View Source models/User.js, line 30

# email

User's email address - used for authentication and communication

View Source models/User.js, line 23

# constant express

Social Media Dashboard API Server

Main Express.js server for the Social Media Dashboard API. Handles authentication, social media platform integrations, and provides RESTful endpoints for the frontend.

Features:

  • JWT-based authentication
  • OAuth integration with multiple social platforms
  • Rate limiting and security middleware
  • CORS configuration for frontend communication
  • Swagger API documentation
Version:
  • 1.0.0
Author:
  • Ignas Panavas

View Source index.js, line 18

# google_id

Google OAuth ID for Google sign-in integration

View Source models/User.js, line 40

# constant jwt

Authentication Middleware

This module provides JWT-based authentication middleware for the Social Media Dashboard API. It handles token verification, user authentication, and token generation for secure API access.

Version:
  • 1.0.0
Author:
  • Ignas Panavas

View Source middleware/auth.js, line 11

# last_login

Timestamp of user's last login for activity tracking

View Source models/User.js, line 46

# constant mongoose

Database Configuration

This module handles MongoDB database connection for the Social Media Dashboard API. It provides a centralized way to connect to MongoDB with proper error handling and logging.

Version:
  • 1.0.0
Author:
  • Ignas Panavas

View Source config/database.js, line 11

# constant mongoose

User Model

Mongoose schema for user accounts in the Social Media Dashboard. Handles user authentication, profile information, and social media account associations.

Version:
  • 1.0.0
Author:
  • Social Media Dashboard Team

View Source models/User.js, line 11

Object

# constant socialConfigs

Social Media Platform Configurations

Contains OAuth and API configuration for supported social media platforms:

  • Instagram Business API
  • TikTok for Business API
  • YouTube Data API v3
  • Facebook Graph API
  • Snapchat Kit API

Each platform configuration includes:

  • OAuth client credentials (from environment variables)
  • Authorization and token URLs
  • Required OAuth scopes
  • API base URLs for data fetching
Properties:
Name Type Description
instagram Object

Instagram Business API configuration

tiktok Object

TikTok for Business API configuration

youtube Object

YouTube Data API v3 configuration

facebook Object

Facebook Graph API configuration

snapchat Object

Snapchat Kit API configuration

View Source config/social.js, line 36

mongoose.Schema

# constant userSchema

User Schema Definition

Defines the structure for user documents in MongoDB. Includes authentication fields, profile information, and social media account references.

View Source models/User.js, line 21

Methods

# async authenticateToken(req, res, next) → {void}

Authenticate JWT Token Middleware

Verifies JWT tokens from the Authorization header and attaches the authenticated user to the request object. This middleware should be used on protected routes that require user authentication.

Parameters:
Name Type Description
req Object

Express request object

res Object

Express response object

next function

Express next middleware function

View Source middleware/auth.js, line 33

Calls next() if authentication succeeds, sends error response if it fails

void
Example
// Protect a route
router.get('/protected', authenticateToken, (req, res) => {
  // req.user is now available with the authenticated user
  res.json({ user: req.user });
});

# async connectDB() → {Promise.<void>}

Connect to MongoDB Database

Establishes a connection to the MongoDB database using the URI from environment variables. Falls back to localhost if no MONGODB_URI is provided. Includes proper error handling and logging.

View Source config/database.js, line 14

If connection fails, the process will exit with code 1

Error

Resolves when connection is established

Promise.<void>
Example
// In your main server file
const connectDB = require('./config/database');
connectDB().then(() => {
  console.log('Server ready');
});

# generateRefreshToken(userId) → {string}

Generate JWT Refresh Token

Creates a new JWT refresh token for the specified user. Refresh tokens are used to obtain new access tokens without requiring the user to log in again. They have a longer expiration time.

Parameters:
Name Type Description
userId string

The MongoDB ObjectId of the user

View Source middleware/auth.js, line 93

JWT refresh token

string
Example
const refreshToken = generateRefreshToken('507f1f77bcf86cd799439011');
// Returns: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

# generateToken(userId) → {string}

Generate JWT Access Token

Creates a new JWT access token for the specified user. Access tokens are used for API authentication and have a shorter expiration time for security.

Parameters:
Name Type Description
userId string

The MongoDB ObjectId of the user

View Source middleware/auth.js, line 72

JWT access token

string
Example
const token = generateToken('507f1f77bcf86cd799439011');
// Returns: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."