1.0.177 • Published 4 years ago

@becomes/cms v1.0.177

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

Becomes CMS - In Development

Get Started

  • Instal CMS CLI package globally: npm i -g @becomes/cms-cli
  • Setup MongoDB database:
  • Navigate to project and run npm run dev
  • Open browser, goto localhost:1280 and create Admin user.

Introduction

This is a small CMS developed by company Becomes that is specialized for building APIs. It was created because of project needs in our company and we decided to make it Open-Source since it solved a lot of problems that we had with other CMS solutions. We hope that you will find it useful in your next project.

  • What Becomes CMS is not?
    • It is not replacement for WordPress - WordPress is used for creating websites while Becomes CMS is used for creating APIs that will be consumed by other services. In this regard, they are completely different.
    • It is not Website generator - As said in previous point, Becomes CMS is used for creating APIs that will be consumed by some other service. You cannot create web pages publicly accessible over Becomes CMS.
    • It is not replacement for highly specialized APIs - Altho you can create any data model using Becomes CMS and manage them thru interactive dashboard, it is not designed to replace an API where very high performance is required.
  • What is Becomes CMS?
    • In one sentence, it is highly flexible and interactive tool for creating APIs that will be consumed by other services.

Terminology

In this document, few "special" words will be used and they have specific meaning.

  • Template - It is a container that holds information about how new Entry should be created, it structure and how it should behave. In addition to that, Template is holding pointers to all available Entries. By itself, Template is nothing more then a template for creating Entries and keeping them in sync with each other, therefore the name is as it is. Template also dictates type of an Entry that can be created by it:
    • Data Modal - This type defines that Entry is a "primitive" object, like plane JSON object (not actually but close enough). Example is a web store item, order, subscription or any other object that can be represented using key-value pairs.
    • Rich Content - This type defines that Entry is a "complex" object and it extends Data Model type. This means that in addition to key-value pairs, it also has User editable rich content. Some examples are: blog post, case study post or any other type of content that will be consumed by humans in readable form.
  • Entry - It is an object that holds actual data in structured way that is useful to a consumer of the CMS API. The structure is defined by Template.
  • Group - It is a placeholder object for creating complex and nested properties in Entry. For example, if it is required for Entry to have object property (non primitive one, like string, number...) Group is used to achieve this.
  • User - It is an entity which is authorized to access CMS dashboard. User can have roles: ADMIN or USER (more information in Users section).
  • Widget - It is a special placeholder object that can be only used in Entries of type Rich Content.
  • Webhook - It is a special object that can be configured to trigger CMS API function called webhook.
  • Function -

By showing some examples this terminology might be easier to understand.

Short Examples

Example 1 - Using CMS to create a Blog website.

The core function of a blog website is a Blog Post. Every blog post on a website follows the same structure: title, cover image, author and content. Only thing that is different between 2 blog posts is the content. Therefore, in this example, Template is defining blog post structure (title property is of type string, cover image is of type string, author is of type Group and so one) while Entry is a single Blog Post and this means that it is holding values for properties defined in Template (title is "My first blog", cover image is "/image.png", author is "{name: "Tom", position: "CEO"}" and so one).

Example 2 - Using CMS to create a simple web store.

The core function of a web store is an Item. To make it as simple as possible this online store is selling 2 Item types: Books and Makers. Books will be defined by creating a Template with properties: name <string>, title <string> and author <string> while Markers will be defined by creating a new Template with properties: name <string>, price <number> and quantity <number>. With this done Book Entry and Marker Entry can be added since structure is defined by Books Template and Markers Template respectively.

Back-end

Becomes CMS can be split into 2 parts, Back-end part that is built using Purple Cheetah framework and Front-end part that is built using Svelte.

User

It is a special model used to describe a CMS user which is a person. If it is required for service or robot to be able to access CMS content, it is highly recommended to use API Key for that since its access level can be restricted. Every User must have unique email and strong password. Email does not have to be valid but it has to be unique.

Security

Back-end uses 2 types of security:

JWT

JWTs are used for dashboard and for other services that want to take full control over Core CMS API. If full access to Core API is not required for consumer, it is recommended to use Key Security.

To obtain JWT Access Token and Refresh Token for a User (created using dashboard), Basic Authorization flow is used with User email and password for endpoint /auth/user. If authorization is successful, API will respond with token

  Response {
    accessToken: string,
    refreshToken: string,
  }

API Key

API Key is created using dashboard, while HTTP Signature is used for authentication when calling Core API. Function below can be used to create HTTP Signature for a request using API Key.

const crypto = require('crypto');

exports.sign = (payload) => {
  const data = {
    key: process.env.API_KEY,
    timestamp: Date.now(),
    nonce: crypto.randomBytes(3).toString("hex"),
    signature: ""
  };
  let payloadAsString = "";
  if (typeof payload === "object") {
    payloadAsString = Buffer.from(JSON.stringify(payload)).toString(
      "base64"
    );
  } else {
    payloadAsString = "" + payload;
  }
  data.signature = crypto
    .createHmac("sha256", process.env.API_SECRET)
    .update(data.nonce + data.timestamp + data.key + payloadAsString)
    .digest('hex');
  return data;
};

