Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions server/docs/swagger.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import swaggerJsDoc from 'swagger-jsdoc'
import swaggerUi from 'swagger-ui-express'

const options = {
definition: {
openapi: '3.0.0',
info: {
title: 'StreamX API Documentation',
version: '1.0.0',
description: 'API documentation for StreamX application',
contact: {
name: 'StreamX Team',
},
},
servers: [
{
url: 'http://localhost:3000',
description: 'Development server',
},
],
components: {
securitySchemes: {
bearerAuth: {
type: 'http',
scheme: 'bearer',
bearerFormat: 'JWT',
},
},
},
security: [
{
bearerAuth: [],
},
],
},
apis: ['./routes/*.js', './controllers/*.js'],
}

const specs = swaggerJsDoc(options)

export { specs, swaggerUi }
2 changes: 2 additions & 0 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
"passport-jwt": "^4.0.1",
"path": "^0.12.7",
"redis": "^5.0.0",
"swagger-jsdoc": "^6.2.8",
"swagger-ui-express": "^5.0.1",
"jest": "^29.7.0",
"morgan": "^1.10.0",
"nodemon": "^3.1.4",
Expand Down
91 changes: 91 additions & 0 deletions server/routes/admin.route.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,100 @@ import { getAllEditors, getAllOwners, getAllRequests, getAllVideos } from '../co

const router = express.Router()

/**
* @swagger
* /api/admin/owners:
* get:
* summary: Get all owners (admin access)
* tags: [Admin]
* security:
* - bearerAuth: []
* responses:
* 200:
* description: List of all owners
* content:
* application/json:
* schema:
* type: array
* items:
* $ref: '#/components/schemas/Owner'
* 401:
* description: Unauthorized - Admin access required
* 500:
* description: Server error
*/
router.get('/owners', getAllOwners)

/**
* @swagger
* /api/admin/editors:
* get:
* summary: Get all editors (admin access)
* tags: [Admin]
* security:
* - bearerAuth: []
* responses:
* 200:
* description: List of all editors
* content:
* application/json:
* schema:
* type: array
* items:
* $ref: '#/components/schemas/Editor'
* 401:
* description: Unauthorized - Admin access required
* 500:
* description: Server error
*/
router.get('/editors', getAllEditors)

/**
* @swagger
* /api/admin/requests:
* get:
* summary: Get all requests (admin access)
* tags: [Admin]
* security:
* - bearerAuth: []
* responses:
* 200:
* description: List of all requests
* content:
* application/json:
* schema:
* type: array
* items:
* $ref: '#/components/schemas/Request'
* 401:
* description: Unauthorized - Admin access required
* 500:
* description: Server error
*/
router.get('/requests', getAllRequests)

/**
* @swagger
* /api/admin/videos:
* get:
* summary: Get all videos (admin access)
* tags: [Admin]
* security:
* - bearerAuth: []
* responses:
* 200:
* description: List of all videos
* content:
* application/json:
* schema:
* type: array
* items:
* $ref: '#/components/schemas/Video'
* 401:
* description: Unauthorized - Admin access required
* 500:
* description: Server error
*/
router.get('/videos', getAllVideos)

export default router
69 changes: 69 additions & 0 deletions server/routes/auth0.route.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,75 @@ import { Router } from 'express'
import { auth0CreateController } from '../controllers/auth0.controller.js'
const router = Router()

/**
* @swagger
* components:
* schemas:
* Auth0User:
* type: object
* properties:
* _id:
* type: string
* description: The auto-generated id of the Auth0 user
* auth0Id:
* type: string
* description: ID from Auth0 authentication
* email:
* type: string
* description: User's email address
* role:
* type: string
* enum: [owner, editor, admin]
* description: User's role in the system
* createdAt:
* type: string
* format: date-time
* description: When the user was created
* updatedAt:
* type: string
* format: date-time
* description: When the user was last updated
*/

/**
* @swagger
* /auth0/create:
* post:
* summary: Create a new Auth0 user in the system
* tags: [Authentication]
* security:
* - bearerAuth: []
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* properties:
* email:
* type: string
* description: User's email address
* role:
* type: string
* enum: [owner, editor, admin]
* description: User's role in the system
* required:
* - email
* - role
* responses:
* 201:
* description: Auth0 user created successfully
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/Auth0User'
* 400:
* description: Invalid request data
* 401:
* description: Unauthorized - Invalid token
* 500:
* description: Server error
*/
router.post('/create', auth0CreateController)

export default router
Loading