Coder Social home page Coder Social logo

contentajs's Introduction

ContentaJS Contenta logo

ContentaJS is a project that integrates with Contenta CMS to provide an high performing headless CMS. It also provides a nodejs application where to host your Server Side Rendering and custom code integrations.

Contenta Stack Architecture

IMPORTANT: this project is meant to be a starting kit for the node integration of your application based on Contenta CMS. We do not provide upgrade paths or backwards compatibility. The model for this is Fork & Go.

Travis Coverage David Dependency Management Last Commit Node Documented with emdaer

Videos

Contenta JS: Introduction

Contenta JS video

Tutorial: Install Contenta CMS + Contenta JS

Contenta JS video

Why?

Contenta CMS (aka the Drupal part) is designed to serve your project’s content. ContentaJS (aka the node.js part) is designed to serve the requests to your client side applications. Some of those requests will end up requesting data from Contenta CMS, others won’t.

You may need ContentaJS because for many reasons you will end up needing a node.js server for your project anyways. You may as well use an opinionated and optimized starter kit that will solve many of your needs without effort.

Microservices

If your API needs to aggregate data for use on the front-end from other services you should not use PHP for that. That is because, in practice, all I/O in Drupal is blocking and the performance of these tasks is usually very poor.

Examples of this are:

  • Showing weather data from a 3rd party API.
  • If you need to make requests to an analytics tool.
  • If you need to run a request through an anti-fraud service before accessing the content.

In these situations you will want to treat Contenta CMS just as any other microservice. Then you will need a server, like this one written in node.js, to orchestrate the different microservices.

Server-Side Rendering

Chances are that you are building a website as part of your digital project. In most cases you will be using a front-end framework like React, Vue, Angular, etc. All of those frameworks recommend using server-side rendering for many reasons. In order to implement server-side rendering you will need a node.js server.

You can use this node.js server (aka ContentaJS) to implement server-side rendering on.

Performance

Your LAMP stack (or alternative) runs your Contenta CMS installation. We all know how flexible and powerful Drupal is. But at the same time it is not great from a performance point of view. In fact it can rapidly become your bottleneck.

With ContentaJS you can reduce the load in your LAMP stack. This is because you don’t even need to hit this stack to access cached responses. ContentaJS will fetch the data from cache, and will only check with Drupal when there is no cache. That reduces greatly the amount of requests Apache needs to process. This reduces the load on Drupal, hence improving performance overall.

ContentaJS integrates transparently with Contenta CMS and can analyze requests that will fail in Drupal. When that happens the request never hits Drupal thus reducing the load there. Examples of this are: a request to a non-existing resource, a request that contains a payload that doesn’t validate against the schema of the resource, etc.

Other

Other server tasks like executing actions on cron, or sending emails, etc. can be done in this node.js server (and/or the machine running it) instead of on the LAMP stack.

Features

This section is still under development.

The main features of this project cover:

  • Automatic integration with the API exposed by your Contenta CMS install. Just provide the URL of the site and everything is taken care of for you.
    • JSON API integration.
    • JSON RPC integration.
    • Subrequests integration.
    • Open API integration.
  • Multi-threaded nodejs server that takes advantage of all the cores of the server’s CPU.
  • A Subrequests server for request aggregation. Learn more about subrequests.
  • A Redis integration via @contentacms/redis.
  • Type safe development environment using Flow.
  • Configurable CORS.

Installation

In order to install ContentaJS you will need to meet the following requirements:

  • nodejs ^8.11.1 or higher. This corresponds to lts/carbon.
  • A working installation of Contenta CMS.
  • A Redis server (optional). Use the @contentacms/redis module to leverage the Redis cache back-end.

See the installation instructions.

Internal Development Notes

This is a dumping ground of notes. This section will disappear eventually, it’s just meant to save ideas for documentation to process some other time.

  • Introduce the ability to timeout requests.
  • Create a separate package using passport to integrate with Simple OAuth.
  • If all subrequests are to the CMS forward the blueprint to Drupal’s subrequests.
  • Compute the appropriate cache-control header from subquests responses.
  • Make sure to mention that the /healthckeck is for auto-scaling policies.
  • Create a @contentacms/redisShare submodule for a shared Redis server between Drupal and node.
  • Document that the proxied requests are not cached because they are considered end responses. The appropriate caching should be in the edge cache layer.
  • Make Cache-Control header overrides configurable.
  • Check feature conflict between cors.maxAge and OPTIONS cache control header.
  • Document better the JSON RPC support.
  • Add documentation about the cache controls

Contributors

Contributors
Mateu Aguiló Bosch

License

@contentacms/contentajs is MIT licensed.

contentajs's People

Contributors

adamrhunter avatar alexsenatore avatar bfodeke avatar e0ipso avatar ethnovode avatar infiniteluke avatar penyaskito avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

contentajs's Issues

Issue with got

Hello,

Some possibility have been remove from got.

  1. You can't now use :
    json: true

