This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var HID = require('node-hid'); | |
var bitwise = require('bitwise'); | |
var socket = require('socket.io-client')('https://frill-crafter.hyperdev.space'); | |
device.on("data", function(data) { | |
// Interpret data buffer and figure out which buttons on which controllers are being pressed | |
// ... Visit https://github.com/hakant/NfieldQuizGame to see the actual code | |
// Then emit the following message to the socket.io server running on hyperdev (for each controller) | |
socket.emit('button-clicked', `{ "ControllerId": ${controllerId}, "ButtonId": ${buttonId} }`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** AdminRepository.ts **/ | |
"use strict"; | |
import * as _ from 'underscore'; | |
import * as nconf from 'nconf'; | |
const businessRules = nconf.get("BusinessRules"); | |
let admins = businessRules.Administrators; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface IAdminRepository { | |
IsUserAdmin(username : string) : boolean; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
import * as _ from 'underscore'; | |
import * as nconf from 'nconf'; | |
const businessRules = nconf.get("BusinessRules"); | |
let admins = businessRules.Administrators; | |
export default class AdminRepository implements IAdminRepository { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict;" | |
import * as express from 'express'; | |
export interface RouteConfigurator { | |
configure(path:string, app: express.Application); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
import * as express from 'express'; | |
const router = express.Router(); | |
import { RouteConfigurator } from './RouteConfigurator' | |
class IndexRouteConfigurator implements RouteConfigurator { | |
public configure(path: string, app: express.Application) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { CommandHandler } from "../infrastructure/command-handler" | |
import container from "../infrastructure/command-handler-container"; | |
class TestHandler implements CommandHandler<TestRequest, TestResponse> { | |
Handle(request: TestRequest): TestResponse { | |
var result = new TestResponse(); | |
result.message = `Hello ${request.name}!`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
import { AsyncCommandHandler } from "../application/command-handler" | |
import container from "../application/command-handler-container"; | |
import * as nconf from 'nconf'; | |
import * as AWS from 'aws-sdk'; | |
import * as Bluebird from 'bluebird'; | |
import * as _ from 'underscore'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
router.get('/', catchAsyncErrors(async function (req, res, next) { | |
var request = new GetIdeasRequest(); | |
request.user = req.user; | |
var response = await application.ExecuteAsync<GetIdeasRequest, GetIdeasResponse>(request); | |
res.json(response.ideas); | |
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import executor from "../infrastructure/command-executor"; | |
import {TestRequest, TestResponse} from "../handlers/test-handler"; | |
let request = new TestRequest(); | |
request.name = "Hakan"; | |
let response = executor.Execute<TestRequest, TestResponse>(request); | |
console.log(response.message); // Prints 'Hello Hakan' |