Generated parameters are parsed in a query with same name.

1.0.177

4 years ago

1.0.176

4 years ago

1.0.175

4 years ago

1.0.174

4 years ago

1.0.173

4 years ago

1.0.172

4 years ago

1.0.171

4 years ago

1.0.170

4 years ago

1.0.169

4 years ago

1.0.168

4 years ago

1.0.167

4 years ago

1.0.166

4 years ago

1.0.165

4 years ago

1.0.164

4 years ago

1.0.163

4 years ago

1.0.162

4 years ago

1.0.161

4 years ago

1.0.160

4 years ago

1.0.159

4 years ago

1.0.158

4 years ago

1.0.157

4 years ago

1.0.156

4 years ago

1.0.154

4 years ago

1.0.155

4 years ago

1.0.153

4 years ago

1.0.152

4 years ago

1.0.149

4 years ago

1.0.150

4 years ago

1.0.151

4 years ago

1.0.148

4 years ago

1.0.147

4 years ago

1.0.145

4 years ago

1.0.144

4 years ago

1.0.146

4 years ago

1.0.143

4 years ago

1.0.142

4 years ago

1.0.141

4 years ago

1.0.140

4 years ago

1.0.139

4 years ago

1.0.136

4 years ago

1.0.138

4 years ago

1.0.135

4 years ago

1.0.134

4 years ago

1.0.133

4 years ago

1.0.132

4 years ago

1.0.131

4 years ago

1.0.130

4 years ago

1.0.129

4 years ago

1.0.128

4 years ago

1.0.125

4 years ago

1.0.127

4 years ago

1.0.126

4 years ago

1.0.124

4 years ago

1.0.123

4 years ago

1.0.122

4 years ago

1.0.121

4 years ago

1.0.120

4 years ago

1.0.118

4 years ago

1.0.119

4 years ago

1.0.117

4 years ago

1.0.116

4 years ago

1.0.115

4 years ago

1.0.114

4 years ago

1.0.113

4 years ago

1.0.112

4 years ago

1.0.111

4 years ago

1.0.110

4 years ago

1.0.109

4 years ago

1.0.108

4 years ago

1.0.107

4 years ago

1.0.106

4 years ago

1.0.105

4 years ago

1.0.103

4 years ago

1.0.104

4 years ago

1.0.102

4 years ago

1.0.101

4 years ago

1.0.100

4 years ago

1.0.99

4 years ago

1.0.98

4 years ago

1.0.97

4 years ago

1.0.96

4 years ago

1.0.95

4 years ago

1.0.94

4 years ago

1.0.93

4 years ago

1.0.91

4 years ago

1.0.92

4 years ago

1.0.89

4 years ago

1.0.90

4 years ago

1.0.88

4 years ago

1.0.87

4 years ago

1.0.86

4 years ago

1.0.79

4 years ago

1.0.80

4 years ago

1.0.84

4 years ago

1.0.83

4 years ago

1.0.82

4 years ago

1.0.81

4 years ago

1.0.85

4 years ago

1.0.78

4 years ago

1.0.77

4 years ago

1.0.76

4 years ago

1.0.75

4 years ago

1.0.74

4 years ago

1.0.73

4 years ago

1.0.72

4 years ago

1.0.71

4 years ago

1.0.70

4 years ago

1.0.69

4 years ago

1.0.68

4 years ago

1.0.67

4 years ago

1.0.66

4 years ago

1.0.65

4 years ago

1.0.64

4 years ago

1.0.62

4 years ago

1.0.63

4 years ago

1.0.61

4 years ago

1.0.60

4 years ago

1.0.59

4 years ago

1.0.58

4 years ago

1.0.57

4 years ago

1.0.55

4 years ago

1.0.56

4 years ago

1.0.54

4 years ago

1.0.53

4 years ago

1.0.52

4 years ago

1.0.51

4 years ago

1.0.50

4 years ago

1.0.49

4 years ago

1.0.47

4 years ago

1.0.46

4 years ago

1.0.45

4 years ago

1.0.44

4 years ago

1.0.43

4 years ago

1.0.42

4 years ago

1.0.40

4 years ago

1.0.41

4 years ago

1.0.39

4 years ago

1.0.38

4 years ago

1.0.33

4 years ago

1.0.32

4 years ago

1.0.37

4 years ago

1.0.36

4 years ago

1.0.35

4 years ago

1.0.34

4 years ago

1.0.31

4 years ago

1.0.30

4 years ago

1.0.29

4 years ago

1.0.28

4 years ago

1.0.27

4 years ago

1.0.26

4 years ago

1.0.25

4 years ago

1.0.24

4 years ago

1.0.23

4 years ago

1.0.22

4 years ago

1.0.21

4 years ago

1.0.20

4 years ago

1.0.19

4 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago