This file contains hidden or 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
{ | |
"name": "typescriptfullstackshell", | |
"version": "1.0.0", | |
"description": "Demonstrate how to do full-stack TypeScript development", | |
"main": "start.js", | |
"scripts": { | |
"start-dev": "nodemon --config \"./util/nodemon.json\"/", |
This file contains hidden or 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 DemoServer from './DemoServer'; | |
// Start the server or run tests | |
if (process.argv[2] !== 'test') { | |
let server = new DemoServer(); | |
server.start(); | |
} else { |
This file contains hidden or 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 { Server } from '@overnightjs/core'; | |
import { Logger } from '@overnightjs/logger'; | |
class DemoServer extends Server { | |
private readonly SERVER_START_MSG = 'Demo server started on port: '; | |
constructor() { | |
super(); | |
} |
This file contains hidden or 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
Show hidden characters
{ | |
"extends": "tslint:recommended", | |
"rules": { | |
"max-line-length": { | |
"options": [100] | |
}, | |
"member-ordering": false, | |
"no-consecutive-blank-lines": false, | |
"object-literal-sort-keys": false, | |
"ordered-imports": false, |
This file contains hidden or 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
{ | |
"compileOnSave": true, | |
"compilerOptions": { | |
"module": "commonjs", | |
"strict": true, | |
"baseUrl": "./", | |
"outDir": "build", | |
"sourceMap": true, | |
"removeComments": true, | |
"experimentalDecorators": true, |
This file contains hidden or 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 { Controller, Middleware, Get } from '@overnightjs/core' | |
import { JwtHandler, SecureRequest } from '@overnightjs/jwt' | |
import { Request, Response } from 'express' | |
import { ParentController } from './ParentController' | |
const jwtHandler = new JwtHandler('yourSecretString', '10h'); | |
const JWTMIDDLEWARE = jwtHandler.getMiddleware(); | |
@Controller('api/jwt') |
This file contains hidden or 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 { Controller, Middleware, Get } from '@overnightjs/core' | |
import { jwt, jwtmiddleware, SecureRequest } from '@overnightjs/jwt' | |
import { Request, Response } from 'express' | |
import { ParentController } from './ParentController' | |
@Controller('api/jwt') | |
export class UserController extends ParentController { | |
This file contains hidden or 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 * as bodyParser from 'body-parser' | |
import { Server } from '@overnightjs/core' | |
import { UserController } from './UserController' | |
import customRouter from 'express-promise-router' | |
export class SampleServer extends Server { | |
constructor() { |
This file contains hidden or 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
/************************************************* | |
* Contact Dog Owner | |
************************************************/ | |
async contactOwner(dogId: number, msg: string): Promise<void> | |
{ | |
try { | |
let ownerEmail = await this._getOwnerEmail(dogId) | |
let info = await this._sendEmail(ownerEmail, msg) | |
console.log(info.message) |
This file contains hidden or 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
/************************************ | |
* Determine Medicine Dosage | |
************************************/ | |
calcDailyPills(mgDaily: number): number | |
{ | |
let weightKilos = this._weight * 0.45 | |
let mgPerPill = 10 | |
return (weightKilos * mgDaily) / mgPerPill | |
} |