Giter Site home page Giter Site logo

tomsvogel / serverless-backend Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jamstack-cms/serverless-backend

0.0 2.0 0.0 18 KB

The serverless back end for JAMstack CMS. Use this back end to deploy a custom CMS using your own front end.

License: MIT License

JavaScript 100.00%

serverless-backend's Introduction

JAMstack CMS infrastructure as code

This is the back end infrastructure that powers the JAMstack CMS.

If you would like to build another CMS based on the JAMstack CMS, this is a great place to start. It includes the following:

  1. GraphQL API with authorization rules.

  2. Amazon S3 for storage of images, videos, and files.

  3. Authentication service for user management and general authentication and authorization.

  4. Lambda functions for image resizing and post-confirmation of users to add to groups.

To deploy this backend with another app

  1. Download the amplify folder into the root of the application you'd like to build

  2. Run the following command:

amplify init
  1. Update the schema to match your requirements.

  2. To update any configuration, you can run the following commands:

amplify update storage

amplify update api

amplify update auth

amplify update function

Updating / evolving the GraphQL schema

To update the schema, open the schema at amplify/backend/api/jamstackcms. Here is the base schema:

  
type Post @model
  @auth (
      rules: [
          { allow: groups, groups: ["Admin"], operations: [create, update, delete] },
          { allow: private, operations: [read] },
          { allow: public, operations: [read] }
      ]
  ) {
  id: ID!
  title: String!
  description: String
  content: String!
  cover_image: String
  createdAt: String
  published: Boolean
  previewEnabled: Boolean
  categories: [String]
  author: User @connection
}

type Comment @model @auth(
  rules: [
    { allow: groups, groups: ["Admin"], operations: [create, update, delete] },
    { allow: owner, ownerField: "createdBy", operations: [create, update, delete] }
  ]
) {
  id: ID!
  message: String!
  createdBy: String
  createdAt: String
}

type Settings @model @auth(rules: [
    { allow: groups, groups: ["Admin"] },
    { allow: groups, groupsField: "adminGroups"},
    { allow: public, operations: [read] },
  ]) {
  id: ID!  
  categories: [String]
  adminGroups: [String]
  theme: String
  border: String
  borderWidth: Int
  description: String
}

type Preview @model
  @auth (
      rules: [
        { allow: groups, groups: ["Admin"] },
        { allow: private, operations: [read] }
      ]
  ) {
  id: ID!
  title: String!
  description: String
  content: String!
  cover_image: String
  createdAt: String
  categories: [String]
}

type Page @model(subscriptions: null)
  @auth (
      rules: [
        { allow: groups, groups: ["Admin"] },
        { allow: private, operations: [read] },
        { allow: public, operations: [read] }
      ]
  )
{
  id: ID!
  name: String!
  slug: String!
  content: String!
  components: String
  published: Boolean
}

type User @model
  @auth(rules: [
    { allow: owner },
    { allow: groups, groups: ["Admin"]},
    { allow: public, operations: [read] }
  ])
{
  id: ID!
  name: String
  username: String
  avatarUrl: String
}

Once you've made the updates, run the following command to test the new API:

amplify mock

Once you've tested the updates, run the following command to deploy the new API:

amplify push

serverless-backend's People

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.