Skip to content

Commit 1851d9e

Browse files
committed
Added configuration section, Upgraded dependencies
1 parent 69906a5 commit 1851d9e

File tree

6 files changed

+441
-116
lines changed

6 files changed

+441
-116
lines changed

README.md

Lines changed: 119 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
* [Install](#install)
4444
* [Usage](#usage)
4545
* [Continuous Integration and Code Coverage](#continuous-integration-and-code-coverage)
46+
* [Configuration](#configuration)
4647
* [Tutorials](#tutorials)
4748
* [Community](#community)
4849
* [Related](#related)
@@ -451,6 +452,113 @@ Here are the simple steps required to setup [SemaphoreCI][] with [Codecov][]:
451452
7. Run a test build ("Rebuild last revision") on SemaphoreCI and check to make sure your code coverage report uploads properly on Codecov
452453
8. Ensure your `README.md` file has the build status and code coverage badges rendered properly (you will need to use a different badge link from each provider if your GitHub repository is private)
453454

455+
### Configuration
456+
457+
#### Environment Variables
458+
459+
We have made configuration of your Lad project easy through a [dotenv][] configuration, per [Twelve-Factor][twelve-factor].
460+
461+
We use the following three packages to manage configuration:
462+
463+
* [dotenv-extended][] - allows us to craft a `.env` definition (otherwise known as a "schema") in a file named `.env.schema`
464+
* [dotenv-mustache][] - allows us to use the [Mustache templating language][mustache] in our `.env` and `.env.defaults` confguration files
465+
* [dotenv-parse-variables][] - automatically parses variable types from `process.env` (e.g. `FOO=4` will set `process.env.FOO = 4` with a `Number` variable type instead of a `String`)
466+
467+
Configuration is managed by the following, in order of priority:
468+
469+
1. Contents of the file at `config/index.js` (reads in `process.env` environment variables)
470+
2. Contents of the files in directories under `config/environments/` (sets defaults per environment, e.g. you can pass `NODE_ENV=staging` and it will load the file at `config/environments/staging.js`)
471+
3. Environment variables used to override defaults or set required ones (e.g. `NODE_ENV=production`)
472+
4. Environment configuration in `.env`
473+
5. Environment configuration in `.env.defaults`
474+
475+
Precedence is taken by the environment configuration files, environment variables, then the `.env` file.
476+
477+
Basically [dotenv][] won't set an environment variable if it already detects it was passed as an environment variable.
478+
479+
Take a look at the [config](template/config) folder contents and also at the defaults at [.env.defaults](template/.env.defaults).
480+
481+
#### Outbound Email Configuration
482+
483+
> By default in the development environment we simply render the email in your browser.
484+
485+
However in other environments such as production, you definitely want emails to be sent.
486+
487+
We built-in support for Postmark by default (though you can swap in your own `transport` provider in the `jobs/email.js` file):
488+
489+
1. Go to [https://postmarkapp.com](https://postmarkapp.com?utm_source=lad) – Start Free Trial
490+
2. Create a free trial account, then click Get Started, and proceed to create a "Server" and "Sender Signature"
491+
3. Copy/paste the "Server API token" under "Credentials" in your `.env` file (example below)
492+
493+
```diff
494+
-POSTMARK_API_TOKEN=
495+
+POSTMARK_API_TOKEN=ac6657eb-2732-4cfd-915b-912b1b10beb1
496+
```
497+
498+
4. Modify the `SEND_EMAIL` variable in `.env` from `false` to `true`
499+
500+
#### Favicon and Touch Icon Configuration
501+
502+
You can customize the favicon and touch icons – just generate a new set at <https://realfavicongenerator.net> and overwrite the existing in the [assets](template/assets) folder.
503+
504+
Just make sure that any relative paths match up in the `assets/browserconfig.xml` and `assets/manifest.json` files.
505+
506+
#### Authentication Methods
507+
508+
##### Google Auth
509+
510+
> In order to add Google sign-in to your app (so users can log in with their Google account):
511+
512+
1. Go to <https://console.developers.google.com> – Create a project (and fill out your project information – if you need a 120x120px default image, [you can use this one](media/lad-120x120.png)
513+
2. Under your newly created project, go to Credentials – Create credentials – OAuth client ID – Web application
514+
3. Set "Authorized JavaScript origins" to `http://yourdomain.com` (replace with your domain) and also `http://localhost:3000` (for local development)
515+
4. Set "Authorized redirect URIs" to `http://yourdomain.com/auth/google/ok` (again, replace with your domain) and also `http://localhost:3000/auth/google/ok` (again, for local development)
516+
5. Copy and paste the newly created key pair for respective properties in your `.env` file (example below)
517+
518+
```diff
519+
-GOOGLE_CLIENT_ID=
520+
+GOOGLE_CLIENT_ID=424623312719-73vn8vb4tmh8nht96q7vdbn3mc9pd63a.apps.googleusercontent.com
521+
-GOOGLE_CLIENT_SECRET=
522+
+GOOGLE_CLIENT_SECRET=Oys6WrHleTOksqXTbEY_yi07
523+
```
524+
525+
6. In `config/index.js`, make sure that `AUTH_GOOGLE_ENABLED=true` to enable this authentication method.
526+
527+
#### Amazon S3 and CloudFront Asset Setup
528+
529+
> In order for your assets to get properly served in a production environment, you'll need to configure AWS:
530+
531+
1. Go to <https://console.aws.amazon.com/iam/home#security_credential> ‐ Access Keys – Create New Access Key
532+
2. Copy and paste the newly created key pair for respective properties in your `.env` file (example below)
533+
534+
```diff
535+
-AWS_IAM_KEY=
536+
+AWS_IAM_KEY=AKIAJMH22P6W674YFC7Q
537+
-AWS_IAM_SECRET=
538+
+AWS_IAM_SECRET=9MpR1FOXwPEtPlrlU5WbHjnz2KDcKWSUcB+C5CpS
539+
```
540+
541+
3. Enable your API by clicking on Overview and then clicking the Enable button
542+
4. Go to <https://console.aws.amazon.com/s3/home> – Create Bucket
543+
5. Create a bucket and copy/paste its name for the property in `.env` (example below)
544+
545+
```diff
546+
-AWS_S3_BUCKET=
547+
+AWS_S3_BUCKET=lad-development
548+
```
549+
550+
6. Go to <https://console.aws.amazon.com/cloudfront/home> – Create Distribution – Get Started
551+
7. Set "Origin Domain Name" equal to your S3 bucket name (their autocomplete drop-down will help you find it)
552+
8. Leave the remaining defaults as is (some fields might be blank, this is OK)
553+
9. Copy/paste the newly created Distribution ID and Domain Name for respective properties in your `.env` file (example below)
554+
555+
```diff
556+
-AWS_CF_DI=
557+
+AWS_CF_DI=E2IBEULE9QOPVE
558+
-AWS_CF_DOMAIN=
559+
+AWS_CF_DOMAIN=d36aditw73gdrz.cloudfront.net
560+
```
561+
454562
### Tutorials
455563

456564
* [Writing Your App](https://github.com/koajs/koa#getting-started)
@@ -490,7 +598,7 @@ If you are seeking permission to use these trademarks, then please [contact us](
490598
[MIT](LICENSE) © [Nick Baugh](http://niftylettuce.com)
491599
492600
493-
##
601+
##
494602
495603
<a href="#"><img src="media/lad-footer.png" alt="#" /></a>
496604
@@ -567,3 +675,13 @@ If you are seeking permission to use these trademarks, then please [contact us](
567675
[nodemailer]: https://nodemailer.com/
568676
569677
[email-templates]: https://github.com/niftylettuce/node-email-templates
678+
679+
[mustache]: https://github.com/janl/mustache.js/
680+
681+
[dotenv-extended]: https://github.com/keithmorris/node-dotenv-extended
682+
683+
[dotenv-mustache]: https://github.com/samcrosoft/dotenv-mustache
684+
685+
[dotenv-parse-variables]: https://github.com/niftylettuce/dotenv-parse-variables
686+
687+
[dotenv]: https://github.com/motdotla/dotenv

media/lad-120x120.png

11.5 KB
Loading

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"is-url": "^1.2.2",
3434
"limax": "^1.5.0",
3535
"npm-conf": "^1.1.2",
36-
"sao": "^0.21.9",
36+
"sao": "^0.22.1",
3737
"semver": "^5.4.1",
3838
"superb": "^1.3.0",
3939
"update-notifier": "^2.2.0",
@@ -48,8 +48,8 @@
4848
"eslint-plugin-compat": "^1.0.4",
4949
"eslint-plugin-prettier": "^2.2.0",
5050
"husky": "^0.14.3",
51-
"lint-staged": "^4.1.0",
52-
"nyc": "^11.2.0",
51+
"lint-staged": "^4.1.3",
52+
"nyc": "^11.2.1",
5353
"prettier": "^1.6.1",
5454
"remark-cli": "^4.0.0",
5555
"remark-preset-github": "^0.0.6",

template/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"koa-manifest-rev": "^0.3.0",
6464
"koa-methodoverride": "^2.0.0",
6565
"koa-no-trailing-slash": "^2.0.0",
66-
"koa-passport": "^3.0.0",
66+
"koa-passport": "^4.0.0",
6767
"koa-redis": "^3.0.0",
6868
"koa-response-time": "^2.0.0",
6969
"koa-router": "^7.2.1",
@@ -84,7 +84,7 @@
8484
"passport-local-mongoose": "^4.2.1",
8585
"pluralize": "^7.0.0",
8686
"popper.js": "^1.12.5",
87-
"pug": "^2.0.0-rc.3",
87+
"pug": "^2.0.0-rc.4",
8888
"qs": "^6.5.0",
8989
"randomstring-extended": "^1.0.0",
9090
"redis": "^2.8.0",
@@ -100,7 +100,7 @@
100100
"webfontloader": "^1.6.28"
101101
},
102102
"devDependencies": {
103-
"autoprefixer": "^7.1.3",
103+
"autoprefixer": "^7.1.4",
104104
"ava": "^0.22.0",
105105
"babel-plugin-lodash": "^3.2.11",
106106
"babel-plugin-transform-object-rest-spread": "^6.26.0",
@@ -134,10 +134,10 @@
134134
"gulp-xo": "^0.16.0",
135135
"husky": "^0.14.3",
136136
"imagemin-pngquant": "^5.0.1",
137-
"lint-staged": "^4.1.2",
137+
"lint-staged": "^4.1.3",
138138
"ms": "^2.0.0",
139139
"nodemon": "^1.12.0",
140-
"nyc": "^11.1.0",
140+
"nyc": "^11.2.1",
141141
"postcss-reporter": "^5.0.0",
142142
"prettier": "^1.6.1",
143143
"remark-cli": "^4.0.0",

0 commit comments

Comments
 (0)