Skip to content

Instantly share code, notes, and snippets.

View consoledotblog's full-sized avatar

consoledotblog

View GitHub Profile
@consoledotblog
consoledotblog / bawts-08.js
Created January 14, 2016 17:15 — forked from Nijhazer/bawts-08.js
Building Applications with TypeScript - Snippet 08
export class Task {
public name: string;
public active: boolean;
public render() : string {
if (this.active) {
return '[Inactive] ' + this.name;
}
return this.name;
}
@consoledotblog
consoledotblog / bawts-09.sh
Created January 14, 2016 17:15 — forked from Nijhazer/bawts-09.sh
Building Applications with TypeScript - Snippet 09
tsc --module commonjs task.ts
@consoledotblog
consoledotblog / bawts-10.sh
Created January 14, 2016 17:15 — forked from Nijhazer/bawts-10.sh
Building Applications with TypeScript - Snippet 08
tsc --module amd task.ts
@consoledotblog
consoledotblog / bawts-11.js
Created January 14, 2016 17:15 — forked from Nijhazer/bawts-11.js
Building Applications with TypeScript - Snippet 11
export interface IDataDriver {
getConnection() : Promise;
getRepository(repositoryName : string) : Promise;
getIdType(value : any) : any;
}
@consoledotblog
consoledotblog / bawts-12.js
Created January 14, 2016 17:15 — forked from Nijhazer/bawts-12.js
Building Applications with TypeScript - Snippet 12
export class MongoDataDriver implements IDataDriver {
getConnection() : Promise {
return new Promise((resolve, reject) => {
Mongo.MongoClient.connect(this.config.connectionURL, (err, connection) => {
if (err) {
reject(err);
}
resolve(connection);
});
});
@consoledotblog
consoledotblog / bawts-13.js
Created January 14, 2016 17:15 — forked from Nijhazer/bawts-13.js
Building Applications with TypeScript - Snippet 13
var router = Express.Router();
var taskManager = new DataManager(
new MongoDataDriver(EnvDataConfig.getInstance()),
Task
);
var taskController = new ExpressController();
taskController.manager = taskManager;
@consoledotblog
consoledotblog / bawts-14.sh
Created January 14, 2016 17:15 — forked from Nijhazer/bawts-14.sh
Building Applications with TypeScript - Snippet 14
tsc --target es6 task.ts
@consoledotblog
consoledotblog / bawts-15.sh
Created January 14, 2016 17:16 — forked from Nijhazer/bawts-15.sh
Building Applications with TypeScript - Snippet 15
tsc --module amd task.ts
@consoledotblog
consoledotblog / bawts-16.js
Created January 14, 2016 17:16 — forked from Nijhazer/bawts-16.js
Building Applications with TypeScript - Snippet 16
var mocha = require('gulp-mocha');
gulp.task('test:api', ['compile:api'], function() {
return gulp.src('api/unit/test/location/**/*.js', {
read: false
}).pipe(mocha({
reporter: 'spec'
}));
});
@consoledotblog
consoledotblog / bawts-17.js
Created January 14, 2016 17:16 — forked from Nijhazer/bawts-17.js
Building Applications with TypeScript - Snippet 17
module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['mocha', 'requirejs', 'chai-sinon'],
// Here, we specify which files Karma should load into the test harness.
files: [
// First, load an additional test runner that the karma-requirejs plugin will need.
'src/test/karma-test-runner.js',