('in your got.js file).
responseType: 'json' do the job.

  1. The query : {query: JSON.stringify(request)} (in ContentaJsonRpc.js) doesn't seem to work . It's ok with searchParams: {query: JSON.stringify(request)} .

++

Passport & auth

Hi there - I'm curious if a separate package using passport to integrate with Simple OAuth has been developed anywhere?

Failure to auto-detect nested CMS installation?

My ContentaCMS is nested (localhost:MAMP-PORT/contenta/web), installed via contenta_jsonapi_project. When writing ContentaJS local config, 'cms.host' requires a complete path to the ContentaCMS to get any type of connection to the node proxy, otherwise connections are refused.

While the app is accepting connections, requests sent to the node proxy api (localhost:NODE-PORT/api) get a 404 response in HTML:
...<pre>Cannot GET /api</pre>...

Direct requests to ContentaCMS API work perfectly.

I've started to go through the built code, but haven't had much luck in finding a solution.

Suggestions?

Connect to fresh drupal 8

I want use a fresh drupal 8 install with jsonapi module. are there any way to connect contentajs to fresh drupal 8?

Error on yarn start

Followed install instructions here: https://github.com/contentacms/contentajs/blob/master/docs/install.md

Error on yarn start:

yarn start
yarn run v1.7.0
warning package.json: No license field
error Command "start" not found.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
node --version
v10.7.0
yarn --version
1.7.0

On my Mac:

/contenta/contentacms << installed contenta_jsonapi

/contenta/contentjs << installed this here, contents as follows:

config << has local.yml
node_modules
package.json
yarn.lock

I ran yarn start from within /contenta/contentjs

Documentation to implement SSR?

Is there any documentation on implementing SSR with this?

I've installed ContentaCMS and ContentaJS. ContentaJS is correctly proxying across to the cms api and returning responses but I receive failed GET requests if I attempt to request anything that's not an API request.

I'm sure there is a few more things to configure before I'll have working SSR with a react app but I haven't been able to find any documentation as to how the SSR works and how I can implement. Just that this supports it.

Edit: I kind of realise now that I was thinking about this from the perspective of progressive decoupling. While Contenta and ContentaJS utilize a fully decoupled approach. Now that realise that it makes sense to me now that I would not getting any response via the ContentaJs proxy unless its an api call.

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this 💪.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here is some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Invalid npm token.

The npm token configured in the NPM_TOKEN environment variable must be a valid token allowing to publish to the registry https://registry.npmjs.org/.

If you are using Two-Factor Authentication, make configure the auth-only level is supported. semantic-release cannot publish with the default auth-and-writes level.

Please make sure to set the NPM_TOKEN environment variable in your CI with the exact value of the npm token.


Good luck with your project ✨

Your semantic-release bot 📦🚀

Installation troubles

Hello,
Trying to install contentajs, not sure what the project route is. I have a folder /contenta and I have contenta cms in the /contenta/www/ directory. I have installed contentajs in the /contenta/ directory but I get the following error:

root@aegir:/contenta# git init && git add . && git ci -m 'feat: project initialization with Contenta JS'
Reinitialized existing Git repository in /contenta/.git/
git: 'ci' is not a git command. See 'git --help'.

Did you mean one of these?
am
commit
config
diff
fsck
gc
init
mv
rm

any ideas?

Please define YOUR_PROJECT_NAME

Sorry to bother you guys, but I'm having issues installing contenta js. I have a folder mysite.com that serves up from mysite.com/web so in my nginx conf server name is mysite.com and server route is mysite.com/web. So when I move the contentajs folder to my PROJECT_NAME is that mysite.com or mysite.com/web or something else? When I move the contentajs to the mysite.com folder npm install returns no package json. Please tell me what folder YOUR_PROJECT_NAME is supposed to be.

Thanks in advance

Add a GraphQL subproject

Ideally we'll want to have an example on how to expose our API using GraphQL as an alternative to JSON API.

This is currently blocked on:

Unable to access the server

Hello,

I am following the instruction to install the server and I am having a hard time to access the server.

After cloning the repo, I created the config local.yml :

cms:
  host: http://headless.devel

cors:
  origin:
    - '*'

then I run npm start, I see pm2 initializing but then when I hit localhost:3000 in my browser I get the error message :

This site can't be reached"

I tried running npm run debug but no success there too.

What am I missing ?

Thanks for your help !

Keep getting Cannot GET /api

Hello,

I have a lando drupal 8 installation set up using the contenta distro. The domain on my local http://colony.lndo.site.

I have followed the contenta js installation instructions from the you page.

Steps:

  1. Downloaded zip
  2. run npm install
  3. create local.yml
  4. add cms->host to http://colony.lndo.site.

When I visit http://localhost:3000/api i get the response Cannot GET /api. What's interesting is if I visit the domain without the /api. so...http://localhost:3000/ It looks like it's trying to load my contenta site.

Is there a piece that I am missing?

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.