Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Lightweight, dynamic blog engine for Node.
NodePress is a blog engine for Node web servers. It's designed to be fast to use and attach to your existing project.
NodePress uses Mongo for database and Express/Socketio for client-server communication.
1. Get NodePress npm install nodepress
2. Add it to your project by using
const NodePress = require('nodepress');
const nodePress = new NodePress();
3. Configure NodePress according to your project/database variables and information.
// Your database info
const databaseInfo = {
ip: 'localhost',
port: '27017',
name: 'myDb',
requireLogon: 'false',
user: 'myUser',
password: 'myPassword'
};
const cfg = {
mongoClient: require('mongodb').MongoClient, // the mongodb client
mongoURL: NodePress.getMongoURL(databaseInfo), // get mongoURL by databaseInfo
httpServer: require('http').createServer(), // a HTTP server
postsPerPage: 10, // how many posts per page to fetch
postsCollection: 'posts' // posts' collection name
};
nodePress.config(cfg);
4. Initialize NodePress and add listeners.
nodePress.init(() => {
// Whenever the user/socket emits 'getPage'
nodePress.on('getPage', (user, pg) => {
console.log('Requesting page ' + pg);
const startTime = new Date().getTime();
nodePress.getPostsFromPage(pg, (data) =>{
// data.last is true if the page the user is requesting
// is the last page (which cointains the earlier posts)
var totalTime = new Date().getTime();
console.log('Request took ' + ((totalTime - startTime)/1000) + 's');
// This will be emitted to the client through Socket.io
nodePress.socket.to(user).emit('postsFromPage', {page: pg, posts: data.posts, last: data.last});
});
});
// Whenever the user/socket emits 'post'
nodePress.on('post', (user, postData) => {
// Check if we have all the information needed
if (!postData.title || !postData.author || !postData.body)
// This will be emitted to the client through Socket.io
return nodePress.socket.to(user).emit('alert', 'You need to fill in all the fields!');
nodePress.post(postData, (err) => {
if (err) { throw err };
// This will be emitted to the client through Socket.io
nodePress.socket.to(user).emit('post-added');
});
});
});
5. Take a look at the client examples in the folder /example/client to setup Socket.io in the client.
MIT License
FAQs
Lightweight blog engine for node
We found that nodepress 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.