Skip to content

Commit

Permalink
Add v32 VueNuxt template
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed May 30, 2021
1 parent 1451d39 commit 2a71248
Show file tree
Hide file tree
Showing 61 changed files with 32,040 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*/node_modules
*/npm-debug.log
15 changes: 5 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /source
WORKDIR /app

RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - \
&& apt-get install -y --no-install-recommends nodejs \
&& echo "node version: $(node --version)" \
&& echo "npm version: $(npm --version)" \
&& rm -rf /var/lib/apt/lists/*

COPY VueNuxtTemplate/package.json .
COPY VueNuxtTemplate/npm-shrinkwrap.json .

RUN npm --prefix VueNuxtTemplate install

COPY . .
RUN dotnet restore

WORKDIR /source/VueNuxtTemplate
RUN dotnet publish -c release -o /app --no-restore
WORKDIR /app/VueNuxt
RUN dotnet publish -c release -o /out --no-restore

FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS runtime
WORKDIR /app
COPY --from=build /app ./
ENTRYPOINT ["dotnet", "VueNuxtTemplate.dll"]
COPY --from=build /out ./
ENTRYPOINT ["dotnet", "VueNuxt.dll"]
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@

$ x new vue-nuxt ProjectName

Alternatively write new project files directly into an empty repository, using the Directory Name as the ProjectName:

$ git clone https://github.com/<User>/<ProjectName>.git
$ cd <ProjectName>
$ x new vue-nuxt

## Description

Nuxt is an opinionated structured framework for rapidly developing Web Applications utilizing developer-friendly [Vue Single Page Components](https://vuejs.org/v2/guide/single-file-components.html) and featuring Hot module replacement that together with [.NET Core's watched builds](https://docs.servicestack.net/templates-websites#watched-net-core-builds) provides an highly productive development experience.
Expand Down Expand Up @@ -45,7 +51,7 @@ Whilst Nuxt.js is a JavaScript (ES 6/7) App it still benefits from [ServiceStack
$ npm run dtos

This will update the Servers `dtos.ts` and generate its corresponding `dtos.js` which can be imported as normal classes as seen in
[gateway.js](https://github.com/NetCoreTemplates/vue-nuxt/blob/master/VueNuxtTemplate/src/shared/gateway.js#L3). Despite the App not being built with TypeScript, developing using a "TypeScript-aware" IDE like VS Code will still be able to utilize the TypeScript classes in [@servicestack/client](https://github.com/ServiceStack/servicestack-client) and the generated `dtos.ts` to provide a rich, typed intelli-sense experience.
[gateway.js](https://github.com/NetCoreTemplates/vue-nuxt/blob/master/VueNuxt/src/shared/gateway.js#L3). Despite the App not being built with TypeScript, developing using a "TypeScript-aware" IDE like VS Code will still be able to utilize the TypeScript classes in [@servicestack/client](https://github.com/ServiceStack/servicestack-client) and the generated `dtos.ts` to provide a rich, typed intelli-sense experience.

## Generate Static Production Build

Expand Down
38 changes: 38 additions & 0 deletions VueNuxt.ServiceInterface/MyServices.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using ServiceStack;
using VueNuxt.ServiceModel;

namespace VueNuxt.ServiceInterface
{
public class MyServices : Service
{
public object Any(Hello request)
{
return new HelloResponse { Result = $"Hello, {request.Name}!" };
}

public object Any(GetLinks request) => new GetLinksResponse
{
Results = new Dictionary<string, string>
{
{"servicestack.net", "https://servicestack.net"},
{"StackOverflow", "http://stackoverflow.com/search?q=servicestack"},
{"Customer Forums", "https://forums.servicestack.net"},
{"Issue Tracker", "https://github.com/ServiceStack/Issues"},
{"Feature Requests", "http://servicestack.uservoice.com/forums/176786-feature-requests"},
{"Release Notes", "https://servicestack.net/release-notes"},
{"Live Demos", "https://github.com/ServiceStackApps/LiveDemos"},
{".NET Core Live Demos", "https://github.com/NetCoreApps/LiveDemos"},
{"Gistlyn", "http://gistlyn.com"},
}
};

public object Any(GetPost request) => new GetPostResponse
{
Id = request.Id,
Title = $"Title {request.Id}",
Description = $"Post Description {request.Id}",
};
}
}
15 changes: 15 additions & 0 deletions VueNuxt.ServiceInterface/VueNuxt.ServiceInterface.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ServiceStack" Version="5.*" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\VueNuxt.ServiceModel\VueNuxt.ServiceModel.csproj" />
</ItemGroup>

</Project>
13 changes: 13 additions & 0 deletions VueNuxt.ServiceModel/GetLinks.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Collections.Generic;
using ServiceStack;

namespace VueNuxt.ServiceModel
{
[Route("/links")]
public class GetLinks : IReturn<GetLinksResponse> {}

public class GetLinksResponse
{
public Dictionary<string,string> Results { get; set; }
}
}
18 changes: 18 additions & 0 deletions VueNuxt.ServiceModel/GetPost.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.Collections.Generic;
using ServiceStack;

namespace VueNuxt.ServiceModel
{
[Route("/posts")]
public class GetPost : IReturn<GetPostResponse>
{
public int Id { get; set; }
}

public class GetPostResponse
{
public int Id { get; set; }
public string Title { get; set; }
public string Description { get; set; }
}
}
16 changes: 16 additions & 0 deletions VueNuxt.ServiceModel/Hello.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using ServiceStack;

namespace VueNuxt.ServiceModel
{
[Route("/hello")]
[Route("/hello/{Name}")]
public class Hello : IReturn<HelloResponse>
{
public string Name { get; set; }
}

public class HelloResponse
{
public string Result { get; set; }
}
}
1 change: 1 addition & 0 deletions VueNuxt.ServiceModel/Types/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
As part of our [Physical Project Structure](https://docs.servicestack.net/physical-project-structure) convention we recommend maintaining any shared non Request/Response DTOs in the `ServiceModel.Types` namespace.
15 changes: 15 additions & 0 deletions VueNuxt.ServiceModel/VueNuxt.ServiceModel.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ServiceStack.Interfaces" Version="5.*" />
</ItemGroup>

<ItemGroup>
<Folder Include="Types\" />
</ItemGroup>

</Project>
45 changes: 45 additions & 0 deletions VueNuxt.Tests/IntegrationTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using Funq;
using ServiceStack;
using NUnit.Framework;
using VueNuxt.ServiceInterface;
using VueNuxt.ServiceModel;

namespace VueNuxt.Tests
{
public class IntegrationTest
{
const string BaseUri = "http://localhost:2000/";
private readonly ServiceStackHost appHost;

class AppHost : AppSelfHostBase
{
public AppHost() : base(nameof(IntegrationTest), typeof(MyServices).Assembly) { }

public override void Configure(Container container)
{
}
}

public IntegrationTest()
{
appHost = new AppHost()
.Init()
.Start(BaseUri);
}

[OneTimeTearDown]
public void OneTimeTearDown() => appHost.Dispose();

public IServiceClient CreateClient() => new JsonServiceClient(BaseUri);

[Test]
public void Can_call_Hello_Service()
{
var client = CreateClient();

var response = client.Get(new Hello { Name = "World" });

Assert.That(response.Result, Is.EqualTo("Hello, World!"));
}
}
}
32 changes: 32 additions & 0 deletions VueNuxt.Tests/UnitTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using NUnit.Framework;
using ServiceStack;
using ServiceStack.Testing;
using VueNuxt.ServiceInterface;
using VueNuxt.ServiceModel;

namespace VueNuxt.Tests
{
public class UnitTest
{
private readonly ServiceStackHost appHost;

public UnitTest()
{
appHost = new BasicAppHost().Init();
appHost.Container.AddTransient<MyServices>();
}

[OneTimeTearDown]
public void OneTimeTearDown() => appHost.Dispose();

[Test]
public void Can_call_MyServices()
{
var service = appHost.Container.Resolve<MyServices>();

var response = (HelloResponse)service.Any(new Hello { Name = "World" });

Assert.That(response.Result, Is.EqualTo("Hello, World!"));
}
}
}
20 changes: 20 additions & 0 deletions VueNuxt.Tests/VueNuxt.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5</TargetFramework>
<DebugType>portable</DebugType>
<OutputType>Library</OutputType>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\VueNuxt.ServiceInterface\VueNuxt.ServiceInterface.csproj" />
<ProjectReference Include="..\VueNuxt.ServiceModel\VueNuxt.ServiceModel.csproj" />

<PackageReference Include="NUnit" Version="3.12.*" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.*" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.*" />
<PackageReference Include="ServiceStack" Version="5.*" />
<PackageReference Include="ServiceStack.Kestrel" Version="5.*" />
</ItemGroup>

</Project>
43 changes: 43 additions & 0 deletions VueNuxt.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26730.3
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VueNuxt", "VueNuxt\VueNuxt.csproj", "{5F817400-1A3A-48DF-98A6-E7E5A3DC762F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VueNuxt.ServiceInterface", "VueNuxt.ServiceInterface\VueNuxt.ServiceInterface.csproj", "{5B8FFF01-1E0B-477D-9D7F-93016C128B23}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VueNuxt.ServiceModel", "VueNuxt.ServiceModel\VueNuxt.ServiceModel.csproj", "{0127B6CA-1B79-46A6-8307-B36836D107F0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VueNuxt.Tests", "VueNuxt.Tests\VueNuxt.Tests.csproj", "{455EC1EF-134F-4CD4-9C78-E813E4E6D8F6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5F817400-1A3A-48DF-98A6-E7E5A3DC762F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5F817400-1A3A-48DF-98A6-E7E5A3DC762F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5F817400-1A3A-48DF-98A6-E7E5A3DC762F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5F817400-1A3A-48DF-98A6-E7E5A3DC762F}.Release|Any CPU.Build.0 = Release|Any CPU
{5B8FFF01-1E0B-477D-9D7F-93016C128B23}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5B8FFF01-1E0B-477D-9D7F-93016C128B23}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5B8FFF01-1E0B-477D-9D7F-93016C128B23}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5B8FFF01-1E0B-477D-9D7F-93016C128B23}.Release|Any CPU.Build.0 = Release|Any CPU
{0127B6CA-1B79-46A6-8307-B36836D107F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0127B6CA-1B79-46A6-8307-B36836D107F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0127B6CA-1B79-46A6-8307-B36836D107F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0127B6CA-1B79-46A6-8307-B36836D107F0}.Release|Any CPU.Build.0 = Release|Any CPU
{455EC1EF-134F-4CD4-9C78-E813E4E6D8F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{455EC1EF-134F-4CD4-9C78-E813E4E6D8F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{455EC1EF-134F-4CD4-9C78-E813E4E6D8F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{455EC1EF-134F-4CD4-9C78-E813E4E6D8F6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {02854F2A-8EF4-468E-80A3-CD64BBAF5D15}
EndGlobalSection
EndGlobal
16 changes: 16 additions & 0 deletions VueNuxt/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# editorconfig.org
root = true

[*]
indent_size = 2
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.cs]
indent_size = 4

[*.md]
trim_trailing_whitespace = false
14 changes: 14 additions & 0 deletions VueNuxt/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# js vendor file with import/require
assets/**

# static vendor file . use with nuxt.config.js script
static/**

# dependencies
node_modules

# Nuxt build
.nuxt

# Nuxt generate
wwwroot
21 changes: 21 additions & 0 deletions VueNuxt/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
root: true,
env: {
browser: true,
node: true
},
parserOptions: {
parser: 'babel-eslint'
},
extends: [
// https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention
// consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules.
'plugin:vue/essential',
],
// required to lint *.vue files
plugins: [
'vue'
],
// add your custom rules here
rules: {}
}
Loading

0 comments on commit 2a71248

Please sign in to comment.