This repo contains an ASP.NET Core + Vuesax + Vue.js 2 starter template (VS2017 or command line)
This is based on this repository
- ASP.NET Core 2.1
- Web API
- VueJS 2
- Vuex (State Store)
- Vuesax (UI Template)
- eslint
- eslint-config-airbnb-base
- testing
- mock file for json-server is available
- Sample of common processing
- In this example, a notification by error handling is prepared
- .Net Core 2.1
- NodeJS >= 8.9.4
- VSCode (ideally), or VS2017
- Install the template from nuget:
dotnet new -i aspnetcore-vuejs
- Create folder from template:
dotnet new vuejs
(Official documentation)- This will automatically run
dotnet restore
unless you install withdotnet new vuejs --skipRestore
- This will automatically run
- Restore Node dependencies by running
npm install
You have two choices when it come at how your preffer to run it. You can either use the command line or the build-in run command.
Run the application using dotnet run
or npm run dev
- note
dotnet run
should be run inDevelopment
environment for hot reloading. This setting can be set either within the command line or via thelaunchSettings.json
available in theProperties
folder.
Run the application in VSCode or Visual Studio 2017 by hitting F5
.
Browse to http://localhost:5000
Install the mock server npm install -D json-server
This is just an example
const jsonServer = require('json-server')
const server = jsonServer.create()
const middlewares = jsonServer.defaults()
server.use(middlewares)
server.listen(3000, () => {
console.log('JSON Server is running')
})
server.get('/unauthorized', (req, res) => {
res.status(401).jsonp({
message: "unauthorized"
})
})
server.get('/systemerror', (req, res) => {
res.status(500).jsonp({
message: "something wrong"
})
})
Run the application using node mock.js
$ curl -i localhost:3000/systemerror
HTTP/1.1 500 Internal Server Error
X-Powered-By: Express
Vary: Origin, Accept-Encoding
Access-Control-Allow-Credentials: true
Cache-Control: no-cache
Pragma: no-cache
Expires: -1
X-Content-Type-Options: nosniff
Content-Type: application/json; charset=utf-8
Content-Length: 32
ETag: W/"20-fhnUB5BwaOsQsXyG8exFr0MEGzY"
Date: Wed, 17 Jan 2018 13:16:01 GMT
Connection: keep-alive
{
"message": "something wrong"
}