Skip to content

Commit

Permalink
feat: lot of work (api/web/bull/graceful/proxy/emails)
Browse files Browse the repository at this point in the history
  • Loading branch information
niftylettuce committed Sep 13, 2019
1 parent 4bfd01d commit a9ffa94
Show file tree
Hide file tree
Showing 57 changed files with 1,059 additions and 956 deletions.
150 changes: 91 additions & 59 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<a href="https://ladjs.github.io/lad/"><img src="media/lad.png" alt="lad" /></a>
</h1>
<div align="center">
<a href="http://slack.crocodilejs.com"><img src="http://slack.crocodilejs.com/badge.svg" alt="chat" /></a>
<a href="https://slack.crocodilejs.com"><img src="https://slack.crocodilejs.com/badge.svg" alt="chat" /></a>
<a href="https://travis-ci.org/ladjs/lad"><img src="https://travis-ci.org/ladjs/lad.svg?branch=master" alt="build status" /></a>
<a href="https://codecov.io/github/ladjs/lad"><img src="https://img.shields.io/codecov/c/github/ladjs/lad/master.svg" alt="code coverage" /></a>
<a href="https://github.com/sindresorhus/xo"><img src="https://img.shields.io/badge/code_style-XO-5ed9c7.svg" alt="code style" /></a>
Expand Down Expand Up @@ -63,7 +63,7 @@ These microservices are preconfigured for security, performance, and graceful re

* Webapp server → [web.js](template/web.js)
* API server → [api.js](template/api.js)
* Job scheduler → [agenda.js](template/agenda.js)
* Job scheduler → [bull.js](template/bull.js)
* Proxy server → [proxy.js](template/proxy.js)

### Front-end
Expand All @@ -85,11 +85,11 @@ These microservices are preconfigured for security, performance, and graceful re

### Back-end

* Redis, sessions, and flash messages (both toast and modal messages thanks to [SweetAlert2][])
* Koa-based webapp and API servers
* Redis, sessions, and flash toast and modal [SweetAlert2][] messages (uses [ioredis][] which has support for [Cluster][redis-cluster], [Sentinel][redis-sentinel], and more)
* Koa-based webapp and API servers (uses HTTP/2 for production!)
* Pagination built-in (using [ctx-paginate][])
* RESTful API with BasicAuth and versioning
* Automated job scheduler with cron and human-readable syntax (backed by [Mongoose][] and [Agenda][])
* Automated job scheduler with cron and human-readable syntax (backed by [Mongoose][] and [Bull][])
* Passport-based authentication and group-based (Unix-like) permissioning
* Stripe-inspired error handling
* Mongoose and MongoDB with common database plugins
Expand Down Expand Up @@ -244,31 +244,41 @@ yarn start all

##### Debugging

As similar to running any other [node][] process, simply use the environment variable `DEBUG`:
* `DEBUG` - debug using [debug][] output (widely adopted package in the community for debugging across all Node packages):

[npm][]:
```sh
DEBUG=* ...
```

```sh
DEBUG=* npm start
```
* `NODE_DEBUG` - debug [node][] internal modules:

[yarn][]:
```sh
NODE_DEBUG=* ...
```

```sh
DEBUG=* yarn start all
```
* `MONGOOSE_DEBUG` - debug Mongoose raw database operation output:

You can also use `NODE_DEBUG` if desired to debug [node][] internal modules.
```sh
MONGOOSE_DEBUG=true ...
```

```sh
NODE_DEBUG=* ...
```
* `TRANSPORT_DEBUG` - debug Nodemailer transport:

And also `MONGOOSE_DEBUG` if you'd like Mongoose raw database operation output.
```sh
TRANSPORT_DEBUG=true ...
```

```sh
MONGOOSE_DEBUG=true ...
```
* `REDIS_MONITOR` - debug Redis using `MONITOR` (uses [@ladjs/redis][ladjs-redis] and passes `true` for the `monitor` argument):

```sh
REDIS_MONITOR=true ...
```

