diff --git a/.env b/.env new file mode 100644 index 0000000..1f1ae83 --- /dev/null +++ b/.env @@ -0,0 +1,7 @@ +MANIFOLD_PGDATABASE=$PGDATABASE +MANIFOLD_PGHOST=$PGHOST +MANIFOLD_PGPASSWORD=$PGPASSWORD +MANIFOLD_PGPORT=$PGPORT +MANIFOLD_PGUSER=$PGUSER +MANIFOLD_MAILGUN_APIKEY=$MAILGUN_APIKEY +MANIFOLD_MAILGUN_DOMAIN=$MAILGUN_DOMAIN diff --git a/.env.example b/.env.example deleted file mode 100644 index a4249c6..0000000 --- a/.env.example +++ /dev/null @@ -1,7 +0,0 @@ -PGHOST= -PGUSER= -PGDATABASE=users -PGPASSWORD= -PGPORT=5432 -SESKEY= -SESSECRET= diff --git a/.gitignore b/.gitignore index 939dcc1..0714e43 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ .cache .DS_Store .manifoldrc -.env node_modules/ # Elastic Beanstalk Files diff --git a/.manifoldrc.example b/.manifoldrc.example new file mode 100644 index 0000000..bd20da7 --- /dev/null +++ b/.manifoldrc.example @@ -0,0 +1,2 @@ +team = my-team +project = my-project diff --git a/README.md b/README.md index fa673c2..c3ef8aa 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,31 @@ # Manifold Sample App -This is the Original AWS version. The updated Manifold version lives at [manifold][branch-manifold]. +You’re viewing the updated **Manifold** version of the app. To see the old +AWS version, view the [old-aws][branch-old-aws] branch. + +## Example + +🖥 https://manifold-sample-app-ohrnvaytsi.now.sh + +Credentials: + +``` +sample-app@manifold.co +verysecurepassword +``` ## Local Installation ```sh +brew install manifoldco/brew/manifold-cli yarn yarn seed ``` -Configure the values in [`.env.example`][dotenv] and save as `.env` using -your own values from AWS RDS Postgres and AWS Simple Email. +After creating a project in [Manifold Dashboard][dashboard], edit the +`.manifoldrc.example` file and save as `.manifoldrc` (delete `team` if you’re +not using Manifold Teams). Running `yarn dev` or `yarn start` will +automatically inline variables from your Manifold project! ## Development Server @@ -18,5 +33,16 @@ your own values from AWS RDS Postgres and AWS Simple Email. yarn dev ``` -[branch-manifold]: https://github.com/manifoldco/manifold-sample-app/ -[dotenv]: ./.env.example +## Deployment + +Deployment is set up to use [Zeit Now][zeit-now]. Once configured, run + +```sh +now +``` + +To deploy your own instance. + +[branch-old-aws]: https://github.com/manifoldco/manifold-sample-app/tree/old-aws +[dashboard]: https://dashboard.manifold.co +[zeit-now]: https://zeit.co/now diff --git a/now.json b/now.json new file mode 100644 index 0000000..3c0b38d --- /dev/null +++ b/now.json @@ -0,0 +1,3 @@ +{ + "name": "manifold-sample-app" +} diff --git a/package.json b/package.json index f87a9b2..052726e 100644 --- a/package.json +++ b/package.json @@ -9,12 +9,13 @@ "scripts": { "client": "babel src -d dist --ignore 'src/**/*.test.js'", "client:watch": "babel src --watch -d dist --ignore 'src/**/*.test.js'", - "dev": "concurrently 'npm run client:watch' 'npm run postcss:watch' 'nodemon -- --experimental-modules server/index.mjs'", - "build": "npm run client && npm run server && npm run postcss", - "postcss": "postcss src/main.css -o dist/assets/main.css", + "dev": "manifold run 'npm run dev:command'", + "dev:command": "concurrently 'npm run client:watch' 'npm run postcss:watch' 'nodemon -- --experimental-modules server/index.mjs'", + "build": "manifold run 'npm run client && npm run postcss'", + "postcss": "postcss src/main.css -o dist/client/assets/main.css", "postcss:watch": "postcss src/main.css -o dist/assets/main.css -w", "seed": "node server/tasks/seed.mjs --experimental-modules", - "start": "nodemon server/index.ms --experimental-modules" + "start": "manifold run 'nodemon server/index.mjs -- --experimental-modules'" }, "keywords": [], "author": "", @@ -27,8 +28,9 @@ "bcrypt": "^1.0.3", "cors": "^2.8.4", "dotenv": "^5.0.1", + "dotenv-expand": "^4.2.0", "express": "^4.16.3", - "node-ses": "^2.1.0", + "mailgun-js": "^0.16.0", "nodemon": "^1.17.3", "passport": "^0.4.0", "passport-local": "^1.0.0", diff --git a/server/config/database.mjs b/server/config/database.mjs index 733fdc3..ea8057e 100644 --- a/server/config/database.mjs +++ b/server/config/database.mjs @@ -1,18 +1,20 @@ import path from 'path'; import fs from 'fs'; import dotenv from 'dotenv'; +import dotenvExpand from 'dotenv-expand'; import bcrypt from 'bcrypt'; import Sequelize from 'sequelize'; -dotenv.config(); +const ENV = dotenv.config(); +dotenvExpand(ENV); /* Config */ const sequelize = new Sequelize({ - database: process.env.PGDATABASE, + database: ENV.MANIFOLD_PGDATABASE, dialect: 'postgres', - host: process.env.PGHOST, - password: process.env.PGPASSWORD, + host: ENV.MANIFOLD_PGHOST, + password: ENV.MANIFOLD_PGPASSWORD, pool: { max: 5, min: 0, @@ -20,8 +22,8 @@ const sequelize = new Sequelize({ idle: 10000, }, operatorsAliases: false, - port: process.env.PGPORT, - username: process.env.PGUSER, + port: ENV.MANIFOLD_PGPORT, + username: ENV.MANIFOLD_PGUSER, }); /* Models */ diff --git a/server/config/email.mjs b/server/config/email.mjs index 2176295..3d829ce 100644 --- a/server/config/email.mjs +++ b/server/config/email.mjs @@ -1,9 +1,11 @@ -import ses from 'node-ses'; +import dotenv from 'dotenv'; +import dotenvExpand from 'dotenv-expand'; +import mailgun from 'mailgun-js'; -// SESKEY: AWS Access Key ID for SES-capable IAM user -// SESSECRET: AWS Secret Access Key for SES-capable IAM user +const ENV = dotenv.config(); +dotenvExpand(ENV); -export const client = ses.createClient({ - key: process.env.SESKEY, - secret: process.env.SESSECRET, +export const client = mailgun({ + apiKey: ENV.MANIFOLD_MAILGUN_APIKEY, + domain: ENV.MANIFOLD_MAILGUN_DOMAIN, }); diff --git a/server/tasks/sendResetEmail.mjs b/server/tasks/sendResetEmail.mjs index b125468..c689dba 100644 --- a/server/tasks/sendResetEmail.mjs +++ b/server/tasks/sendResetEmail.mjs @@ -1,10 +1,16 @@ import { client } from '../config/email'; export const sendResetEmail = email => - client.sendEmail({ - to: email, - from: 'support@myapp.com', - subject: 'Reset Password for Sample App', - message: - 'Test sent successfully! There isn’t actually a reset link because this is only a demo.', - }); + client.messages().send( + { + to: email, + from: 'support@myapp.com', + subject: 'Reset Password for Sample App', + text: + 'Test sent successfully! There isn’t actually a reset link because this is only a demo.', + }, + (err, body) => { + if (err) return console.log(err); + return console.log(body); + } + );