# ASP.NET Core / Vue.js SPA Template App
This app is a template application using ASP.NET Core for a REST/JSON API server and Vue.js for a web client.
## Overview of Stack
- Server
- ASP.NET Core
- PostgresSQL
- Entity Framework Core w/ EF Migrations
- JSON Web Token (JWT) authorization with OpenIddict
- Docker used for development PostgresSQL database and MailCatcher server
- Client
- Vue.js
- Webpack for asset bundling and HMR (Hot Module Replacement)
- CSS Modules
- Fetch API for REST requests
- Testing
- xUnit for .NET Core
- MailCatcher for development email delivery
- DevOps
- Ansible playbook for provisioning (Nginx reverse proxy, SSL via Let's Encrypt, PostgresSQL backups to S3)
- Ansible playbook for deployment
## Setup
1. Install the following:
- [.NET Core 1.1](https://www.microsoft.com/net/core)
- [Node.js >= v7.8.0](https://nodejs.org/en/download/)
- [Ansible >= 2.0](http://docs.ansible.com/ansible/intro_installation.html)
- [Docker](https://docs.docker.com/engine/installation/)
2. Run `npm install && npm start`
3. Open browser and navigate to [http://localhost:5000](http://localhost:5000).
## Scripts
### `npm install`
When first cloning the repo or adding new dependencies, run this command. This will:
- Install Node dependencies from package.json
- Install .NET Core dependencies from api/api.csproj and api.test/api.test.csproj (using dotnet restore)
### `npm start`
To start the app for development, run this command. This will:
- Run `docker-compose up` to ensure the PostgreSQL and MailCatcher Docker images are up and running
- Run dotnet watch run which will build the app (if changed), watch for changes and start the web server on http://localhost:5000
- Run Webpack dev middleware with HMR via [ASP.NET JavaScriptServices](https://github.com/aspnet/JavaScriptServices)
### `npm run migrate`
After making changes to Entity Framework models in `api/Models/`, run this command to generate and run a migration on the database. A timestamp will be used for the migration name.
### `npm test`
This will run the xUnit tests in api.test/ and the Vue.js tests in client-web.test/.
### `npm run provision:prod`
_Before running this script, you need to create an ops/hosts file first. See the [ops README](ops/) for instructions._
This will run the ops/provision.yml Ansible playbook and provision hosts in ops/hosts inventory file. This prepares the hosts to recieve deployments by doing the following:
- Install Nginx
- Generate a SSL certificate from [Let's Encrypt](https://letsencrypt.org/) and configure Nginx to use it
- Install .Net Core
- Install Supervisor (will run/manage the ASP.NET app)
- Install PostgreSQL
- Setup a cron job to automatically backup the PostgresSQL database, compress it, and upload it to S3.
- Setup UFW (firewall) to lock everything down except inbound SSH and web traffic
- Create a deploy user, directory for deployments and configure Nginx to serve from this directory
### `npm run deploy:prod`
_Before running this script, you need to create a ops/hosts file first. See the [ops README](ops/) for instructions._
This script will:
- Build release Webpack bundles
- Package the .NET Core application in Release mode (dotnet publish)
- Run the ops/deploy.yml Ansible playbook to deploy this app to hosts in /ops/hosts inventory file. This does the following:
- Copies the build assets to the remote host(s)
- Updates the `appsettings.json` file with PostgresSQL credentials specified in ops/hosts file and the app URL (needed for JWT tokens)
- Restarts the app so that changes will be picked up
## Development Email Delivery
This template includes a [MailCatcher](https://mailcatcher.me/) Docker image so that when email is sent during development (i.e. new user registration), it can be viewed
in the MailCacher web interface at [http://localhost:1080/](http://localhost:1080/).
## Visual Studio Code config
This project has [Visual Studio Code](https://code.visualstudio.com/) tasks and debugger launch config located in .vscode/.
### Tasks
- **Command+Shift+B** - Runs the "build" task which builds the api/ project
- **Command+Shift+T** - Runs the "test" task which runs the xUnit tests in api.test/ and Mocha/Enzyme tests in client-web.test/.
### Debug Launcher
With the following debugger launch configs, you can set breakpoints in api/ or the the Mocha tests in client-web.test/ and have full debugging support.
- **Debug api/ (server)** - Runs the vscode debugger (breakpoints) on the api/ .NET Core app
- **Debug client-web.test/ (Mocha tests)** - Runs the vscode debugger on the client-web.test/ Mocha tests
## Credit
The following resources were helpful in setting up this template:
- [Sample for implementing Authentication with a React Flux app and JWTs](https://github.com/auth0-blog/react-flux-jwt-authentication-sample)
- [Angular 2, React, and Knockout apps on ASP.NET Core](http://blog.stevensanderson.com/2016/05/02/angular2-react-knockout-apps-on-aspnet-core/)
- [Setting up ASP.NET v5 (vNext) to use JWT tokens (using OpenIddict)](http://capesean.co.za/blog/asp-net-5-jwt-tokens/)
- [Cross-platform Single Page Applications with ASP.NET Core 1.0, Angular 2 & TypeScript](https://chsakell.com/2016/01/01/cross-platform-single-page-applications-with-asp-net-5-angular-2-typescript/)
- [Stack Overflow - Token Based Authentication in ASP.NET Core](http://stackoverflow.com/questions/30546542/token-based-authentication-in-asp-net-core-refreshed)
- [SPA example of a token based authentication implementation using the Aurelia front end framework and ASP.NET core]( https://github.com/alexandre-spieser/AureliaAspNetCoreAuth)
- [A Real-World React.js Setup for ASP.NET Core and MVC5](https://www.simple-talk.com/dotnet/asp-net/a-real-world-react-js-setup-for-asp-net-core-and-mvc)
- My own perseverance because this took a _lot_ of time to get right ����
没有合适的资源?快使用搜索试试~ 我知道了~
aspnet-core-vuejs-template:ASP.NET Core Vue.js SPA模板应用程序
共111个文件
yml:30个
cs:23个
ts:14个
需积分: 26 8 下载量 88 浏览量
2021-02-01
18:40:01
上传
评论
收藏 131KB ZIP 举报
温馨提示
ASP.NET Core / Vue.js SPA模板应用程序 此应用程序是一个模板应用程序,它使用ASP.NET Core(用于REST / JSON API服务器)和Vue.js(用于Web客户端)。 堆栈概述 服务器 ASP.NET核心 PostgreSQL 带EF迁移的实体框架核心 带有OpenIddict的JSON Web令牌(JWT)授权 Docker用于开发PostgresSQL数据库和MailCatcher服务器 客户 Vue.js Webpack用于资产捆绑和HMR(热模块更换) CSS模块 提取REST请求的API 测验 .NET Core的xUnit MailCatcher用于开发电子邮件传递 开发运维 用于配置的Ansible手册(Nginx反向代理,通过Let's Encrypt的SSL,到S3的PostgresSQL备份) Ansible部署手册 建立 安装以下内容: 运行npm install && npm start 打开浏览器并导航到 。 剧本 npm install 第一次克隆存储库或添加新的依赖项时,请运行此命令。 这将: 从pac
资源详情
资源评论
资源推荐
收起资源包目录
aspnet-core-vuejs-template:ASP.NET Core Vue.js SPA模板应用程序 (111个子文件)
all 415B
NuGet.Config 276B
NuGet.Config 276B
20170420031935_Initial.cs 14KB
20170421213657_1492810608.Designer.cs 11KB
DefaultDbContextModelSnapshot.cs 11KB
20170420031935_Initial.Designer.cs 11KB
AuthController.cs 8KB
Startup.cs 8KB
ContactController.cs 2KB
DefaultDbContextInitializer.cs 2KB
EmailSender.cs 2KB
SpaFallbackMiddleware.cs 2KB
EmailSenderOptions.cs 1KB
20170421213657_1492810608.cs 930B
Program.cs 764B
DefaultDbContext.cs 610B
Contact.cs 576B
Tests.cs 506B
Tests.cs 504B
SpaFallbackOptions.cs 317B
NewUser.cs 303B
ControllerTests.cs 279B
IEmailSender.cs 232B
ApplicationUser.cs 208B
ConfirmEmail.cs 177B
api.csproj 3KB
api.test.csproj 936B
global.css 146B
.editorconfig 180B
hosts.example 2KB
.gitignore 328B
scratch.html 3KB
index.template.html 570B
favicon.ico 198B
config.j2 3KB
etc_nginx_sites-available.conf.j2 1KB
pgsql_backup.sh.j2 857B
etc_supervisor_conf.d_app_name.conf.j2 351B
s3cfg.j2 81B
webpack.config.js 2KB
webpack.config.release.js 1KB
package.json 2KB
launch.json 1KB
tasks.json 612B
appsettings.json 598B
tsconfig.json 376B
tsconfig.json 271B
settings.json 176B
global.json 62B
LICENSE 1KB
LICENSE 1KB
yarn.lock 112KB
development-20170420.log 123KB
README.md 6KB
README.md 1KB
README.md 1KB
auth.styl 716B
contacts.styl 38B
RestUtilities.ts 3KB
array-find.ts 2KB
Auth.ts 1KB
boot.ts 1KB
Contacts.ts 1KB
object-assign.ts 913B
Auth.ts 369B
tests.ts 353B
string-startsWith.ts 319B
styles.d.ts 152B
string-startsWith.d.ts 87B
sfc.d.ts 83B
object-assign.d.ts 82B
array-find.d.ts 71B
ContactForm.vue 3KB
Contacts.vue 3KB
SignIn.vue 2KB
Default.vue 2KB
Register.vue 2KB
App.vue 691B
RegisterComplete.vue 657B
Auth.vue 246B
main.yml 3KB
install.yml 2KB
configure.yml 1KB
main.yml 1KB
main.yml 894B
main.yml 781B
provision.yml 775B
backup.yml 774B
main.yml 571B
main.yml 559B
main.yml 487B
main.yml 467B
docker-compose.yml 327B
main.yml 205B
main.yml 201B
main.yml 194B
main.yml 194B
deploy.yml 182B
main.yml 137B
共 111 条
- 1
- 2
余木脑袋
- 粉丝: 24
- 资源: 4596
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0