@comake/solid-on-rails
v0.10.0
Published
Runs a Node.js server using componentsjs preset with configurations for working with Solid.
Downloads
724
Readme
Solid on Rails was created to make it easy for developers to get up an running with SKL and Solid. Taking inspiration from the success of Ruby on Rails, it comes pre-configured with everything needed to create an application that can:
- Store application data in a database (relational or key-value)
- Expose an API (REST, GraphQL, etc.)
- Run asyncronous workloads in the background
- (Coming Soon) Store user data in a Solid pod
- (Coming Soon) Authenticate users with Solid OIDC
Features
Dependency Injection
The Solid on Rails framework is designed to be flexible such that people can easily run different configurations. To do so, Solid on Rails uses the dependency injection framework Components.js.
Components.js allows components to be instantiated and wired together declaratively using semantic configuration files. Solid on Rails also uses Components-Generator.js to automatically generate the necessary description configurations of all classes. Components are configured in JSON files, which makes it so that changing the configuration does not require any changes to the code.
Get started configuring your application
Storage
Solid on Rails utilizes the Data Mapper Pattern to separate an application's domain logic and it's usage of databases to store data. This means that you can create applications that are loosely coupled, and thus hightly scalable and maintainable.
The Data Mapper Pattern is implemented using TypeORM. It includes a system to run migrations on data in the database.
Routes
Like Rails, routes to connect URLs to code for the application's API or web pages are defined in a configuration file. Each route matches a URL pattern and HTTP method to a specific handler (or a chain of handlers). These handlers are defined in JSON using the dependency injection framework Components.js.
Background Jobs
Solid on Rails comes with a built in system for scheduling background jobs to be executed outside of the main process. Background job queues can solve many different problems, from smoothing out processing peaks to creating robust communication channels between microservices or offloading heavy work from one server to many smaller workers, etc.
A variety of queuing backends can be used but the default configuration uses Bull.
Learn more about Background Jobs
Requirements
Please ensure your operating system has the following software installed:
- Git - see GitHub's tutorial for installation
- Node.js - use nvm to install it on any OS, or brew on a mac
- Redis - follow the Redis installation guide for your OS. Alternatively, run the Redis Docker image.
- A database - for storage of application data (if required). See TypeORM's Data Source documentation for options that work out-of-the-box. Run your database as a service on your OS or with Docker.
{% hint style="info" %} If your application doesn't need background job processing, you don't need to run Redis (See How to remove Background Jobs). {% endhint %}
{% hint style="info" %} If your application doesn't need to store applicaton data, you don't need to run a database (See How to remove application data storage). {% endhint %}
Quick Start
Create a Node.js application (if you haven't already):
mkdir my-application
cd my-application
npm init
Install the latest server version from the npm package repository:
npm install --save @comake/solid-on-rails
Add the start command to scripts
in your package.json
"scripts": {
"start": "npx solid-on-rails"
}
Start the server! 🚀
npm run start
Continue to the Getting Started guide to learn how to create your own Components.js configuration to customize your application with your own routes, plugins, background jobs, and more.
TODO
- [ ] Break up BaseHttpServerFactory createServer function
- [ ] UiEnabledConverter?
- [ ] Add integration tests for Storage Accessor
- [ ] Add migration documentation
- [ ] Add CLI documentation
Note
There's a bug with typeorm and componentsjs-generator
You have to add "./package.json": "./package.json",
to the exports of node_modules/typeorm/package.json
.
See:
- https://github.com/typeorm/typeorm/issues/9178
- https://github.com/LinkedSoftwareDependencies/Components-Generator.js/issues/83