1.0.0 • Published 7 years ago

rimer v1.0.0

Weekly downloads
41
License
-
Repository
-
Last release
7 years ago

Rimer is a blog engine heavily influenced by Poet and implemented with JavaScript for node and firebase.

Install

$ npm install --save rimer

Once you have the rimer module in your app, just instantiate an instance with your Express app and options, and call the init method:

Setup

var
  express = require('express'),
  firebase = require('firebase')
  Rimer = require('rimer'),
  app = express();
  
var firebaseApp = firebase.initializeApp({
  serviceAccount: "path_to_firebase_json",
  databaseURL: "****************************"
});
var ref = firebase.database(firebaseApp).ref()

var rimerOptions = {
    ref : ref,
    postLimit: 2 // default value 10
}
var rimer = Rimer(rimerOptions)
rimer.init()

Responses and Error Codes

error : JSON

  • error.code* : Number
  • error.value* : String

response : JSON

  • response.code* : Number
  • response.value : Can be JSON, Array, String or null depending upon service type

Valid Code :

    code                                title
    200                                 Ok
    400                                 Invalid Request
    500                                 Module Error

Post Services

1. Create Post

    var snippet = {
        body: JSON 
    }
    rimer.post.create(snippet, function(error, response) {
        if(error)
            console.log(error)
        else
            console.log(response)
    })

snippet.body

  • title* : String
  • preview* : String (Short Decription of post)
  • category* : String
  • tags* : String (comma seperated values)
  • images : String (comma sepearted value)
  • thumbnail: String
  • description: String (Body of post)

response.value : JSON

  • Created post data and id

2. Update Post

    var snippet = {
        query: JSON,
        body: JSON 
    }
    rimer.post.update(snippet, function(error, response) {
        if(error)
            console.log(error)
        else
            console.log(response)
    })

snippet.query

  • id* : String (Post Id returned with post details)
  • published : Boolean (default true indicating post is in published state)

snippet.body

  • title, preview, category, thumbnail, description as string
  • tags, images as string (comma seperated values)
  • set optional valid keys in body as "" to remove that value from post

response.value : JSON

  • Updated post raw data

3. Publish Post

    var snippet = {
        query: JSON 
    }
    rimer.post.publish(snippet, function(error, response) {
        if(error)
            console.log(error)
        else
            console.log(response)
    })

snippet.query

  • id* String (Post Id)

response.value : String

  • Published Post Id

4. Unpublish Post

    var snippet = {
        query: JSON 
    }
    rimer.post.unpublish(snippet, function(error, response) {
        if(error)
            console.log(error)
        else
            console.log(response)
    })

snippet.query

  • id* : String (Post Id)

response.value : String

  • Unpubublished Post Id

5. Delete Post

    var snippet = {
        query: JSON 
    }
    rimer.post.delete(snippet, function(error, response) {
        if(error)
            console.log(error)
        else
            console.log(response)
    })

snippet.query

  • id* : String (Post Id)
  • published : Boolean (default true indicating post is in published state)

6. Get Post By Id

    var snippet = {
        query*: JSON,
        fields: String(Comma Seperated Values)
    }
    rimer.post.findOne(snippet, function(error, response) {
        if(error)
            console.log(error)
        else 
            console.log(response)
    })

snippet.query

  • id* : String (Post Id)
  • published : (default true indicating post is in published state)

snippet.fields

  • String (comma sepearted value of keys to be returned in each post)
  • valid keys for post will only be returned
  • any extra key not present in post will be not available in response

response.value : JSON

  • Post Detail

7. Get Posts

    var snippet = {
        query*: JSON,
        fields: String(Comma Seperated Values)
    }
    rimer.post.find(snippet, function(error, response) {
        if(error)
            console.log(error)
        else 
            console.log(response)
    })

snippet.query

  • published : Boolean (default true indicating post is in published state)
  • nextkey : String (Returned in previous response to return next set of post)

snippet.fields

  • String (comma sepearted value of keys to be returned in each post)
  • valid keys for post will only be returned
  • any extra key not present in post will be null in response

response.value: Array

  • Array of post json (Can be empty array if no post available) response.nextKey: String
  • Returned only if next set of data available

