Skip to content

NodeJS Script for backend of 11th Commandment Application

Notifications You must be signed in to change notification settings

gunpreet34/11thCommandment-Script

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

11th Commandment API

Various routes:

For user

Schema

username-string
access-number
fb_id-string
fb_number-Number
gmail_id-string
gmail_number-Number
mobile-string
name-string
bookmarkedNews-Array

'post' /register

username:String(unique,required)
password:String(required)
response:String(Toast to be shown)

'post' /login

username:String(unique,required)
password:String(required)
response:String("Found","Not Found")

For admin registration

Schema

name-string
password-string
access-number
mobile-number
email-string

'get' /registerAdmin -> To load the webpage for registration

'post' /registerSuccess

send ->
        1.name:String(required)
        2.email:String(Unique.required)
        3.password:String(required)
        4.access:String ("0" for Editor and "1" for Admin) - (Required)
        5.number:Number(Required)
response: Json - {success:String,data:Msg to be shown}

'post' /adminLogin

email:String(Unique.required)
password:String(required)
response:Json - {success:String,data:Msg to be shown}

For news

Type -> News or Poll

Schema

title-string
titleSearch-[String]
description-string
url-string
category-string
tags-[string] -> splitted categories array
imageURL-string
source-string
count-number
date-string
verify-boolean
uniqueUrl-string
type-string
//For poll
question-string
optionOne-string
optionTwo-string
optionOneCount-number
optionTwoCount-number

'post' /postNews

send - title,description,url,category(separated by ','),count,tagPrimary,tagSecondary,imageURL,source,type(poll or news),question,optionOne,optionTwo
extras - tags(for category splitting),titleSearch(for title splitting into words)
response - string

'post' /updateNews

find admin via -> user_id
find news via -> _id
send - title,description,url,category(separated by ','),count,tagPrimary,tagSecondary,imageURL,source,type(poll or news),question,optionOne,optionTwo
extras - tags(for category splitting),titleSearch(for title splitting into words)
response - string

'post' /deleteNews

send - id
response - string

'get' /getNews -> Get verified news - for users

response - json - {success,data} - where success is integer and data is json

'post' /getNewsByCategory

send - category
response - json - {success,data} - where success is integer and data is in json - returns news within a category

'post' /searchNewsByTitle

send - title
response - json - {success,data} - where success is integer and data is in json - returns news within a category - returns news except the parameters: tags,titleSearch,url,tagPrimary,,tagSecondary,source,date,count,category

'post' /searchUnverifiedNewsByTitle

send - user_id,title
response - json - {success,data} - where success is integer and data is in json - returns news within a category - returns all unverified news

'post' /searchVerifiedNewsByTitle

send - user_id,title
response - json - {success,data} - where success is integer and data is in json - returns news within a category - returns all verified news

'get' /getNewsByTitle

response - json - {success,data} - where success is integer and data is in json - returns news by title - returns news except the parameters: tags,titleSearch,date,count

For sharing news url

Share -> "https://commandment-api.herokuapp.com/news/" + uniqueUrl
get request to above url will return the news in Json format

For bookmarking news

BookmarkedNews Schema

username-string
news_id-string
news-object

'post' /bookmark

send - username,news_id
response - string

'post' /getBookmarkedNews

send - username
response - json - {success,data} - where success is integer and data is in json - returns news by id

'post' /deleteBookmark

send - username,news_id
response - json - {success,data} - success in string("0" or "1") and data is String containing the message

For categories

Schema

category-string
count-number
imageURL-string
verify-boolean

'post' /addCategory

send - category(name),image(url),user_id(Author)
response - String (Either -> Category added OR -> Error) 

'post' /updateCategory

send - category(name),image(url),user_id(Author)
response - String (Either -> Category added OR -> Error) 

'post' /deleteCategory

send - _id(category id)
response - json(success:0 means failure, success:1 means success, data has message embedded)

'get' /getUnverifiedCategories

response - json({successParameter,jsonArrayOfUnverifiedCategories})

'get' /getVerifiedCategories

response - json({successParameter,jsonArrayOfVerifiedCategories})

'get' /getCategory/:id

response - json({successParameter,jsonOfCategoryCorrespondingToId})

'get' /getCategories

response - json - {success,data} - where success is integer and data is json

'get' /getCategoriesWithNews -> Get only those categories which have news

response - json - ({successParameter,jsonArrayOfAllCategoriesWithNews})

For polls

SavedPoll Schema

username-string
poll_id-string
option-number

'post' /getPolls

response - json - {success,data} - success in string("0" or "1") and data is JsonArray of all the Polls

'post' /pollCount -> increase counter

send -> 1. option:String(Required) - Either "0" or "1"
        2. username:String(Required)
        3. news_id:String(Required)
response:Json - {success:String, data:(Message)String, optionOne:Number, optionTwo:Number}

'post' /getPoll -> get polls for a user

send : username:String(Required)
response : Json - {success:String,data:votedPolls}

For Advertisement

Type -> Simple(Non-intruisive),Image,Video

Schema

type-string
advertisementListCount-number
title-string
titleSearch-[string]
description-string
advertisementUrl-string
URL-string
source-string
verify-boolean
shown-boolean
uniqueUrl-string

'post' /addAdvertisement

send : title,URL,source,type,advertisementListCount,description , user_id(Admin)
response : String (Success message or error message)

'post' /updateAdvertisement

send : title,URL,advertisementUrl,source,type,advertisementListCount,description , user_id(Admin)
response : String (Success message or error message)

'post' /deleteAdvertisement

send : _id
response : json(successParameter, deletedAdvertisement)

'get' /getAdvertisements -> Get all advertisements - verified only - for users

response: json - {successParameter,jsonArray}

'get' /getUnverifiedAdvertisement -> Get only unverified - for authors

response: json - {successParameter,jsonArray} 

'get' /getAllAdvertisements/:user_id -> Get verified advertisements - for authors

response: json - {successParameter,jsonArray} 

About

NodeJS Script for backend of 11th Commandment Application

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •