express-comment
Simple Article Post/Comment Management Middleware
express-comment
is a middleware bundled with frontend API utilities that allows you to create a simple yet highly usable post/comment system with minimal code.
Condition
This package is under active development, and is just entering its alpha stage. The API may change with new features added in the future.
How to use
Install express-comment-frontend
as frontend API and /lib/api.md
for details, and /example/*
for examples of backend use. In general, you can simply mount the middleware on a path with minimal configuration, and use /lib/frontend
predefined API for simple query and update.
Demo
Front-end API
// frontend code, using lib/index.js of express-comment-frontendlet comment = ; // If you use React/Node instead, you can likely to be able to simply (not yet tested);let comment = ; // begin: let commentID;let replyID; // Callback styledcomment ; // Promise styledcomment ; comment ; comment // true if you want to get all replies to the comment found, will be accessible at entry[i].reply ; // find root comments on an articlecomment // true if you want to get all replies to the comment found, will be accessible at entry[i].reply ; // Delete!comment ; comment ;
Back-end API
const express = ;const bodyParser = ;const app = ;const comment = ;const drivers = commentdrivers; // General settingsconst ecSettings = {} // with MongoDB (Mongo Native Client)const mongo_config = /* ... */ // see /lib/db/mongo/README.md;app; // or if with Sequelize.js (supporting MySQL, PostgreSQL, SQLite, etc.)const sequelize_config = database: 'ec' username: 'root' password: '' settings: /* Sequelize config settings, check Sequelize docs about config settings. */ host: 'localhost' dialect: 'mysql' pool: max: 5 min: 0 acquire: 30000 idle: 10000 app; /* ... */ // You are good to go!