Bedrock lets you set up a production-ready Node web application in under 10 minutes. It is a collection of popular frameworks that work well together. It is great for dashboards, CRUD webapps, and more.
Bedrock is built on Sails, which is a popular MVC Framework that is built on Express. It has all of the great features that Sails ships with, such as:
- Reusable Security Policies (Middleware)
- Configurable via a global
- Encourages use of reusable services.
- Waterline ORM that works well with multiple popular databases such as MySQL, Postgres, Mongo, etc.
- Follows MVC conventions, which keeps your code organized as your project grows.
- Auto-generates simple REST APIs based on your models, using Blueprint.
- It is just an Express server under the hood, so all Express modules still work.
Check out all the features on the Sails documentation page.
On top of the Sails features, Bedrock adds in a few nice-to-haves on the server side:
- All the code you need to setup user authentication flow
- Support for Database Migrations
- Configure the server for various
NODE_ENVsuch as development, staging, and production
Bedrock hooks up React, Flux, and React Router to make frontend development very enjoyable. Here are the features that you get:
- React Routing is setup, so you can just start building components and routes
- NuclearJS is Bedrock’s Flux Library, and its project directory is setup with the necessary files.
You can learn more about Bedrock’s frontend stack on the Frontend Development with Bedrock page.
Bedrock is the starting point of your Node application. To install, you should clone the project, and then build on top of it.
git clone ... <project-name> cd <project-name> npm install
Configure Database Connection
config/connections.js. Update the
mysql connection details. At this point, you may need to create a new database.
If you want to use a different database (PostgreSQL or Mongo), remove the
mysql connection, and create a new connection, as shown in the comments in the file.
If you don’t want any database, you can just remove everything in
config/connections.js but understand that user authentication won’t work.
Migrate database tables
Bedrock sets up authentication for your server, and creates Login, Signup, and Reset password pages. It uses PassportJS to accomplish this.
To facilitate this, you need to run a migration to create the
Passports table. Just run this from the command line:
After it runs, check your database and you should see `Users` and `Passports` table created. We will talk more about migrations in the Best Practices section. ### Build JS/CSS assets Bedrock uses Grunt to build the CSS and JS assets. To build, just run:
This will run the CSS and JS assets using Webpack. It will also start watching for CSS and JS changes.
Run the server
To run the server, run:
By default, it will start up the server on port 1337. To configure the PORT or NODE_ENV, you can prefix those variables:
NODE_ENV=staging PORT=9999 sails --debug lift
Bedrock is composed of these open-source frameworks.
Sails: Sails makes it easy to build custom, enterprise-grade Node.js apps. It is designed to emulate the familiar MVC pattern of frameworks like Ruby on Rails, but with support for the requirements of modern apps: data-driven APIs with a scalable, service-oriented architecture
React Router: React Router is a complete routing library for React.
NuclearJS: Traditional Flux architecture built with ImmutableJS data structures. Very similar to Redux.