8. Get Posts By Category

    var snippet = {
        query*: JSON,
        fields: String(Comma Seperated Values)
    }
    rimer.post.findByCategory(snippet, function(error, response) {
        if(error)
            console.log(error)
        else 
            console.log(response)
    })

snippet.query

  • category*: String (Post Id)

snippet.fields

  • String (comma sepearted value of keys to be returned in each post)
  • valid keys for post will only be returned

response.value: Array

  • Array of published post for a category (Can be empty array if no post available)

9. Get Posts By Author

    var snippet = {
        query*: JSON,
        fields: String(Comma Seperated Values)
    }
    rimer.post.findByAuthor(snippet, function(error, response) {
        if(error)
            console.log(error)
        else 
            console.log(response)
    })

snippet.query

  • authorId*: String (Author Id)

snippet.fields

  • String (comma sepearted value of keys to be returned in each post)
  • valid keys for post will only be returned

response.value: Array

  • Array of published post by an author (Can be empty array if no post available)

10. Add Post Author

    var snippet = {
        query*: JSON,
        fields: String(Comma Seperated Values)
    }
    rimer.post.assignAuthor(snippet, function(error, response) {
        if(error)
            console.log(error)
        else 
            console.log(response)
    })

snippet.query

  • id* : String (Post Id)
  • authorId* : String (Author Id)
  • published : Boolean (default true indicating post is in published state)

11. Remove Post Author

    var snippet = {
        query*: JSON,
        fields: String(Comma Seperated Values)
    }
    rimer.post.unassignAuthor(snippet, function(error, response) {
        if(error)
            console.log(error)
        else 
            console.log(response)
    })

snippet.query

  • id* : String (Post Id)
  • authorId : String (Author Id)
  • published : Boolean (default true indicating post is in published state)

Author Services

1. Create Author

    var snippet = {
        body: JSON 
    }
    rimer.author.create(snippet, function(error, response) {
        if(error)
            console.log(error)
        else
            console.log(response)
    })

snippet.body

  • name* : String
  • about* : String (Short Decription of post)
  • image : String
  • thumbnail: String
  • facebook : String
  • twitter: String
  • instagram: String
  • snapchat: String
  • other: String

response.value : JSON

  • Created author data and id

2. Update Author

    var snippet = {
        query: JSON,
        body: JSON 
    }
    rimer.author.update(snippet, function(error, response) {
        if(error)
            console.log(error)
        else
            console.log(response)
    })

snippet.query

  • id* : String (Author Id returned with author deleteP)

snippet.body

  • name, about, image, thumbnail, facebook, twitter, instagram, snapchat, other as string
  • set optional valid keys in body as "" to remove that value from author

response.value : JSON

  • Updated author raw data

3. Delete Author

    var snippet = {
        query: JSON 
    }
    rimer.author.delete(snippet, function(error, response) {
        if(error)
            console.log(error)
        else
            console.log(response)
    })

snippet.query

  • id*: String (Author Id)

4. Get Author By Id

    var snippet = {
        query*: JSON,
        fields: String(Comma Seperated Values)
    }
    rimer.author.findOne(snippet, function(error, response) {
        if(error)
            console.log(error)
        else 
            console.log(response)
    })

snippet.query

  • id* : String (Post Id)
  • published : Boolean (default true indicating post is in published state)

snippet.fields

  • String (comma sepearted value of keys to be returned in each post)
  • valid keys for author will only be returned
  • any extra key in fields not present in author will be not available in response

response.value : JSON Deleting an author will remove all its refrence from posts

5. Get Authors

    var snippet = {
        query: JSON,
        fields: String(Comma Seperated Values)
    }
    rimer.author.find(snippet, function(error, response) {
        if(error)
            console.log(error)
        else 
            console.log(response)
    })

snippet.query : {} snippet.fields

  • String (comma sepearted value of keys to be returned in each author detail)
  • valid keys for author will only be returned
  • any extra key not present in author will be null in response

response.value : Array

  • Array of author json (Can be empty array if no author available)

Category Services

1. Get Published Categories

    rimer.category.find(function(error, response) {
        if(error)
            console.log(error)
        else 
            console.log(response)
    })

response.value : Array

  • Array of category json (Can be empty array if no author available)
  • Each category is a json of name and count(total post in a particular category)
1.0.0

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago