Progressively Enhanced React To Do List. HTML–first, Node, Express, PostgreSQL.
Have a look at the synchronous and asynchronous endpoints in action. Run the live demo at our Heroku Dino.
Install the grunt-cli package if you haven't before. This should be done as a global install:
npm install -g grunt-cli
Make sure you have grunt
installed by testing:
grunt --version
To interact with the application you'll need to be running PostgreSQL for the database. Install Postgres if you haven't already. Mac users can install Postgres via brew.
Create a synctodo database.
psql
CREATE DATABASE synctodo;
\q
Next import our example data. Data will be imported into a tasks
table.
psql synctodo < _build/db/synctodo.sql
First, clone a copy of this git repo by running:
git clone -b grunt git@github.com:jpdevries/synctodo.git
Then cd into the synctodo
folder and install the Node dependencies:
cd synctodo
npm install
You should now be able to build the files and run the Node server!
grunt build
npm run serve
The server will automatically restart when changes are made. To watch the Sass source files for changes and automatically rebuild the source files, run the grunt
command:
grunt #alias for grunt watch
By default this project runs on port 1187. To run it on a different port use the PORT
environmental variable:
PORT=8081 npm run serve #visit http://localhost:8081 in your browser
To use a database with a different name use the PGDATABASE
environmental variable:
PGDATABASE=anotherdb npm run serve
- Add, Complete, Archive, and Delete Tasks
- Progressive Enhancement (
.no-js
) support - Isomorphic HTML layer doubles as a data model for Redux
- Isomorphic server uses the same promises for asynchronous and synchronous requests
- React Routing
- React and Redux used on both server and client side
- REST API prefetches and fetches data to keep UI fresh
- Loads dependencies from CDN with local fallback
- Feature detection to only load scripts if they'll work (IE9+)
Homepage at /
Asynchronously posts to /api/tasks
Synchronously posts to /
Asynchronously posts to /api/tasks
Synchronously posts to /archive
Asynchronously posts to /api/tasks
Synchronously posts to /
Asynchronously posts to /api/tasks
Synchronously posts to /delete/tasks
Asynchronously posts to /api/tasks
A simple PostgreSQL database schema is used to store our tasks. See server.js
for the queries that interact with the database to add, complete, archive, unarchive, and delete tasks.
CREATE TABLE "tasks" (
id SERIAL PRIMARY KEY,
title varchar(255) NOT NULL DEFAULT '',
completed smallint NOT NULL DEFAULT '0',
archived smallint NOT NULL DEFAULT '0'
);
This component strives for WCAG 2.0 Guidelines Level AA. Please open an issue for any accessibility issue, feedback, or concern.