Skip to content

Commit 33c66e2

Browse files
author
I
committed
feat(example): update example
1 parent 5b226c8 commit 33c66e2

File tree

6 files changed

+15
-30
lines changed

6 files changed

+15
-30
lines changed

.gitignore

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,15 @@
22
logs
33
*.log
44
lib
5-
dist
65

76
# Runtime data
87
pids
98
*.pid
109
*.seed
1110

12-
# Directory for instrumented libs generated by jscoverage/JSCover
13-
lib-cov
14-
1511
# Coverage directory used by tools like istanbul
1612
coverage
1713

18-
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
19-
.grunt
20-
21-
# node-waf configuration
22-
.lock-wscript
23-
24-
# Compiled binary addons (http://nodejs.org/api/addons.html)
25-
build/Release
26-
2714
# Dependency directory
2815
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
2916
node_modules

.npmignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
coverage
22
.travis.yml
33
example
4-
.idea
5-
src
64
*.spec.js

example/app.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {getSchema} from '../src';
66

77
import User from './user';
88

9+
mongoose.Promise = global.Promise;
910
mongoose.connect(process.env.MONGO_URI || 'mongodb://localhost/graphql');
1011
const port = process.env.PORT || 8080;
1112

@@ -35,10 +36,14 @@ app.use(graffiti.koa({
3536
}));
3637

3738
// redirect all requests to /graphql
38-
app.use(function *redirect() {
39+
app.use(function *redirect(next) {
3940
this.redirect('/graphql');
41+
yield next;
4042
});
4143

42-
app.listen(port);
43-
44-
console.log(`Started on http://localhost:${port}/`);
44+
app.listen(port, (err) => {
45+
if (err) {
46+
throw err;
47+
}
48+
console.log(`Started on http://localhost:${port}/`);
49+
});

example/index.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

example/package.json

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22
"name": "graffiti-mongoose-example",
33
"description": "An example using graffiti-mongoose",
44
"scripts": {
5-
"start": "node index.js"
5+
"start": "babel-node app.js"
66
},
77
"dependencies": {
88
"@risingstack/graffiti": "^3.0.3",
99
"@risingstack/graffiti-mongoose": "../",
10-
"babel-runtime": "^6.5.0",
11-
"koa": "^1.1.2",
12-
"koa-bodyparser": "^2.0.1"
13-
},
14-
"devDependencies": {
15-
"babel": "^6.5.1"
10+
"babel-cli": "6.11.4",
11+
"babel-runtime": "6.9.2",
12+
"koa": "1.2.1",
13+
"koa-bodyparser": "2.2.0"
1614
}
1715
}

example/user.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ User.remove().then(() => {
2929
users.push(new User({
3030
name: `User${i}`,
3131
age: i,
32-
createdAt: new Date() + i * 100,
32+
createdAt: new Date() + (i * 100),
3333
friends: users.map((i) => i._id),
3434
nums: [0, i],
3535
bools: [true, false],

0 commit comments

Comments
 (0)