Skip to content

Instantly share code, notes, and snippets.

View seanpmaxwell's full-sized avatar
🎯
Focusing

Sean Maxwell seanpmaxwell

🎯
Focusing
View GitHub Profile
@Controller('api/users')
export class UserController {
@Get(':id')
@Middleware([middleware1, middleware2])
get(req: Request, res: Response, next: NextFunction): any {
console.log(req.params.id);
return res.status(200).json({msg: 'get_called'});
}
}
export class UserController {
getRoutes(): Router {
let router = express.Router();
router.get('/api/users/:id', [middleware1, middleware2], (req, res, next) => {
this.get(req, res, next);
}
import { Request, Response, NextFunction } from 'express'
import { Controller, Middleware, Get, Post, Put, Delete } from '@overnightjs/core'
@Controller('api/users')
export class UserController {
@Get(':id')
get(req: Request, res: Response): any {
import * as bodyParser from 'body-parser'
import { Server } from '@overnightjs/core'
import { UserController } from './UserController'
import { LoginController } from './LoginController'
export class SampleServer extends Server {
@seanpmaxwell
seanpmaxwell / tsconfig.json
Last active October 31, 2018 03:34
Enforce Type Safety in TypeScript
{
"compileOnSave": false,
"compilerOptions": {
"noImplicitAny": true, <--- Add this option
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "es2015",
"moduleResolution": "node",
// ******* Same Line ******* //
class Dog {
makeSound(breed: string): void {
if(breed === 'chihuahua') {
console.log('growl')
} else if(breed === 'beagle') {
console.log('woof woof')
} else {
class Dog
{
makeSound(breed: string): void
{
if(breed === 'chihuahua') {
console.log('growl')
}
else if(breed === 'beagle') {
console.log('woof woof')
}
var Dog = /** @class */ (function () {
function Dog() {
}
Dog.prototype.makeSound = function (breed) {
if (breed === 'chihuahua') {
console.log('growl');
}
else if (breed === 'beagle') {
console.log('woof woof');
}
class Dog
{
private _weight: number
static readonly SPECIES = 'canis familiaris'
static readonly TAXONOMY: Taxonomy = taxonomiesModule(this.SPECIES)
set weight(weight: number): void
{
this._weight = weight
}
/**
* TypeScript file for the "Dog" class
*
* created by sean maxwell Nov 1, 2018
*/
class Dog extends Animal
{
furColor: string