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

Feature/descriptions #10

Open
wants to merge 72 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
6fa4e7e
connects to PSQL and products replaced with Users
Zxela Aug 27, 2018
227979c
changed homepage title
Zxela Aug 27, 2018
fd42d42
added Blockchain table
Zxela Aug 27, 2018
21330ef
Created table models
njlatcham Aug 27, 2018
18887a4
added transaction to index.js
Zxela Aug 27, 2018
c33e603
Fixing tables
njlatcham Aug 27, 2018
cd51405
Merge branch 'db/setup' of github.com:Zxela/Wallet-Cryptorial into db…
njlatcham Aug 27, 2018
61b0082
added target key
njlatcham Aug 27, 2018
8936301
fixing database
njlatcham Aug 27, 2018
b8a6ac0
eh
njlatcham Aug 27, 2018
796bacc
added pacakge
Zxela Aug 27, 2018
2c910fc
Merge branch 'db/setup' of github.com:Zxela/Wallet-Cryptorial into db…
Zxela Aug 27, 2018
805ca02
added relation to model index
Zxela Aug 27, 2018
a314081
added comment /releationship
Zxela Aug 27, 2018
bc1c483
can view JSON at endpoint
Zxela Aug 27, 2018
b4caf06
changed how data from users is displayed
Zxela Aug 27, 2018
251e295
adding front-end client server
njlatcham Aug 28, 2018
561efa1
swapped client for clean install
Zxela Aug 28, 2018
780d064
added git ignore
Zxela Aug 28, 2018
e7a19e1
removing node_moduels
Zxela Aug 28, 2018
c53aee4
added gitignore
Zxela Aug 28, 2018
55cb09f
added container component
Zxela Aug 28, 2018
5613556
npm installed
njlatcham Aug 28, 2018
5d9c5e9
remove node_modules
Zxela Aug 28, 2018
1cc86c6
remove node_moduels
Zxela Aug 28, 2018
37871a3
Merge branch 'feature/home-page'
Zxela Aug 28, 2018
dec9ef4
removed node_modules
Zxela Aug 28, 2018
d72fdd7
Create README.md
Zxela Aug 28, 2018
8ca5840
fixed container
Zxela Aug 28, 2018
3de9fce
added basic html for sign-up page
Zxela Aug 28, 2018
dad4384
Created homepage component
njlatcham Aug 28, 2018
d56a732
Merge pull request #1 from Zxela/feature/home-container
Zxela Aug 28, 2018
2b80e03
Merge branch 'master' into feature/register-user-forms
Zxela Aug 28, 2018
10ed830
Merge pull request #2 from Zxela/feature/register-user-forms
Zxela Aug 28, 2018
28d4cbd
small changes
njlatcham Aug 28, 2018
5db027c
added css
njlatcham Aug 28, 2018
1880ede
mneumonic phrase component created
Zxela Aug 28, 2018
2e3c087
added public key page
Zxela Aug 28, 2018
abd0b00
added CoinInfo component
Zxela Aug 28, 2018
a04466b
added components for tutorial
njlatcham Aug 28, 2018
c1dd801
samplesell added
Zxela Aug 28, 2018
a815d4f
Merge pull request #3 from Zxela/page/public-key
Zxela Aug 28, 2018
cdb3fb4
Merge pull request #4 from Zxela/page/coininfo
Zxela Aug 28, 2018
e26bae8
Merge pull request #5 from Zxela/page/sample-sell
Zxela Aug 28, 2018
177d960
Set theme jekyll-theme-slate
Zxela Aug 28, 2018
b777063
added browser router
Zxela Aug 28, 2018
7adf865
git pushMerge branch 'master' of github.com:Zxela/Wallet-Cryptorial
Zxela Aug 28, 2018
7da9bed
Merge branch 'master' into feature/mneumonic
njlatcham Aug 28, 2018
4856484
Merge pull request #6 from Zxela/feature/mneumonic
njlatcham Aug 28, 2018
eee3402
Merge branch 'master' of github.com:Zxela/Wallet-Cryptorial
Zxela Aug 28, 2018
31b4dfb
Finished adding tutorial components
njlatcham Aug 28, 2018
4d1f3ea
Merge pull request #7 from Zxela/feature/finishingComp
njlatcham Aug 28, 2018
40974d6
added routing
Zxela Aug 28, 2018
246da69
Merge branch 'master' of github.com:Zxela/Wallet-Cryptorial
Zxela Aug 28, 2018
570bd58
Merge pull request #8 from Zxela/feature/react-router
Zxela Aug 28, 2018
dcb2142
Merge branch 'master' of github.com:Zxela/Wallet-Cryptorial
Zxela Aug 28, 2018
fee1ca0
titlecased files
Zxela Aug 28, 2018
7ca2132
Finishing routes
Zxela Aug 28, 2018
ae2257a
fixed exports
Zxela Aug 28, 2018
ce73a6c
adding first link
njlatcham Aug 28, 2018
660ebd9
adding first links
njlatcham Aug 28, 2018
c1c0725
finihed routes and some styling
njlatcham Aug 28, 2018
ebf1079
added message
Zxela Aug 28, 2018
53230d0
added more views
Zxela Aug 29, 2018
7682672
Merge branch 'master' into feature/links
Zxela Aug 29, 2018
0f1e765
Merge pull request #9 from Zxela/feature/links
Zxela Aug 29, 2018
eccd3f3
added descriptions
njlatcham Aug 29, 2018
da69756
Merge branch 'feature/links' of github.com:Zxela/Wallet-Cryptorial in…
njlatcham Aug 29, 2018
f5ed052
Merge pull request #10 from Zxela/feature/links
njlatcham Aug 29, 2018
39c0acf
started adding descriptions
njlatcham Aug 29, 2018
cacebb8
Added more descriptions and a few minor changes
njlatcham Aug 29, 2018
6fa0ee2
idk
njlatcham Aug 30, 2018
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
Binary file added .DS_Store
Binary file not shown.
45 changes: 16 additions & 29 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,34 +1,21 @@
# Logs
logs
*.log
# See https://help.github.com/ignore-files/ for more about ignoring files.