* `REDIS_FRIENDLY_ERROR_STACK` - debug Redis with friendly error stack messages (see [showFriendlyErrorStack][show-friendly-error-stack] option of [ioredis][])

```sh
REDIS_FRIENDLY_ERROR_STACK=true ...
```

#### Production

Expand Down Expand Up @@ -506,39 +516,53 @@ tree template -I "build|node_modules|coverage|test"
template
├── LICENSE
├── README
├── agenda.js
├── api.js
├── app
│   ├── controllers
│   │   ├── api
│   │   │   ├── index.js
│   │   │   └── v1
│   │   │   ├── index.js
│   │   │   ├── log.js
│   │   │   └── users.js
│   │   ├── index.js
│   │   └── web
│   │   ├── admin
│   │   │   ├── index.js
│   │   │   └── users.js
│   │   ├── auth.js
│   │   ├── contact.js
│   │   └── index.js
│   │   ├── index.js
│   │   ├── my-account.js
│   │   └── support.js
│   ├── models
│   │   ├── index.js
│   │   ├── inquiry.js
│   │   └── user.js
│   └── views
│   ├── 404.pug
│   ├── 500.pug
│   ├── _breadcrumbs.pug
│   ├── _footer.pug
│   ├── _nav.pug
│   ├── _pagination.pug
│   ├── _register-or-login.pug
│   ├── about.pug
│   ├── admin.pug
│   ├── contact.pug
│   ├── admin
│   │   ├── index.pug
│   │   └── users
│   │   ├── index.pug
│   │   └── retrieve.pug
│   ├── dashboard
│   │   └── index.pug
│   ├── forgot-password.pug
│   ├── home.pug
│   ├── layout.pug
│   ├── my-account.pug
│   ├── my-account
│   │   ├── index.pug
│   │   └── security.pug
│   ├── privacy.pug
│   ├── register-or-login.pug
│   ├── reset-password.pug
│   ├── signup-or-login.pug
│   ├── spinner
│   │   ├── 1.pug
│   │   ├── 10.pug
Expand All @@ -552,58 +576,47 @@ template
│   │   ├── 8.pug
│   │   ├── 9.pug
│   │   └── spinner.pug
│   ├── support.pug
│   └── terms.pug
├── assets
│   ├── browserconfig.xml
│   ├── css
│   │   ├── _custom.scss
│   │   ├── _email.scss
│   │   ├── _hljs-github.scss
│   │   ├── _hljs.scss
│   │   ├── _sticky-footer.scss
│   │   ├── _variables.scss
│   │   └── app.scss
│   ├── fonts
│   │   └── GoudyBookletter1911.otf
│   ├── img
│   │   ├── android-chrome-192x192.png
│   │   ├── android-chrome-384x384.png
│   │   ├── apple-touch-icon.png
│   │   ├── favicon-16x16.png
│   │   ├── favicon-32x32.png
│   │   ├── favicon.ico
│   │   ├── logo-square.svg
│   │   ├── mstile-150x150.png
│   │   └── social.png
│   │   ├── social.png
│   │   └── twitter.png
│   ├── js
│   │   ├── admin
│   │   │   └── dashboard.js
│   │   ├── ajax-form.js
│   │   ├── change-hash-on-scroll.js
│   │   ├── clipboard.js
│   │   ├── core.js
│   │   ├── custom-file-input.js
│   │   ├── facebook-hash-fix.js
│   │   ├── flash.js
│   │   ├── jump-to.js
│   │   ├── return-to.js
│   │   ├── spinner.js
│   │   └── swal.js
│   └── manifest.json
│   │   ├── logger.js
│   │   └── uncaught.js
│   ├── manifest.json
│   └── robots.txt
├── bull.js
├── config
│   ├── env.js
│   ├── environments
│   │   ├── development.js
│   │   ├── index.js
│   │   ├── production.js
│   │   ├── staging.js
│   │   └── test.js
│   ├── index.js
│   ├── meta.js
│   ├── phrases.js
│   ├── polyfills.js
│   └── utilities.js
├── ecosystem.json
├── emails
│   ├── _content.pug
│   ├── _footer.pug
│   ├── _header.pug
│   ├── _nav.pug
│   ├── inquiry
│   │   ├── html.pug
Expand All @@ -622,18 +635,21 @@ template
│   ├── i18n.js
│   ├── index.js
│   ├── logger.js
│   ├── passport.js
│   └── policies.js
├── jobs
│   ├── email.js
│   └── index.js
├── index.js
├── locales
│   ├── README.md
│   ├── en.json
│   ├── es.json
│   └── zh.json
├── nodemon.json
├── package-scripts.js
├── package.json
├── proxy.js
├── queues
│   ├── email.js
│   ├── index.js
│   └── mandarin.js
├── routes
│   ├── api
│   │   ├── index.js
Expand All @@ -643,9 +659,13 @@ template
│   └── web
│   ├── admin.js
│   ├── auth.js
│   └── index.js
│   ├── index.js
│   └── my-account.js
├── template
├── web.js
└── yarn.lock
31 directories, 119 files
```
Expand Down Expand Up @@ -745,7 +765,7 @@ If you are seeking permission to use these trademarks, then please [contact us](

[git]: https://git-scm.com/

[slack]: http://slack.crocodilejs.com/
[slack]: https://slack.crocodilejs.com/

[brew]: https://brew.sh/

Expand Down Expand Up @@ -805,7 +825,7 @@ If you are seeking permission to use these trademarks, then please [contact us](

[mongoose]: http://mongoosejs.com

[agenda]: http://agendajs.com
[bull]: https://github.com/OptimalBits/bull

[ladjs-auth]: https://github.com/ladjs/auth

Expand Down Expand Up @@ -866,3 +886,15 @@ If you are seeking permission to use these trademarks, then please [contact us](
[base64]: https://github.com/jelmerdemaat/postcss-base64

[cssnext]: http://cssnext.io/

[debug]: https://github.com/visionmedia/debug

[ladjs-redis]: https://github.com/ladjs/redis

[show-friendly-error-stack]: https://github.com/luin/ioredis#error-handling

[ioredis]: https://github.com/luin/ioredis

[redis-cluster]: https://redis.io/topics/cluster-tutorial

[redis-sentinel]: https://redis.io/topics/sentinel
26 changes: 13 additions & 13 deletions sao.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,30 +78,30 @@ module.exports = {
: 'Please include a valid GitHub.com URL without a trailing slash'
},
web: {
message: 'Do you need a web server',
message: 'Do you need a web server (@ladjs/web)',
type: 'confirm',
default: true
},
i18n: {
message: 'Do you need automatic multi-lingual support',
type: 'confirm',
default: true,
when: answers => answers.web
},
api: {
message: 'Do you need an API server',
message: 'Do you need an API server (@ladjs/api)',
type: 'confirm',
default: true
},
agenda: {
message: 'Do you need a job scheduler',
bull: {
message: 'Do you need a job scheduler (@ladjs/bull)',
type: 'confirm',
default: true
},
proxy: {
message: 'Do you need a proxy (http => https redirect)',
type: 'confirm',
default: true
},
i18n: {
message: 'Do you need automatic multi-lingual support',
type: 'confirm',
default: true,
when: answers => answers.web || answers.api
}
},
filters: {
Expand All @@ -120,9 +120,9 @@ module.exports = {

'web.js': 'web === true',
'api.js': 'api === true',
'agenda.js': 'agenda === true',
'bull.js': 'bull === true',
'proxy.js': 'proxy === true',
'jobs/**': 'agenda === true'
'jobs/**': 'bull === true'
},
move: {
// We keep `.gitignore` as `gitignore` in the project
Expand All @@ -135,7 +135,7 @@ module.exports = {
post: async ctx => {
ctx.gitInit();

// TODO: ctx.answers.agenda
// TODO: ctx.answers.bull
// - remove from pkg
// - remove config
// - remove tests
Expand Down
Loading

0 comments on commit a9ffa94

Please sign in to comment.