├── .gitignore
├── LICENSE.md
├── README.md
├── components
├── KittenItem.js
└── PageHead.js
├── config
└── config.js
├── docs
└── demo.gif
├── package.json
├── pages
├── _app.js
└── index.js
├── redux
└── reduxApi.js
├── server
├── api
│ └── kittens.js
├── routes.js
└── server.js
├── static
└── app.css
└── yarn.lock
/.gitignore:
--------------------------------------------------------------------------------
1 | .next/
2 | node_modules/
3 | .env
4 |
5 | # See https://help.github.com/ignore-files/ for more about ignoring files.
6 |
7 | # dependencies
8 | /node_modules
9 |
10 | # testing
11 | /coverage
12 |
13 | # production
14 | /build
15 |
16 | # misc
17 | .DS_Store
18 | .env.local
19 | .env.development.local
20 | .env.test.local
21 | .env.production.local
22 |
23 | npm-debug.log*
24 | yarn-debug.log*
25 | yarn-error.log*
26 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | Copyright (c) 2019, Tom Söderlund
2 |
3 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
4 |
5 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
6 |
7 | Source: http://opensource.org/licenses/ISC
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Next.js (React) + Redux + Express REST API + Postgres SQL boilerplate
2 |
3 | _Note: this is my v2 boilerplate for React web apps. See also my [Firebase and React Hooks boilerplate](https://github.com/tomsoderlund/nextjs-pwa-firebase-boilerplate) and [REST + MongoDB boilerplate](https://github.com/tomsoderlund/nextjs-express-mongoose-crudify-boilerplate)._
4 |
5 | ## Support this project
6 |
7 | Did you or your company find `nextjs-sql-rest-api-boilerplate` useful? Please consider giving a small donation, it helps me spend more time on open-source projects:
8 |
9 | [](https://ko-fi.com/tomsoderlund)
10 |
11 | ## Why is this awesome?
12 |
13 | This is a great starting point for a any project where you want **React + Redux** (with server-side rendering, powered by [Next.js](https://github.com/zeit/next.js)) as frontend and **Express/Postgres SQL** as a REST API backend.
14 | _Lightning fast, all JavaScript._
15 |
16 | * Simple REST API routes with [`sql-wizard`](https://github.com/tomsoderlund/sql-wizard).
17 | * Redux REST support with `redux-api` and `next-redux-wrapper`.
18 | * Flexible client-side routing with `next-routes` (see `server/routes.js`).
19 | * Flexible configuration with `config/config.js` and `.env` file.
20 | * Hot reloading with `nodemon`.
21 | * Testing with Jasmine.
22 | * Code formatting and linting with StandardJS.
23 | * JWT authentication for client-server communication (coming).
24 |
25 | ## Demo
26 |
27 | See [**nextjs-sql-rest-api-boilerplate** running on Heroku here](https://nextjs-sql-rest-api.herokuapp.com/).
28 |
29 | 
30 |
31 | ## How to use
32 |
33 | Clone this repository:
34 |
35 | git clone https://github.com/tomsoderlund/nextjs-sql-rest-api-boilerplate.git [MY_APP]
36 |
37 | Install dependencies:
38 |
39 | cd [MY_APP]
40 | yarn # or npm install
41 |
42 | Install Postgres and set up the database:
43 |
44 | psql postgres # Start the Postgres command-line client
45 |
46 | CREATE DATABASE "nextjs-sql-rest-api-boilerplate"; -- You can also use \connect to connect to existing database
47 | CREATE TABLE kitten (id serial, name text); -- Create a blank table
48 | INSERT INTO kitten (name) VALUES ('Pugget'); -- Add example data
49 | SELECT * FROM kitten; -- Check data exists
50 | \q
51 |
52 | Start it by doing the following:
53 |
54 | export DATABASE_URL=[your Postgres URL] # Or use a .env file
55 | yarn dev
56 |
57 | In production:
58 |
59 | yarn build
60 | yarn start
61 |
62 | If you navigate to `http://localhost:3123/` you will see a [Next.js](https://github.com/zeit/next.js) page with a list of kittens (or an empty list if you haven’t added one).
63 |
64 | Your API server is running at `http://localhost:3123/api/kittens`
65 |
66 |
67 | ## Deploying
68 |
69 | ### Deploying on Heroku
70 |
71 | heroku create [MY_APP]
72 | heroku addons:create heroku-postgresql:hobby-dev
73 | git push heroku master
74 |
75 | ### Deploying on Now
76 |
77 | (Coming)
78 |
--------------------------------------------------------------------------------
/components/KittenItem.js:
--------------------------------------------------------------------------------
1 | const KittenItem = ({ kitten, index, inProgress, handleUpdate, handleDelete }) => (
2 |