# Runtime data
pids
*.pid
*.seed
# dependencies
node_modules/

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# testing
*/coverage

# Coverage directory used by tools like istanbul
coverage
# production
*/build

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# misc
*/.DS_Store
*/.env.local
*/.env.development.local
*/.env.test.local
*/.env.production.local

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# https://docs.npmjs.com/cli/shrinkwrap#caveats
node_modules

# Debug log from npm
npm-debug.log

# Sensitive info
.env
certs/*.pem
*/npm-debug.log*
*/yarn-debug.log*
*/yarn-error.log*
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"git.ignoreLimitWarning": true
}
115 changes: 3 additions & 112 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,114 +1,5 @@
# Baaaes 💓
# Wallet-Cryptorial
Wallet-Cryptorial

**Baaaes** is an opinionated, fully fleshed-out API server boilerplate based on [ExpressJS](http://expressjs.com) and [Sequelize](http://sequelizejs.com) with working examples and tests - you just have to jump in and modify it to your needs. It makes extensive use of `async`/`await` to eliminate callback hell _completely_ and make Javascript your bae.

## TL;DR HOWTO

1. Download the [zip package](https://github.com/fzero/baaaes/archive/master.zip) and unzip it somewhere (cloning is **not** recommended for normal use)
2. Run `npm install`
3. Copy `.env.example` to `.env` and add your Postgres DB configuration
4. If you need HTTPS support, run `npm run makecert`

You should be ready to go now! Start the server with `npm start` and run tests with `npm test`.


## How & why?

The basic code was created with [`express-generator`](https://expressjs.com/en/starter/generator.html), then the following changes were made:

* Complete conversion to native Node ES6 syntax.
* HTTPS support included, and you can generate self-signed certificates for development by running `npm run makecert`. Note that you **will** see warning messages; use [Let's encrypt](https://letsencrypt.org/) and a real domain name to avoid this.
* [CORS](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing) support baked in with configuration examples.
* Differentiated environments (`development`, `test` and `production`) defined by the `APP_ENV` environment variable.
* [Handlebars](http://handlebarsjs.com/) templates for HTML views.
* [Sequelize](http://sequelizejs.com) as ORM, along with an example model implementation making extensive use of the `async`/`await` pattern to minimize frustration.
* Example API routes _with fully working RESTful CRUD endpoints_, also using `async`/`await`!
* [Mocha](http://mochajs.org/) integration tests for the example API. And guess what? We're using `async`/`await` for that too!


## Making Express great again with `async`/`await`

Let's face it, working with databases in Node has always been frustrating (to say the least). Node 7 introduces native support for `async`/`await`, which is nothing more than syntatic sugar on top of the Promise pattern. This means that **if your code uses promises, you can use `async`/`await` right now!**

So instead of writing an API route like this...

```js
// GET /products
// Returns a JSON array containing all available product objects
router.get('/', (req, res) => {
models.Product.findAll()
.then((result) => {
res.json(result)
})
.catch((error) => {
res.status(400).json(error)
})
})
```

...you can write this instead!

```js
router.get('/', async (req, res) => {
try {
res.json(await models.Product.findAll())
}
catch(error) {
res.status(400).json(error)
}
})
```

Note how you can use `try`/`catch` for async error handling - and YES, IT WORKS! 💓


## External dependencies

**Baaaes** expects a Postgres database up and running, but you can modify the code to use any other database supported by Sequelize. You'll have to install the corresponding `npm` packages and modify the `.env` file. [Relevant documentation here.](http://docs.sequelizejs.com/en/v3/docs/getting-started/)

Out of the box, **Baaaes** uses URI-style configuration for database connections, but you can use as many environment variables as you want (e.g. `DB_USER`, `DB_PASS`, `DB_HOST` and so on). **Just make sure to keep you test database separated; all data is destroyed every time the test suite runs!**


## Note about boilerplates in general

The objective of Baaaes is **not** to prescribe how you should organize your project, but showing **one** particular way to do it (hence _opinionated_).

If you already know what you're doing, you can configure Express, Sequelize, Knex, Mongo and whatever else you're using however you want. Still, it can be useful to take a peek at some of this code to inform your decisions.

This is one of the reasons I've decided against making Baaaes into a code generation package (such as `express-generator`). The other reason is it would be too much like creating yet another Javascript framework, and **NOBODY** wants that.

**NOBODY.**


## To do

* Authentication middleware example
* [JWT](https://jwt.io/) example
* Bake in Let's Encrypt
* Example NGINX configuration
* Clustering
* HTTP/2
* Koa version


## MIT License

Copyright (c) 2017 Fabio Neves

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
How-to make a Cryptocurrency Wallet!
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
theme: jekyll-theme-slate
133 changes: 0 additions & 133 deletions api/products.js

This file was deleted.

Loading