Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikk36 committed Mar 31, 2015
0 parents commit 6b4f02b
Show file tree
Hide file tree
Showing 73 changed files with 2,500 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true

# 2 space indentation
[**.*]
indent_style = space
indent_size = 2
17 changes: 17 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Auto detect text files and perform LF normalization
* text=auto

# Custom for Visual Studio
*.cs diff=csharp

# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
78 changes: 78 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# Commenting this out is preferred by some people, see
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
node_modules

# Users Environment Variables
.lock-wscript

# =========================
# Operating System Files
# =========================

# OSX
# =========================

.DS_Store
.AppleDouble
.LSOverride

# Thumbnails
._*

# Files that might appear on external disk
.Spotlight-V100
.Trashes

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

# Windows
# =========================

# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp

# Windows shortcuts
*.lnk

public/app
.idea
92 changes: 92 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Aurelia-Node

This is a NodeJS Express App bundled with the [Skeleton App](https://github.com/aurelia/skeleton-navigation) of the [Aurelia](http://www.aurelia.io/) platform. It sets up a standard navigation-style app using gulp to build your ES6 code with the babel compiler. Karma/Jasmine testing is also configured.

For more info please visit the official site: http://www.aurelia.io/


## Running The App

1. Fork or download this repo
2. Navigate into the folder
3. Install the Apps dependencies

```shell
npm install
```
4. Download a fresh copy of the skeleton app by issuing following command:

```shell
node bin/install
```
5. Navigate to the frontend folder

```shell
cd public/app
```
6. Ensure that [Gulp](http://gulpjs.com/) is installed. If you need to install it, use the following command:

```shell
npm install -g gulp
```
7. Ensure that [jspm](http://jspm.io/) is installed. If you need to install it, use the following command:

```shell
npm install -g jspm
```
> **Note:** jspm queries GitHub to install semver packages, but GitHub has a rate limit on anonymous API requests. It is advised that you configure jspm with your GitHub credentials in order to avoid problems. You can do this by executing `jspm endpoint config github` and following the prompts.
8. Install the client-side dependencies with jspm:

```shell
jspm install
```
>**Note:** Windows users, if you experience an error of "unknown command unzip" you can solve this problem by doing `npm install -g unzip` and then re-running `jspm install`.
9. To run the app go back to the project root and execute the following command:

```shell
gulp watch
```
10. Browse to [http://localhost:7000](http://localhost:7000) to see the app. You can make changes in the code found under `src` and the browser should auto-refresh itself as you save files.

>**Note:** If you prefer to run the node app without Gulp just do ``` node app.js ```

## Serving views from Node

You can easily serve your Views from the Node Backend. This example uses the [Swig](http://paularmstrong.github.io/swig/) Templating Engine, but you are of course free to choose whatever you want :)
If you take a look at the folder `views/welcome.html` you'll see the welcome View being served by NodeJS. The route association can be found in `routes/api.js`. The code below demonstrates how to reply with the html file.

```
/* GET welcome view */
router.get('/views/welcome', function(req, res) {
res.render('welcome', {nodePort: require('../app').get('port')});
});
```

In order to use this in Aurelia open the file `public/app/src/welcome.js` and add following method to the Welcome Class. This will make sure that the VM requests the server-side View during the navigation instruciton.

```
getViewStrategy() {
return '../../views/welcome';
}
```


## E2E Testing
An example of how to use Protractor for E2E Testing with Aurelia has been added.
In order to run them you need to make sure protractor and the necessary webdriver is installed

```shell
npm install -g protractor
webdriver-manager update
```

Now start up the application in one Terminal with from the project root with the command:
```shell
node app.js
```

After that, in another Terminal, from the project root, just type following:
```shell
protractor protractor.conf.js
```
53 changes: 53 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
var util = require("util");
var express = require("express");
var path = require("path");
var cookieParser = require("cookie-parser");
var bodyParser = require("body-parser");

/*var routes = require("./routes/index");
var users = require("./routes/users");*/

var app = express();
var http = require("http").Server(app);
var io = require("socket.io")(http);

var allowCrossDomain = function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Methods", "GET,PUT,POST,DELETE");
res.header("Access-Control-Allow-Headers", "Content-Type");

next();
};

// view engine setup
app.set("view engine", "jade");
//app.set("views", path.join(__dirname, "views"));

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(allowCrossDomain);
app.use(cookieParser());
app.use(express.static(path.join(__dirname, "public/app")));

//var api = require("./routes/api");
//app.use("/", api);

var debug = require("debug")("aurelia-node");

app.set("port", process.env.PORT || 9000);

var server = http.listen(app.get("port"), function() {
debug("Express server listening on port " + server.address().port);
});

io.on("connection", function(socket) {
util.log("a user connected");
socket.on("disconnect", function() {
util.log("a user disconnected");
});
socket.on("welcome", function() {
util.log("Welcome!");
});
});

module.exports = app;
Loading

0 comments on commit 6b4f02b

Please sign in to comment.