Last active
May 29, 2019 05:25
-
-
Save seanpmaxwell/21fb6bde8097749f9fc2fb4568caf19c to your computer and use it in GitHub Desktop.
Revisions
-
seanpmaxwell revised this gist
May 29, 2019 . 1 changed file with 0 additions and 11 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -35,17 +35,6 @@ class DemoServer extends Server { super.addControllers(ctlrInstances); } public start(port: number): void { this.app.listen(port, () => { Logger.Imp(this.SERVER_START_MSG + port); -
seanpmaxwell revised this gist
May 29, 2019 . 1 changed file with 32 additions and 16 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,25 +1,20 @@ 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: '; private readonly DEV_MSG = 'Express Server is running in development mode. ' + 'No front-end content is being served.'; constructor() { super(true); this.app.use(bodyParser.json()); this.app.use(bodyParser.urlencoded({extended: true})); super.addControllers(new DemoController()); // Point to front-end code if (process.env.NODE_ENV !== 'production') { @@ -29,12 +24,33 @@ class DemoServer extends Server { } } private setupControllers(): void { const ctlrInstances = []; for (const name in controllers) { if (controllers.hasOwnProperty(name)) { let Controller = (controllers as any)[name]; ctlrInstances.push(new Controller()); } } super.addControllers(ctlrInstances); } private serveFrontEndProd(): void { const dir = path.join(__dirname, 'public/react/demo-react/'); // Set the static and views directory this.app.set('views', dir); this.app.use(express.static(dir)); // Serve front-end content this.app.get('*', (req, res) => { res.sendFile('index.html', {root: dir}); }); } public start(port: number): void { this.app.listen(port, () => { Logger.Imp(this.SERVER_START_MSG + port); }); } } export default DemoServer; -
seanpmaxwell revised this gist
May 18, 2019 . 1 changed file with 0 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -16,14 +16,11 @@ class DemoServer extends Server { constructor() { super(); // Setup json middleware this.app.use(bodyParser.json()); this.app.use(bodyParser.urlencoded({extended: true})); // Setup the controllers super.addControllers(new DemoController()); // Point to front-end code if (process.env.NODE_ENV !== 'production') { cinfo('Starting server in development mode'); -
seanpmaxwell revised this gist
May 16, 2019 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -8,8 +8,7 @@ import DemoController from './controllers/demo/DemoController'; class DemoServer extends Server { private readonly _SERVER_START_MSG = 'Demo server started on port: '; private readonly _DEV_MSG = 'Express Server is running in development mode. Back-end is ' + 'currently running on port: '; private _port = 3001; -
seanpmaxwell revised this gist
Feb 15, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -26,7 +26,7 @@ class DemoServer extends Server { super.addControllers(new DemoController()); // Point to front-end code if (process.env.NODE_ENV !== 'production') { cinfo('Starting server in development mode'); const msg = this._DEV_MSG + process.env.EXPRESS_PORT; this.app.get('*', (req, res) => res.send(msg)); -
seanpmaxwell revised this gist
Feb 14, 2019 . 1 changed file with 1 addition and 8 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -41,11 +41,4 @@ class DemoServer extends Server { } } export default DemoController; -
seanpmaxwell revised this gist
Jan 29, 2019 . 1 changed file with 3 additions and 10 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -27,20 +27,13 @@ class DemoServer extends Server { // Point to front-end code if (process.env.NODE_ENV === 'development') { cinfo('Starting server in development mode'); const msg = this._DEV_MSG + process.env.EXPRESS_PORT; this.app.get('*', (req, res) => res.send(msg)); } } public start(): void { this.app.listen(this._port, () => { cimp(this._SERVER_START_MSG + this._port); -
seanpmaxwell revised this gist
Jan 27, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -23,7 +23,7 @@ class DemoServer extends Server { this.app.use(bodyParser.urlencoded({extended: true})); // Setup the controllers super.addControllers(new DemoController()); // Point to front-end code if (process.env.NODE_ENV === 'development') { -
seanpmaxwell revised this gist
Jan 26, 2019 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -19,8 +19,8 @@ class DemoServer extends Server { super(); // Setup json middleware this.app.use(bodyParser.json()); this.app.use(bodyParser.urlencoded({extended: true})); // Setup the controllers super.addControllers_(new DemoController()); @@ -37,12 +37,12 @@ class DemoServer extends Server { cinfo('Starting server in development mode'); const msg = this._DEV_MSG + process.env.EXPRESS_PORT; this.app.get('*', (req, res) => res.send(msg)); } public start(): void { this.app.listen(this._port, () => { cimp(this._SERVER_START_MSG + this._port); }); } -
seanpmaxwell revised this gist
Jan 24, 2019 . 1 changed file with 1 addition and 12 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -23,7 +23,7 @@ class DemoServer extends Server { this.app_.use(bodyParser.urlencoded({extended: true})); // Setup the controllers super.addControllers_(new DemoController()); // Point to front-end code if (process.env.NODE_ENV === 'development') { @@ -32,17 +32,6 @@ class DemoServer extends Server { } private _serveFrontEndDev(): void { cinfo('Starting server in development mode'); -
seanpmaxwell created this gist
Jan 24, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,69 @@ import * as express from 'express'; import * as bodyParser from 'body-parser'; import { Server } from '@overnightjs/core'; import { cimp, cinfo } from 'simple-color-print'; import DemoController from './controllers/demo/DemoController'; class DemoServer extends Server { private readonly _SERVER_START_MSG = 'Demo server started on port: '; private readonly _DEV_MSG = 'Express Server is running in development mode. Start the React ' + 'development server "npm run start:react" to develop front-end content. Back-end is ' + 'currently running on port: '; private _port = 3001; constructor() { super(); // Setup json middleware this.app_.use(bodyParser.json()); this.app_.use(bodyParser.urlencoded({extended: true})); // Setup the controllers this._setupControllers(); // Point to front-end code if (process.env.NODE_ENV === 'development') { this._serveFrontEndDev(); } } private _setupControllers(): void { const demoController = new DemoController(); const controllers = []; controllers.push(demoController); super.addControllers_(controllers); } private _serveFrontEndDev(): void { cinfo('Starting server in development mode'); const msg = this._DEV_MSG + process.env.EXPRESS_PORT; this.app_.get('*', (req, res) => res.send(msg)); } public start(): void { this.app_.listen(this._port, () => { cimp(this._SERVER_START_MSG + this._port); }); } } /** * Start the server */ (() => { const server = new DemoServer(); server.start(); })();