This setup is using:
It is for:
- Running a website with users.
- Using Google web browser OAuth.
- Replacing my old work with next-postgres-sequelize.
- Deploying with https://render.com or something like it.
Clone this repository!
Create an .env file at your project root.
CLIENT_ID=GET_ME_FROM_GOOGLE
CLIENT_SECRET=GET_ME_FROM_GOOGLE
JWT_SECRET=74b8b454-29a6-4282-bdec-7e2895c835eb
PASSWORD_SECRET=$2b$10$CVMCvJeC9vco2MwAAlEbBO
- Generate your own
PASSWORD_SECRETwithBCrypt.genSaltSync(10). - Generate your own
JWT_SECRET. - Obtain
CLIENT_IDandCLIENT_SECRETfrom https://console.developers.google.com after you setup your application. - Use
CMD+Fto findREDIRECT_URISin~/common/credentials. Google needs this string for the Authorized redirect URIs setting. The default is:http://localhost:1337/sign-in-confirm.
Enable People API.
All steps assume you have Homebrew installed on your machine. You might want to install iTerm since you need multiple terminal windows open as well.
Using another version of Postgres? That may be okay. I use Postgres 11 to share versions with Render but I have tried these steps with Postgres 9 as well.
Mileage may vary with a different version.
brew uninstall postgresql
brew install postgresql@11
brew link postgresql@11 --forceMake sure NodeJS version 10+ is installed on your machine.
brew install nodeWe use nodemon to reload the site whenever changes are made locally.
npm install -g nodemonOnce you have Postgres and Node, run these commands:
npm install
npm run devIn a seperate terminal tab run your postgres version, in this case the command below is referencing Postgres 11.
postgres -D /usr/local/var/postgresql@11 -p 1334- Start with creating an admin user.
- Finish with creating a database for testing.
# Enter Postgres console
psql postgres -p 1334
# Create a new user for yourself
CREATE ROLE admin WITH LOGIN PASSWORD 'oblivion';
# Allow yourself to create databases
ALTER ROLE admin CREATEDB;
# Or just go ham and become a super user
ALTER USER admin WITH SUPERUSER;
# Exit Postgres console
\q
# Log in as your new user.
psql postgres -p 1334 -U admin
# Create a database named: nptdb.
# If you change this, update knexfile.js
CREATE DATABASE nptdb;
# Give your self privileges
GRANT ALL PRIVILEGES ON DATABASE nptdb TO admin;
# List all of your databases
\list
# Connect to your newly created DB as a test
\connect nptdb
# Exit Postgres console
\qRun the following commands:
npm run do-setup-database
npm run do-seed-databaseView http://localhost:1337 in your browser.
Coming soon.
Feel free to slang any feels to @wwwjim.