Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swap AWS app to Manifold #2

Open
wants to merge 2 commits into
base: old-aws
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -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
7 changes: 0 additions & 7 deletions .env.example

This file was deleted.

1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.cache
.DS_Store
.manifoldrc
.env
node_modules/

# Elastic Beanstalk Files
Expand Down
2 changes: 2 additions & 0 deletions .manifoldrc.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
team = my-team
project = my-project
36 changes: 31 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,48 @@
# 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

```sh
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
3 changes: 3 additions & 0 deletions now.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "manifold-sample-app"
}
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand All @@ -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",
Expand Down
14 changes: 8 additions & 6 deletions server/config/database.mjs
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
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,
acquire: 30000,
idle: 10000,
},
operatorsAliases: false,
port: process.env.PGPORT,
username: process.env.PGUSER,
port: ENV.MANIFOLD_PGPORT,
username: ENV.MANIFOLD_PGUSER,
});

/* Models */
Expand Down
14 changes: 8 additions & 6 deletions server/config/email.mjs
Original file line number Diff line number Diff line change
@@ -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,
});
20 changes: 13 additions & 7 deletions server/tasks/sendResetEmail.mjs
Original file line number Diff line number Diff line change
@@ -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);
}
);