Skip to content

Instantly share code, notes, and snippets.

View yamikuronue's full-sized avatar

Bay yamikuronue

View GitHub Profile
getAllGames: (res) => {
//For this sprint, all users can see all games
return new Promise((resolve, reject) => {
dao.getAllGames().then((data) => {
for (let i = 0; i < data.length; i++) {
data[i].canonical = `/api/game/${data[i].id}`;
}
res.send(data);
resolve();
dao.getAllGames().then((data) => {
for (let i = 0; i < data.length; i++) {
data[i].canonical = `/api/game/${data[i].id}`;
}
res.send(data);
}).catch((err) => {
//TODO: logging errors
res.status(500).send({ error: 'Database error.' });
});
let data = [{
ID: '1',
Name: 'test game',
Adult: false,
GameMasters: null,
Tags: [],
IC: null
},
{
ID: '2',
//Controller module
var express = require('express');
var router = express.Router();
app.route('/book')
.get(function(req, res) {
res.send('Get a random book');
})
.post(function(req, res) {
res.send('Add a book');
@yamikuronue
yamikuronue / Using Async.JS
Created March 19, 2015 18:57
Comparison of callback hell from freezing-octo-cyril
define([
"intern!object",
"intern/chai!assert",
"intern/dojo/node!../../../src/dao/todoItems",
"intern/dojo/node!fs",
"intern/dojo/node!is-there",
"intern/dojo/node!sinon",
"intern/dojo/node!sqlite3",
"intern/dojo/node!async"
], function (registerSuite, assert, dao, fs, IsThere, sinon, sqlite3, async) {