Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
koa-smartdoc-middleware
Advanced tools
Smartdoc is an RESTful document generator according to document-style comment
#smartdoc-middleware
Smartdoc is an RESTful document generator according to document-style comment.
Smartdoc reads all API-Document comments in service folder by AST, generates a delaration data file, then serve a single-page application for browsering and testing interfaces at the mounted route.
npm install --save koa-smartdoc-middleware
For example, we have an project like this:
- index.js
+ services // The directory where api functions defined in.
- user.js
- post.js
- ...
And you've commented these service functions correctly. (See below)
Then, you can easily extend your app with smartdoc:
// index.js
const app = require('koa')();
const mount = require('koa-mount');
const smartdoc = require('koa-smartdoc-middleware');
const pathToServices = path.join('../services');
// ...
app.use(mount('/doc', smartdoc(pathToServices)));
// ...
app.listen(3000);
Then, you will able to access the document page at http://localhost:3000/doc
.
First, you should declare an app like this (In any file inside the services folder, generally, services/index.js):
// services/index.js
/**
* Example Application
* @application example-app
*
* @author linkeo
* @version 0.0.1
*/
module.exports = {};
Notice: To declare an Application,
@application [name]
is necessary.
Then, in every service modules, declare your APIs.
// services/user.js
/**
* User Services
* @module user
* @path /user
*/
module.exports = class UserService {
/**
* User Login
*
* @note If success, will set cookies with response.
*
* @route {post} /login
* @param {String} account Phone or email of the user
* @param {String} password
* @param {String} from Where the user logins, can be 'app', 'web'
* @return {Object} An object contains user information
*/
*login(req, res) {
//...
}
}
Notice: To declare a Module,
@module [name]
is necessary.Notice: To declare an Action,
@route [method] [path]
is necessary.
Then, you will get an API declaration structure like this:
name: example-app
title: Example Application
modules:
- name: user-674e7e
title: User Services
path: /user
actions:
- name: post-login-768ed4
title: User Login
route:
method: post
path: /login
params: ...
FAQs
Smartdoc is an RESTful document generator according to document-style comment
The npm package koa-smartdoc-middleware receives a total of 3 weekly downloads. As such, koa-smartdoc-middleware popularity was classified as not popular.
We found that koa-smartdoc-middleware demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.