This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Universal support #23
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a9bfee2
chore(providers): move shared providers to separate file
jeffbcross 3ea3d19
feat(universal): add support for server-side rendering
jeffbcross 378fa32
chore(Backend): add try/catch to work around server-side Firebase ins…
jeffbcross 9b52ebb
chore: add configuration to debug universal server in vscode
jeffbcross 4c32508
fix(toast): add message property to toast class
jeffbcross 6bad4cb
chore: add TS typings to project manually
jeffbcross File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Launch", | ||
"type": "node", | ||
"request": "launch", | ||
"program": "dist/app/main-server.js", | ||
"stopOnEntry": false, | ||
"args": [], | ||
"cwd": ".", | ||
"runtimeExecutable": null, | ||
"runtimeArgs": [ | ||
"--nolazy" | ||
], | ||
"env": { | ||
"NODE_ENV": "development" | ||
}, | ||
"externalConsole": false, | ||
"sourceMaps": false, | ||
"outDir": null | ||
}, | ||
{ | ||
"name": "Attach", | ||
"type": "node", | ||
"request": "attach", | ||
"port": 5858 | ||
} | ||
] | ||
} |
This file contains 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
This file contains 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
This file contains 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
File renamed without changes.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/// <reference path="../typings/tsd.d.ts" /> | ||
|
||
import * as path from 'path'; | ||
import * as express from 'express'; | ||
import {SERVER_LOCATION_PROVIDERS, ng2engine} from 'angular2-universal-preview/dist/server'; | ||
|
||
import {provide} from 'angular2/core'; | ||
import {APP_BASE_HREF, ROUTER_PROVIDERS} from 'angular2/router'; | ||
|
||
import {SHARED_PROVIDERS} from './shared-providers'; | ||
|
||
// Angular 2 | ||
import {App} from './app/app'; | ||
|
||
let app = express(); | ||
let root = path.join(path.resolve(__dirname, '..')); | ||
|
||
// Express View | ||
app.engine('.ng2.html', ng2engine); | ||
app.set('views', root); | ||
app.set('view engine', 'ng2.html'); | ||
|
||
// Serve static files | ||
app.use(express.static(root)); | ||
|
||
// Routes | ||
app.use('/', (req, res) => { | ||
res.render('index', { App, providers: [ | ||
ROUTER_PROVIDERS, | ||
SERVER_LOCATION_PROVIDERS, | ||
provide(APP_BASE_HREF, {useValue: `http://localhost:3000${req.baseUrl}`}), | ||
SHARED_PROVIDERS | ||
] }); | ||
}); | ||
|
||
// Server | ||
app.listen(3000, () => { | ||
console.log('Listen on http://localhost:3000'); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,14 @@ | ||
import {bootstrap} from 'angular2/platform/browser'; | ||
import {platform, provide} from 'angular2/core'; | ||
import {ROUTER_PROVIDERS} from 'angular2/router'; | ||
import {ROUTER_PROVIDERS, LocationStrategy, PathLocationStrategy} from 'angular2/router'; | ||
|
||
import {AuthService} from './services/Auth'; | ||
import {Backend, BackendConfig} from './services/Backend'; | ||
import {Nav} from './services/Nav'; | ||
|
||
const FIREBASE_URL = 'https://ng2-forum-demo.firebaseio.com'; | ||
import {SHARED_PROVIDERS} from './shared-providers'; | ||
|
||
import {App} from './app/app'; | ||
|
||
bootstrap(App,[ | ||
bootstrap(App, [ | ||
ROUTER_PROVIDERS, | ||
AuthService, | ||
Backend, | ||
provide(BackendConfig, {useValue: {url: FIREBASE_URL }}) | ||
SHARED_PROVIDERS, | ||
provide(LocationStrategy, {useClass: PathLocationStrategy}) | ||
]); | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {provide} from 'angular2/core'; | ||
|
||
import {AuthService} from './services/Auth'; | ||
import {Backend, BackendConfig} from './services/Backend'; | ||
|
||
export const FIREBASE_URL = 'https://ng2-forum-demo.firebaseio.com'; | ||
|
||
export const SHARED_PROVIDERS = [ | ||
AuthService, | ||
Backend, | ||
provide(BackendConfig, {useValue: {url: FIREBASE_URL }}) | ||
]; |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"version": "v4", | ||
"repo": "borisyankov/DefinitelyTyped", | ||
"ref": "master", | ||
"path": "typings", | ||
"bundle": "typings/tsd.d.ts", | ||
"installed": { | ||
"firebase/firebase.d.ts": { | ||
"commit": "2cad4a3cff770c37b40496188c246b1a60e87e2d" | ||
}, | ||
"mime/mime.d.ts": { | ||
"commit": "2cad4a3cff770c37b40496188c246b1a60e87e2d" | ||
}, | ||
"serve-static/serve-static.d.ts": { | ||
"commit": "2cad4a3cff770c37b40496188c246b1a60e87e2d" | ||
}, | ||
"express/express.d.ts": { | ||
"commit": "2cad4a3cff770c37b40496188c246b1a60e87e2d" | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Eventually typings should not be included in version control. | ||
|
||
Right now they must be, because the installed typings have to | ||
be manually updated to prevent duplication with node.d.ts typings | ||
included with angular2. | ||
|
||
Local edits: remove reference to node.d.ts from express.d.ts. | ||
|
||
(@jeffbcross 2016-01-21) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the repo should use
typings
.tsd
will be deprecated soon. (you also want to.gitignore
typings/
folder. see upgrade commit angular/universal-starter@cfb7b52)