Skip to content

Commit c9a7188

Browse files
committedSep 13, 2019
feat: lot of work (api/web/bull/graceful/proxy/emails)
1 parent 73d1d2b commit c9a7188

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1059
-956
lines changed
 

‎README.md

+91-59
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<a href="https://ladjs.github.io/lad/"><img src="media/lad.png" alt="lad" /></a>
33
</h1>
44
<div align="center">
5-
<a href="http://slack.crocodilejs.com"><img src="http://slack.crocodilejs.com/badge.svg" alt="chat" /></a>
5+
<a href="https://slack.crocodilejs.com"><img src="https://slack.crocodilejs.com/badge.svg" alt="chat" /></a>
66
<a href="https://travis-ci.org/ladjs/lad"><img src="https://travis-ci.org/ladjs/lad.svg?branch=master" alt="build status" /></a>
77
<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>
88
<a href="https://github.com/sindresorhus/xo"><img src="https://img.shields.io/badge/code_style-XO-5ed9c7.svg" alt="code style" /></a>
@@ -63,7 +63,7 @@ These microservices are preconfigured for security, performance, and graceful re
6363

6464
* Webapp server → [web.js](template/web.js)
6565
* API server → [api.js](template/api.js)
66-
* Job scheduler → [agenda.js](template/agenda.js)
66+
* Job scheduler → [bull.js](template/bull.js)
6767
* Proxy server → [proxy.js](template/proxy.js)
6868

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

8686
### Back-end
8787

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

245245
##### Debugging
246246

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

249-
[npm][]:
249+
```sh
250+
DEBUG=* ...
251+
```
250252

251-
```sh
252-
DEBUG=* npm start
253-
```
253+
* `NODE_DEBUG` - debug [node][] internal modules:
254254

255-
[yarn][]:
255+
```sh
256+
NODE_DEBUG=* ...
257+
```
256258

257-
```sh
258-
DEBUG=* yarn start all
259-
```
259+
* `MONGOOSE_DEBUG` - debug Mongoose raw database operation output:
260260

261-
You can also use `NODE_DEBUG` if desired to debug [node][] internal modules.
261+
```sh
262+
MONGOOSE_DEBUG=true ...
263+
```
262264

263-
```sh
264-
NODE_DEBUG=* ...
265-
```
265+
* `TRANSPORT_DEBUG` - debug Nodemailer transport:
266266

267-
And also `MONGOOSE_DEBUG` if you'd like Mongoose raw database operation output.
267+
```sh
268+
TRANSPORT_DEBUG=true ...
269+
```
268270

269-
```sh
270-
MONGOOSE_DEBUG=true ...
271-
```
271+
* `REDIS_MONITOR` - debug Redis using `MONITOR` (uses [@ladjs/redis][ladjs-redis] and passes `true` for the `monitor` argument):
272+
273+
```sh
274+
REDIS_MONITOR=true ...
275+
```
276+
277+
* `REDIS_FRIENDLY_ERROR_STACK` - debug Redis with friendly error stack messages (see [showFriendlyErrorStack][show-friendly-error-stack] option of [ioredis][])
278+
279+
```sh
280+
REDIS_FRIENDLY_ERROR_STACK=true ...
281+
```
272282

273283
#### Production
274284

