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:38
TypeScriptFullStackShell/package.json
{
"name": "typescriptfullstackshell",
"version": "1.0.0",
"description": "demonstrate how to do full-stack TypeScript development",
"main": "build/demo.bundle.js",
"scripts": {
"start": "npm install --only=prod && NODE_ENV=production node ./build/start.js",
"start-dev": "nodemon --config \"./util/nodemon.json\"",
"test": "ts-node src/start.ts test",
"build": "sh ./util/buildForProd.sh"
@seanpmaxwell
seanpmaxwell / start.js
Last active May 18, 2019 14:41
TypeScriptFullStackShell/start.ts
if (process.argv[2] === 'dev') {
process.env.NODE_ENV = 'development';
require('./src/DemoServer');
} else if (process.argv[2] === 'prod') {
process.env.NODE_ENV = 'production';
require('./build/demo.bundle');
} else if (process.argv[2] === 'test') {
...
@seanpmaxwell
seanpmaxwell / DemoServer.ts
Last active May 29, 2019 05:35
TypeScriptFullStackShell/src/DemoServer.ts
constructor() {
super(true);
this.app.use(bodyParser.json());
this.app.use(bodyParser.urlencoded({extended: true}));
this.setupControllers();
// Point to front-end code
if (process.env.NODE_ENV !== 'production') {
this.app.get('*', (req, res) => res.send(this.DEV_MSG));
} else {
this.serveFrontEndProd();
@seanpmaxwell
seanpmaxwell / buildForProd.sh
Last active February 21, 2019 06:08
TypeScriptFullStackShell/util/buildForProd.sh
#!/usr/bin/env bash
### Build BackEnd ###
# Remove existing production folder
rm -rf ./build/
# Transpile .ts to .js
@seanpmaxwell
seanpmaxwell / DemoController.test.ts
Last active May 29, 2019 05:30
TypeScriptFullStackShell/src/controllers/demo/DemoController.test.ts
import * as supertest from 'supertest';
import {} from 'jasmine';
import { OK, BAD_REQUEST } from 'http-status-codes';
import { SuperTest, Test } from 'supertest';
import { Logger } from '@overnightjs/logger';
import TestServer from '../shared/TestServer.test';
import DemoController from './DemoController';
describe('DemoController', () => {
@seanpmaxwell
seanpmaxwell / TestServer.test.ts
Last active May 29, 2019 05:28
TypeScriptFullStackShell/src/controllers/shared/TestServer.test.ts
import * as bodyParser from 'body-parser';
import { Application } from 'express';
import { Server } from '@overnightjs/core';
class TestServer extends Server {
constructor() {
super();
this.app.use(bodyParser.json());
this.app.use(bodyParser.urlencoded({extended: true}));
@seanpmaxwell
seanpmaxwell / package.json
Created January 24, 2019 22:33
TypeScriptFullStackShell/src/public/react/demo-react/package.json
{
"name": "demo-react",
"version": "0.1.0",
"private": true,
"dependencies": {
"@types/jest": "23.3.13",
"@types/node": "10.12.18",
"@types/react": "16.7.20",
"@types/react-dom": "16.0.11",
"react": "^16.7.0",
@seanpmaxwell
seanpmaxwell / App.tsx
Last active May 29, 2019 05:27
TypeScriptFullStackShell/src/public/react/demo-react/src/App.tsx
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
class App extends Component {
render() {
async function callExpress() {
try {
@seanpmaxwell
seanpmaxwell / DemoServer.ts
Last active May 29, 2019 05:25
TypeScriptFullStackShell/src/DemoServer.ts
import * as path from 'path';
import * as express from 'express';
import * as bodyParser from 'body-parser';
import * as controllers from './controllers';
import { Server } from '@overnightjs/core';
import { Logger } from '@overnightjs/logger';
class DemoServer extends Server {
private readonly SERVER_START_MSG = 'Demo server started on port: ';
@seanpmaxwell
seanpmaxwell / DemoController.ts
Last active May 29, 2019 05:19
TypeScriptFullStackShell/src/controllers/demo/DemoController.ts
import { OK, BAD_REQUEST } from 'http-status-codes';
import { Controller, Get } from '@overnightjs/core';
import { Logger } from '@overnightjs/logger';
import { Request, Response } from 'express';
@Controller('api/say-hello')
class DemoController {
public static readonly SUCCESS_MSG = 'hello ';