Skip to content

Instantly share code, notes, and snippets.

View seanpmaxwell's full-sized avatar
🎯
Focusing

Sean Maxwell seanpmaxwell

🎯
Focusing
View GitHub Profile
@seanpmaxwell
seanpmaxwell / package.json
Last active May 29, 2019 05:16
TypeScriptFullStackShell/package.json
{
"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\"/",
@seanpmaxwell
seanpmaxwell / start.ts
Last active May 18, 2019 14:43
TypeScriptFullStackShell/start.js
import DemoServer from './DemoServer';
// Start the server or run tests
if (process.argv[2] !== 'test') {
let server = new DemoServer();
server.start();
} else {
@seanpmaxwell
seanpmaxwell / DemoServer.ts
Last active May 29, 2019 05:15
TypeScriptFullStackShell/src/DemoServer.ts
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();
}
@seanpmaxwell
seanpmaxwell / tslint.json
Last active May 29, 2019 05:08
TypeScriptFullStackShell/tslint.json
{
"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,
@seanpmaxwell
seanpmaxwell / tsconfig.json
Last active May 29, 2019 05:04
TypeScriptFullStackShell's tsconfig.json
{
"compileOnSave": true,
"compilerOptions": {
"module": "commonjs",
"strict": true,
"baseUrl": "./",
"outDir": "build",
"sourceMap": true,
"removeComments": true,
"experimentalDecorators": true,
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')
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 {
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() {
/*************************************************
* 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)
/************************************
* Determine Medicine Dosage
************************************/
calcDailyPills(mgDaily: number): number
{
let weightKilos = this._weight * 0.45
let mgPerPill = 10
return (weightKilos * mgDaily) / mgPerPill
}