Comparing version 1.0.2 to 1.0.3
{ | ||
"name": "nodepress", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Dynamic blog engine for node", | ||
@@ -5,0 +5,0 @@ "main": "nodepress.js", |
# NodePress | ||
Lightweight, dynamic blog engine for Node. | ||
NodePress is an API-styled blog engine for Node software and servers. It will make the backend faster for you when developing a blog. NodePress uses Mongo as its DB and Socketio/Express for server-client communication. NodePress was built to be a fast and light alternative for blog integrations with Node, which should work for any website. | ||
NodePress is a blog engine for Node web servers. It's designed to be fast to use and attach to your existing project. | ||
## Technology | ||
NodePress uses Mongo for database and Express/Socketio for client-server communication. | ||
## How to | ||
**1.** Install it with `npm install nodepress` or `git clone https://github.com/Rellfy/NodePress/` | ||
**1.** Get NodePress `npm install nodepress` | ||
**2.** Add it to your server by using | ||
**2.** Add it to your project by using | ||
@@ -17,22 +21,26 @@ ```javascript | ||
**3.** Configure NodePress by using | ||
**3.** Configure NodePress according to your project | ||
```javascript | ||
// 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); | ||
``` | ||
Where `cfg` is an object with the following values: | ||
`mongoClient` - MongoClient object (`require('mongodb').MongoClient`); | ||
`mongoURL` - You can get the connection URL by calling `NodePress.getMongoURL` with the following parameters: | ||
`ip` - Database's IP (string) | ||
`port` - Database's port (string) | ||
`name` - Database's name (string) | ||
`requireLogon` - Whether your database requires an user and password (bool, optional) | ||
`user` - Database's user (string, optional) | ||
`password` - Database's password (string, optional) | ||
`httpServer` - An instance of require('http') | ||
`postsPerPage` - How many posts to load per page (int) | ||
`postsCollection` - Database's collection name to store post documents (string) | ||
**4.** Initialize NodePress and add listeners. | ||
@@ -53,2 +61,3 @@ | ||
// This will be emitted to the client through Socket.io | ||
nodePress.socket.to(user).emit('postsFromPage', {page: pg, posts: data.posts, last: data.last}); | ||
@@ -62,2 +71,3 @@ }); | ||
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!'); | ||
@@ -67,3 +77,3 @@ | ||
if (err) { throw err }; | ||
// Send confirmation to user | ||
// This will be emitted to the client through Socket.io | ||
nodePress.socket.to(user).emit('post-added'); | ||
@@ -75,3 +85,3 @@ }); | ||
**5.** You can take a look at the client examples in the folder /example/client | ||
**5.** Take a look at the client examples in the folder /example/client to setup Socket.io in the client. | ||
@@ -78,0 +88,0 @@ ## License |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
86
21122