portal-api-creator

1.0.12 • Public • Published

#portal-api-creator

##How to install

npm i portal-api-creator

###Define :

createPortalAPI(modules==>{ <name> : 'api list' },
 (m)=>"https://myspace.com/space/v1/" ,   ===> prefix will be added for all urls + dynamic changable
 (m)=>globalParameters,                   ===> params will be added for all urls + dynamic changable
 (m)=>headers                             ===> header will be added for all urls + dynamic changable
)

##How to use in your code - example

import createPortalAPI, { kb , community } from 'portal-api-creator'; 

const portalAPIS = createPortalAPI({ kb, community}, (m)=>{
	
	return 'https://myspace.com/api/v1/'

} , (m)=>{

	return { appId : "dsdlfo39o3ksjkskso90939o33i38i383i" }
	
} , (m)=>{

	return {
		hash : "sdflsflsdkfsdkfiwelelqweoqwelqweqkewpelqweqkenqw8j33jj3bnbbdsfhfhdshfshdf"
	}
});


portalAPIS.kb.articles()
portalAPIS.community.topics()
import creatorPortalAPI, { kb } from 'portal-api-creator';
global.portalAPI = creatorPortalAPI({ kb },()=>{
	return "https://my.allows.com/v1/api/"
},()=>{
	return {
		"appPortalId" : "4659fc50aa0a07b8cd88c9af18ee0eb36cf32c3dda4b4401afb6719abeecaa48"
	}
});

global.portalAPI.kb.articles();

##How to use dynamic/custom modules code - example

import APIBuilder from 'portal-api-creator'; 

const builder = APIBuilder((m)=>{
	
	return 'https://myspace.com/api/v1/'

} , (m)=>{

	return { appId : "dsdlfo39o3ksjkskso90939o33i38i383i" }
	
} , (m)=>{

	return {
		hash : "sdflsflsdkfsdkfiwelelqweoqwelqweqkewpelqweqkenqw8j33jj3bnbbdsfhfhdshfshdf"
	}
});

let module1 =  builder.create({ <module1> : <module1 apis> });
let module2  = builder.create({ <module2> : <module2 apis> });
let module3  = builder.create({ <module3> : <module3 apis> });

module3.books()
module2.people()

##Next Works - inside the pattern changes js-api-creator soon.

	entity : {
		
		name : "communityTopics",
		type : ["get","update","delete","create"],
		entity : {
			name : "attachments",
			type : ["get","delete","create"],
			actions : [
				{ name : "content", type : ["get"]  }
			]
		},
		actions : [
			{ name : "like" , type : ["update"]  },
			{ name : "dislike" ,  type : ["update"] },
		]
	}
	

Package Sidebar

Install

npm i portal-api-creator

Weekly Downloads

13

Version

1.0.12

License

MIT

Unpacked Size

86.5 kB

Total Files

47

Last publish

Collaborators

  • iniankarthick