Build a Node web app with user authentication, security, and more in under 10 minutes. Now supports React Hot Loading for super-fast development. :ok_hand:
Bedrock lets you set up a production-ready webapp in under 10 minutes.
Three primary reasons:
We will talk about the installation in more detail in the next section, but here is the quickstart guide.
git clone [email protected]:tilomitra/bedrock.git <project-name>
cd <project-name>
npm install
Then, open config/connections.js
and update your database connection details.
Then, run the migrations to create the relevant database tables.
# Run migrations
grunt db:migrate:up
Then, simply start everything.
# Start servers
npm start
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
Go into 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.
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 Users
and Passports
table. Just run this from the command line:
grunt db:migrate:up
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.
To start developing, run:
npm start
This will start up 3 things:
In production mode, you'll want to build your assets ahead of time. To do this, run:
grunt buildProd
This will build your assets and store it in the www/
directory.
Then, you can run your server in production mode:
NODE_ENV=production sails lift
This will start up the NodeJS server in production mode. If you want this to be a long-lived background task, consider using a Node Process Manager like pm2.
Bedrock is built on Sails, so it has all of the great features that Sails ships with.
This includes, but is not limited to:
config
object.Mailer
service.Check out all the features on the Sails documentation page. I've used raw Express and I've used Sails, and I will take Sails everytime guys.
Bedrock lets you build reusable components using React and call its API via Flux Actions. Pages are linked together using React Router
Here's how it works at a high level:
It is simple, one-way communication that scales to hundreds of components (We have 100+ components in our internal fork of Bedrock).
Learn more about Bedrock on Node Web Apps. Here are some useful tutorials:
Sign up to the Node Web Apps newsletter to stay up to date on new tutorials.
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: A JavaScript Library for building user interfaces
React Router: React Router is a complete routing library for React.
NuclearJS: Traditional Flux architecture built with ImmutableJS data structures. Very similar to Redux.
Webpack: A module bundler for front-end assets. It is used in Bedrock for chunking JavaScript files to be loaded on demand and hot reloading.
React Hot Loader: Tweak React components in real time without page refreshes.