@sjeremich23/docs
v1.0.2
Published
Swagger API documentation for the PWA backend API.
Downloads
7
Maintainers
Readme
📚 Swagger Integration for Express.js
This project provides middleware for integrating Swagger UI into the Week 1 - Creating Your Backend API assignment for class WDV3322, Programming for Web Applications.
✨ Features
- Swagger UI Integration: Easily serve your Swagger documentation.
- Customizable Configuration: Load Swagger configuration from a JSON file.
📦 Installation
To install the package, use npm:
npm install @sjeremich23/docs
📖 Step-by-Step Integration
- Import or require the middleware in your Express.js application.
orimport swaggerRouter from "@sjeremich23/docs";
const swaggerRouter = require("@sjeremich23/docs");
- Add the endpoint
/api-docs
to serve the Swagger UI.app.use("/api-docs", swaggerRouter);
🚀 Usage
ES6 Module
Import the middleware in your Express.js application:
import express from "express";
import swaggerRouter from "@sjeremich23/docs";
const app = express();
app.use("/api-docs", swaggerRouter);
app.listen(3000, () => {
console.log("Server is running on port 3000");
});
CommonJS Module
Import the middleware in your Express.js application:
const express = require("express");
const swaggerRouter = require("@sjeremich23/docs");
const app = express();
app.use("/api-docs", swaggerRouter);
app.listen(3000, () => {
console.log("Server is running on port 3000");
});
🛠️ Configuration
The package comes with a default swaggerConfig.json
file. You can customize it as needed.
📄 License
This project is licensed under the MIT License.