@wikoci/payloadjs
v1.0.1
Published
Payload CMS SDK for use in javascript
Downloads
151
Maintainers
Readme
Payload CMS SDK + Plugin
✨ Features
- Restful Method
- Plugin Permission
- Plugin to Upload multiples files once.
- Plugin aggregate endpoints part of Mongodb aggregate
Installation
npm i @wikoci/payloadjs
yarn @wikoci/payloadjs
SDK JS - Restfull
import {Payload} from "@wikoci/payloadjs"
var payload =new Payload({
key:'',
apiURL:'',
mediaURL:'',
debug:true
})
login()
payload.login("slug",data,options);
me()
payload.me("slug");
logout()
payload.logout("slug");
find()
payload.find("slug",params,options);
global()
Find single collection type.
payload.global("slug");
findOne()
payload.findOne("slug",ID);
create()
payload.find("slug",data,options);
update()
payload.find("slug",ID,data,options);
deleteOne()
payload.find("slug",ID);
setToken()
payload.setToken(token);
clearToken()
payload.clearToken();
aggregate()
** require Plugin aggregate **
//In server.js
const {aggregateEndpoints} =require("@wikoci/payloadjs/plugins/mongodb")
payload.init({
secret: process.env.PAYLOAD_SECRET,
mongoURL: process.env.MONGODB_URI,
express: app,
onInit: () => {
aggregateEndpoints(payload) //++ Add this line
payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`);
},
});
payload.aggregate("slug",pipeline);
Plugin
Permission plugin
This plugin active all feature : createdBy , updatedBy , and Permission utility.
** Notice: **
1- All slug contains users
are allowed to use permission plugins and authentication execpt default payload users.
Ex: customer-users , public-users , doa-users
//payload.config.js
import {permission } from "@wikoci/payloadjs/plugin"
const config ={ // Optional
defaultPermission:{
slug: {
auth: ["create", "readAny"], // default permissions for Auth User : create | readAny | readOwn | deleteAny | deleteOwn | updateOwn | updateAny | aggregate | readGlobal | createGlobal
public: ["readAny"], // No auth user readAny | createAny | deleteAny | updateAny | readGlobal | createGlobal,
readOnlyCreatedBy: true, // Admin UI
readOnlyUpdatedBy: true, // Admin UI
},
}
}
plugins:[
permission(config)
]