@@ -506,39 +516,53 @@ tree template -I "build|node_modules|coverage|test"
506516
template
507517
├── LICENSE
508518
├── README
509-
├── agenda.js
510519
├── api.js
511520
├── app
512521
│   ├── controllers
513522
│   │   ├── api
514523
│   │   │   ├── index.js
515524
│   │   │   └── v1
516525
│   │   │   ├── index.js
526+
│   │   │   ├── log.js
517527
│   │   │   └── users.js
518528
│   │   ├── index.js
519529
│   │   └── web
530+
│   │   ├── admin
531+
│   │   │   ├── index.js
532+
│   │   │   └── users.js
520533
│   │   ├── auth.js
521-
│   │   ├── contact.js
522-
│   │   └── index.js
534+
│   │   ├── index.js
535+
│   │   ├── my-account.js
536+
│   │   └── support.js
523537
│   ├── models
524538
│   │   ├── index.js
525539
│   │   ├── inquiry.js
526540
│   │   └── user.js
527541
│   └── views
528542
│   ├── 404.pug
529543
│   ├── 500.pug
544+
│   ├── _breadcrumbs.pug
530545
│   ├── _footer.pug
531546
│   ├── _nav.pug
532547
│   ├── _pagination.pug
548+
│   ├── _register-or-login.pug
533549
│   ├── about.pug
534-
│   ├── admin.pug
535-
│   ├── contact.pug
550+
│   ├── admin
551+
│   │   ├── index.pug
552+
│   │   └── users
553+
│   │   ├── index.pug
554+
│   │   └── retrieve.pug
555+
│   ├── dashboard
556+
│   │   └── index.pug
536557
│   ├── forgot-password.pug
537558
│   ├── home.pug
538559
│   ├── layout.pug
539-
│   ├── my-account.pug
560+
│   ├── my-account
561+
│   │   ├── index.pug
562+
│   │   └── security.pug
563+
│   ├── privacy.pug
564+
│   ├── register-or-login.pug
540565
│   ├── reset-password.pug
541-
│   ├── signup-or-login.pug
542566
│   ├── spinner
543567
│   │   ├── 1.pug
544568
│   │   ├── 10.pug
@@ -552,58 +576,47 @@ template
552576
│   │   ├── 8.pug
553577
│   │   ├── 9.pug
554578
│   │   └── spinner.pug
579+
│   ├── support.pug
555580
│   └── terms.pug
556581
├── assets
557582
│   ├── browserconfig.xml
558583
│   ├── css
559584
│   │   ├── _custom.scss
560585
│   │   ├── _email.scss
561-
│   │   ├── _hljs-github.scss
586+
│   │   ├── _hljs.scss
587+
│   │   ├── _sticky-footer.scss
562588
│   │   ├── _variables.scss
563589
│   │   └── app.scss
564590
│   ├── fonts
565-
│   │   └── GoudyBookletter1911.otf
566591
│   ├── img
567592
│   │   ├── android-chrome-192x192.png
568593
│   │   ├── android-chrome-384x384.png
569594
│   │   ├── apple-touch-icon.png
570595
│   │   ├── favicon-16x16.png
571596
│   │   ├── favicon-32x32.png
572597
│   │   ├── favicon.ico
598+
│   │   ├── logo-square.svg
573599
│   │   ├── mstile-150x150.png
574-
│   │   └── social.png
600+
│   │   ├── social.png
601+
│   │   └── twitter.png
575602
│   ├── js
576-
│   │   ├── admin
577-
│   │   │   └── dashboard.js
578-
│   │   ├── ajax-form.js
579-
│   │   ├── change-hash-on-scroll.js
580-
│   │   ├── clipboard.js
581603
│   │   ├── core.js
582-
│   │   ├── custom-file-input.js
583-
│   │   ├── facebook-hash-fix.js
584-
│   │   ├── flash.js
585-
│   │   ├── jump-to.js
586-
│   │   ├── return-to.js
587-
│   │   ├── spinner.js
588-
│   │   └── swal.js
589-
│   └── manifest.json
604+
│   │   ├── logger.js
605+
│   │   └── uncaught.js
606+
│   ├── manifest.json
607+
│   └── robots.txt
608+
├── bull.js
590609
├── config
591610
│   ├── env.js
592-
│   ├── environments
593-
│   │   ├── development.js
594-
│   │   ├── index.js
595-
│   │   ├── production.js
596-
│   │   ├── staging.js
597-
│   │   └── test.js
598611
│   ├── index.js
599612
│   ├── meta.js
600613
│   ├── phrases.js
614+
│   ├── polyfills.js
601615
│   └── utilities.js
602616
├── ecosystem.json
603617
├── emails
604618
│   ├── _content.pug
605619
│   ├── _footer.pug
606-
│   ├── _header.pug
607620
│   ├── _nav.pug
608621
│   ├── inquiry
609622
│   │   ├── html.pug
@@ -622,18 +635,21 @@ template
622635
│   ├── i18n.js
623636
│   ├── index.js
624637
│   ├── logger.js
638+
│   ├── passport.js
625639
│   └── policies.js
626-
├── jobs
627-
│   ├── email.js
628-
│   └── index.js
640+
├── index.js
629641
├── locales
630-
│   ├── README.md
631642
│   ├── en.json
632643
│   ├── es.json
633644
│   └── zh.json
634645
├── nodemon.json
646+
├── package-scripts.js
635647
├── package.json
636648
├── proxy.js
649+
├── queues
650+
│   ├── email.js
651+
│   ├── index.js
652+
│   └── mandarin.js
637653
├── routes
638654
│   ├── api
639655
│   │   ├── index.js
@@ -643,9 +659,13 @@ template
643659
│   └── web
644660
│   ├── admin.js
645661
│   ├── auth.js
646-
│   └── index.js
662+
│   ├── index.js
663+
│   └── my-account.js
664+
├── template
647665
├── web.js
648666
└── yarn.lock
667+
668+
31 directories, 119 files
649669
```
650670
651671
@@ -745,7 +765,7 @@ If you are seeking permission to use these trademarks, then please [contact us](
745765

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

748-
[slack]: http://slack.crocodilejs.com/
768+
[slack]: https://slack.crocodilejs.com/
749769

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

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

806826
[mongoose]: http://mongoosejs.com
807827

808-
[agenda]: http://agendajs.com
828+
[bull]: https://github.com/OptimalBits/bull
809829

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

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

868888
[cssnext]: http://cssnext.io/
889+
890+
[debug]: https://github.com/visionmedia/debug
891+
892+
[ladjs-redis]: https://github.com/ladjs/redis
893+
894+
[show-friendly-error-stack]: https://github.com/luin/ioredis#error-handling
895+
896+
[ioredis]: https://github.com/luin/ioredis
897+
898+
[redis-cluster]: https://redis.io/topics/cluster-tutorial
899+
900+
[redis-sentinel]: https://redis.io/topics/sentinel

‎sao.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -78,30 +78,30 @@ module.exports = {
7878
: 'Please include a valid GitHub.com URL without a trailing slash'
7979
},
8080
web: {
81-
message: 'Do you need a web server',
81+
message: 'Do you need a web server (@ladjs/web)',
8282
type: 'confirm',
8383
default: true
8484
},
85-
i18n: {
86-
message: 'Do you need automatic multi-lingual support',
87-
type: 'confirm',
88-
default: true,
89-
when: answers => answers.web
90-
},
9185
api: {
92-
message: 'Do you need an API server',
86+
message: 'Do you need an API server (@ladjs/api)',
9387
type: 'confirm',
9488
default: true
9589
},
96-
agenda: {
97-
message: 'Do you need a job scheduler',
90+
bull: {
91+
message: 'Do you need a job scheduler (@ladjs/bull)',
9892
type: 'confirm',
9993
default: true
10094
},
10195
proxy: {
10296
message: 'Do you need a proxy (http => https redirect)',
10397
type: 'confirm',
10498
default: true
99+
},
100+
i18n: {
101+
message: 'Do you need automatic multi-lingual support',
102+
type: 'confirm',
103+
default: true,
104+
when: answers => answers.web || answers.api
105105
}
106106
},
107107
filters: {
@@ -120,9 +120,9 @@ module.exports = {
120120

121121
'web.js': 'web === true',
122122
'api.js': 'api === true',
123-
'agenda.js': 'agenda === true',
123+
'bull.js': 'bull === true',
124124
'proxy.js': 'proxy === true',
125-
'jobs/**': 'agenda === true'
125+
'jobs/**': 'bull === true'
126126
},
127127
move: {
128128
// We keep `.gitignore` as `gitignore` in the project
@@ -135,7 +135,7 @@ module.exports = {
135135
post: async ctx => {
136136
ctx.gitInit();
137137

138-
// TODO: ctx.answers.agenda
138+
// TODO: ctx.answers.bull
139139
// - remove from pkg
140140
// - remove config
141141
// - remove tests

0 commit comments

Comments
 (0)
Failed to load comments.