Skip to content

Commit

Permalink
feat(example): update example
Browse files Browse the repository at this point in the history
  • Loading branch information
I committed Jul 26, 2016
1 parent 5b226c8 commit 33c66e2
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 30 deletions.
13 changes: 0 additions & 13 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,15 @@
logs
*.log
lib
dist

# Runtime data
pids
*.pid
*.seed

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

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

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

# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
2 changes: 0 additions & 2 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
coverage
.travis.yml
example
.idea
src
*.spec.js
13 changes: 9 additions & 4 deletions example/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {getSchema} from '../src';

import User from './user';

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

Expand Down Expand Up @@ -35,10 +36,14 @@ app.use(graffiti.koa({
}));

// redirect all requests to /graphql
app.use(function *redirect() {
app.use(function *redirect(next) {
this.redirect('/graphql');
yield next;
});

app.listen(port);

console.log(`Started on http://localhost:${port}/`);
app.listen(port, (err) => {
if (err) {
throw err;
}
console.log(`Started on http://localhost:${port}/`);
});
3 changes: 0 additions & 3 deletions example/index.js

This file was deleted.

12 changes: 5 additions & 7 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
"name": "graffiti-mongoose-example",
"description": "An example using graffiti-mongoose",
"scripts": {
"start": "node index.js"
"start": "babel-node app.js"
},
"dependencies": {
"@risingstack/graffiti": "^3.0.3",
"@risingstack/graffiti-mongoose": "../",
"babel-runtime": "^6.5.0",
"koa": "^1.1.2",
"koa-bodyparser": "^2.0.1"
},
"devDependencies": {
"babel": "^6.5.1"
"babel-cli": "6.11.4",
"babel-runtime": "6.9.2",
"koa": "1.2.1",
"koa-bodyparser": "2.2.0"
}
}
2 changes: 1 addition & 1 deletion example/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ User.remove().then(() => {
users.push(new User({
name: `User${i}`,
age: i,
createdAt: new Date() + i * 100,
createdAt: new Date() + (i * 100),
friends: users.map((i) => i._id),
nums: [0, i],
bools: [true, false],
Expand Down

0 comments on commit 33c66e2

Please sign in to comment.