Skip to content
This repository has been archived by the owner on Jul 12, 2020. It is now read-only.

Commit

Permalink
hapi 17 && async/await (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
jedireza authored Feb 3, 2018
1 parent 2156418 commit 5f2291b
Show file tree
Hide file tree
Showing 76 changed files with 6,760 additions and 10,855 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/*
test/artifacts/*
.env
.eslintrc.js
12 changes: 1 addition & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
sudo: true
language: node_js
node_js:
- "8"
- "9"
services:
- mongodb
env:
- NODE_ENV=test CXX=g++-4.8
before_install:
- sudo apt-get install unicode-data
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.8
68 changes: 44 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ this repo and build one on top of Frame.
| url | username | password |
|:-------------------------------------------------------------------------- |:-------- |:-------- |
| [https://getframe.herokuapp.com/](https://getframe.herokuapp.com/) | root | root |
| [https://getframe.herokuapp.com/docs](https://getframe.herokuapp.com/docs) | ---- | ---- |

[Postman](http://www.getpostman.com/) is a great tool for testing and
developing APIs. See the wiki for details on [how to
Expand All @@ -44,19 +43,14 @@ login](https://github.com/jedireza/frame/wiki/How-to-login).

## Requirements

You need [Node.js](http://nodejs.org/download/) installed and you'll need
[MongoDB](http://www.mongodb.org/downloads) installed and running.

We use [`bcrypt`](https://github.com/ncb000gt/node.bcrypt.js) for hashing
secrets. If you have issues during installation related to `bcrypt` then [refer
to this wiki
page](https://github.com/jedireza/frame/wiki/bcrypt-Installation-Trouble).
You need [Node.js](http://nodejs.org/download/) `>=8.x` and you'll need a
[MongoDB](http://www.mongodb.org/downloads) `>=2.6` server running.


## Installation

```bash
$ git clone git@github.com:jedireza/frame.git
$ git clone https://github.com/jedireza/frame.git
$ cd frame
$ npm install
```
Expand Down Expand Up @@ -101,7 +95,7 @@ $ npm run first-time-setup
```bash
$ npm start

# > [email protected] start /Users/jedireza/projects/frame
# > [email protected] start /home/jedireza/projects/frame
# > ./node_modules/nodemon/bin/nodemon.js -e js,md server

# 09 Sep 03:47:15 - [nodemon] v1.10.2
Expand All @@ -114,11 +108,28 @@ see the welcome message.
[`nodemon`](https://github.com/remy/nodemon) watches for changes in server
code and restarts the app automatically.

We also pass the `--inspect` flag to Node so you have a debugger available.
Watch the output of `$ npm start` and look for the debugging URL and open it in
Chrome. It looks something like this:
### With the debugger

`chrome-devtools://devtools/remote/serve_file/@62cd277117e6f8ec53e31b1be58290a6f7ab42ef/inspector.html?experiments=true&v8only=true&ws=localhost:9229/node`
```bash
$ npm run inspect

# > [email protected] inspect /home/jedireza/projects/frame
# > nodemon --inspect -e js,md server.js

# [nodemon] 1.14.12
# [nodemon] to restart at any time, enter `rs`
# [nodemon] watching: *.*
# [nodemon] starting `node --inspect server.js`
# Debugger listening on ws://127.0.0.1:9229/3d706d9a-b3e0-4fc6-b64e-e7968b7f94d0
# For help see https://nodejs.org/en/docs/inspector
# 180203/193534.071, [log,info,mongodb] data: HapiMongoModels: successfully connected to the db.
# 180203/193534.127, [log,info,mongodb] data: HapiMongoModels: finished processing auto indexes.
# Server started on port 9000
```

Once started with the debuger you can open Google Chrome and go to
[chrome://inspect](chrome://inspect). See https://nodejs.org/en/docs/inspector/
for more details.


## Running in production
Expand Down Expand Up @@ -157,23 +168,32 @@ use to write all of our tests.
```bash
$ npm test

# > [email protected] test /Users/jedireza/projects/frame
# > ./node_modules/lab/bin/lab -c
# > [email protected] test /home/jedireza/projects/frame
# > lab -c -L

# ..................................................
# ..................................................
# ..................................................
# ..................................................
# ..................................................
# ........
# ..................................................
# ..................................................
# ..................................................
# ..............

# 258 tests complete
# Test duration: 2398 ms
# 164 tests complete
# Test duration: 14028 ms
# No global variable leaks detected
# Coverage: 100.00%
# Linting results: No issues
```

### Targeted tests

If you'd like to run a specific test or subset of tests you can use the
`test-server` npm script.

You specificy the path(s) via the `TEST_TARGET` environment variable like:

```bash
$ TEST_TARGET=test/server/web/main.js npm run test-server
```

## License

MIT
Expand Down
17 changes: 12 additions & 5 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,18 @@ const config = {
},
hapiMongoModels: {
mongodb: {
uri: {
$filter: 'env',
production: process.env.MONGODB_URI,
test: 'mongodb://localhost:27017/frame-test',
$default: 'mongodb://localhost:27017/frame'
connection: {
uri: {
$filter: 'env',
production: process.env.MONGODB_URI,
$default: 'mongodb://localhost:27017/'
},
db: {
$filter: 'env',
production: process.env.MONGODB_DB_NAME,
test: 'frame-test',
$default: 'frame'
}
}
},
autoIndex: true
Expand Down
Loading

0 comments on commit 5f2291b

Please sign in to comment.