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
// server.js | |
// where your node app starts | |
// init project | |
var express = require('express'); | |
var app = express(); | |
var http = require('http').Server(app); | |
var io = require('socket.io')(http); | |
io.on('connection', function(socket){ |
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 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' |
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); | |
})); |