Aurelia Web API Example
This is an example of an Aurelia web application backed by an ASP.NET 5 Web API web service.
The client and server build tasks are handled by gulp.
This example assumes you are familiar with node.js, npm, and gulp.
If you're using npm 2.x, I recommend upgrading npm. If you don't want to upgrade your system npm, install a version manager.
npm install nave -g nave use 4.2.2 npm install npm -g npm --version # should be 3.x
If you don't install npm 3, projects with many npm dependencies will result in lots of nested folders and excessive disk IO.
Download and install ASP.NET 5 from https://get.asp.net/.
dnvm install 1.0.0-rc1-final dnvm use 1.0.0-rc1-final
npm install npm install gulp jspm -g jspm install
Setup the database
cd src/AureliaWebApi dnx ef database update -e Production
. ├── build │ └── tasks ├── node_modules ├── src │ ├── Controllers │ ├── Migrations │ ├── Models │ ├── Properties │ ├── client │ │ ├── app │ │ └── specs │ └── wwwroot └── test └── AureliaWebApiTests
Gulp build settings
Gulp build tasks, relies on settings in parent directory
Location of the client and server source code
Folders related to Web API
Base folder for client-related source and tests
The client source: Aurelia written in ES6
Unit and end-to-end tests for Aurelia
Aggregate folder for all server-side tests
This takes the AddUserSecrets extension from Microsoft.Extensions.Configuration and calls it on the builder object. There's a discrepancy between rc1-final packages, so PathHelper.cs and ConfigurationExtensions.cs were taken directly from source.
User secrets can be added with the user-secret helper:
dnu commands install Microsoft.Framework.SecretManager
Then, you can set a secret:
user-secret set ApiSecret:Key keyboardcat
This secret is stored unencrypted in secrets.json in your home directory (see ConfigurationExtensions and PathHelper for location). The benefit here is the secret won't accidentally be committed to source.
Code First Blog/Post models (taken from http://ef.readthedocs.org/en/latest/getting-started/osx.html).
To run migrations:
dnx ef database update
To create additional migrations, run:
dnx ef migrations add MigrationName
Then, run the update command again.
$ gulp help [22:52:08] Using gulpfile /Volumes/Extra/projects/AureliaWebApi/gulpfile.js [22:52:08] Starting 'help'... Main Tasks ------------------------------ build changelog clean default help lint release serve watch Sub Tasks ------------------------------ build-css build-deps build-html build-images build-sass build-source bump-version dotnet-build dotnet-restore dotnet-run dotnet-test prepare-release [22:52:08] Finished 'help' after 1.25 ms
Main build tasks should be pretty self-explanatory.
gulp and everything gets built, tested, and staged for testing in browser sync.
gulp dotnet-run will run as a Production environment. You can run in Development by passing the environment variable:
ASPNET_ENV=Development gulp dotnet-run
The development environment will use an in-memory database while the production environment persists to a local SQLite database file.
jspm_packagesto avoid copying from client/app to wwwroot during build.
- Iterate all tests and execute dnx test.
- Setup karma and end-to-end testing
- Work up a client application in Aurelia
- Upgrade everything to include dotnet50