Skip to content
This repository has been archived by the owner on Jul 20, 2020. It is now read-only.

Feature/add circle ci #30

Merged
merged 12 commits into from Dec 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions .circleci/config.yml
@@ -0,0 +1,20 @@
# Python CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-python/ for more details
#
version: 2
jobs:
build:
docker:
- image: microsoft/dotnet
steps:
- checkout
- run:
name: get dependencies
command: dotnet restore ./src
- run:
name: build
command: dotnet build ./src
- run:
name: package
command : dotnet pack ./src -o publish -c Release --version-suffix prerelease
28 changes: 28 additions & 0 deletions .vscode/launch.json
@@ -0,0 +1,28 @@
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/src/Nancy.Hal.Example/bin/Debug/netcoreapp2.0/Nancy.Hal.Example.dll",
"args": [],
"cwd": "${workspaceFolder}/src/Nancy.Hal.Example",
// For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
"console": "internalConsole",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
15 changes: 15 additions & 0 deletions .vscode/tasks.json
@@ -0,0 +1,15 @@
{
"version": "2.0.0",
"tasks": [
{
"taskName": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/src/Nancy.Hal.Example/Nancy.Hal.Example.csproj"
],
"problemMatcher": "$msCompile"
}
]
}
5 changes: 5 additions & 0 deletions README.md
Expand Up @@ -29,6 +29,11 @@ Get started
Install-Package Nancy.Hal
```






2) Create a `HalConfiguration` instance.
```
var config = new HalConfiguration();
Expand Down
2 changes: 1 addition & 1 deletion SharedAssemblyInfo.cs
Expand Up @@ -5,4 +5,4 @@
[assembly: AssemblyCompany("Dan Barua, Matt Vane, Thomas Eizinger, Richard Bennett")]
[assembly: AssemblyProduct("Nancy.Hal")]
[assembly: AssemblyCopyright("Copyright (C) Dan Barua, Matt Vane, Thomas Eizinger, Richard Bennett and other contributors")]
[assembly: AssemblyVersion("1.2.1")]
[assembly: AssemblyVersion("2.0.0")]
16 changes: 10 additions & 6 deletions rakefile.rb
Expand Up @@ -4,8 +4,12 @@
require 'rake/clean'
require 'rexml/document'

NANCY_VERSION = "1.4.3"
LIB_VERSION = "1.3.0"
NANCY_VERSION = "2.0.0-beta"
LIB_VERSION = "2.0.0-beta0001"
ASSEMBLY_VERSION = LIB_VERSION
if LIB_VERSION.include? "-"
ASSEMBLY_VERSION = LIB_VERSION.gsub(/\-\S+/, '')
end

OUTPUT = "build"
CONFIGURATION = 'Release'
Expand All @@ -16,7 +20,7 @@
Albacore.configure do |config|
config.log_level = :verbose
config.msbuild.use :net4
config.xunit.command = "tools/xunit/xunit.console.clr4.x86.exe"
config.xunit.command = "tools/xunit/xunit.console.clr4.x86.exe"
end

desc "Compiles solution and runs unit tests"
Expand All @@ -28,7 +32,7 @@

desc "Update shared assemblyinfo file for the build"
assemblyinfo :version => [:clean] do |asm|
asm.version = LIB_VERSION
asm.version = ASSEMBLY_VERSION
asm.company_name = "#{CONTRIBUTORS}"
asm.product_name = "Nancy.Hal"
asm.title = "Nancy.Hal"
Expand Down Expand Up @@ -81,7 +85,7 @@

desc "Generates NuGet packages for each project that contains a nuspec"
task :nuget_package => [:publish] do
Dir.mkdir("#{OUTPUT}/nuget")
Dir.mkdir("#{OUTPUT}/nuget")
nuspecs = FileList["src/**/*.nuspec"]
root = File.dirname(__FILE__)

Expand Down Expand Up @@ -159,4 +163,4 @@ def get_assembly_version(file)
return result[1] if !result.nil?
end
end
end
end
102 changes: 46 additions & 56 deletions src/Nancy.Hal.Example/Model/Users/RolesModule.cs
@@ -1,63 +1,53 @@
namespace Nancy.Hal.Example.Model.Users
{
using Nancy;
namespace Nancy.Hal.Example.Model.Users {
using Nancy.Hal.Example.Model.Users.Commands;
using Nancy.Hal.Example.Model.Users.Queries;
using Nancy.ModelBinding;
using Nancy;

public class RolesModule : NancyModule {
public RolesModule (Database db) : base ("/roles") {
this.Get ("/", _ => {
var request = this.Bind<GetRoleList> ();
var roles = db.GetAllRoles ();
return Negotiate.WithModel (roles);
});

this.Get ("/{roleId:guid}", _ => {
var req = this.Bind<GetRoleDetails> ();
var role = db.GetRoleById (req.RoleId);

if (role == null) {
return 404;
}

return Negotiate.WithModel (role);
});

this.Post ("/", _ => {
var req = this.Bind<CreateRole> ();
db.CreateRole (req);
var role = db.GetRoleById (req.Id.GetValueOrDefault ());
return Negotiate
.WithHeader ("Location", "/roles/" + req.Id.GetValueOrDefault ())
.WithModel (role)
.WithStatusCode (HttpStatusCode.Created);
});

this.Put ("/{roleId:guid}", _ => {
var req = this.Bind<UpdateRole> ();
db.UpdateRole (req);
var role = db.GetRoleById (req.RoleId);

return
Negotiate.WithHeader ("Location", "/roles/" + req.RoleId)
.WithModel (role);
});

public class RolesModule : NancyModule
{
public RolesModule(Database db)
: base("/roles")
{
this.Get["/"] = _ =>
{
var request = this.Bind<GetRoleList>();
var roles = db.GetAllRoles();
return Negotiate.WithModel(roles);
};

this.Get["/{roleId:guid}"] = _ =>
{
var req = this.Bind<GetRoleDetails>();
var role = db.GetRoleById(req.RoleId);

if (role == null)
{
return 404;
}

return Negotiate.WithModel(role);
};

this.Post["/"] = _ =>
{
var req = this.Bind<CreateRole>();
db.CreateRole(req);
var role = db.GetRoleById(req.Id.GetValueOrDefault());
return Negotiate
.WithHeader("Location", "/roles/" + req.Id.GetValueOrDefault())
.WithModel(role)
.WithStatusCode(HttpStatusCode.Created);
};

this.Put["/{roleId:guid}"] = _ =>
{
var req = this.Bind<UpdateRole>();
db.UpdateRole(req);
var role = db.GetRoleById(req.RoleId);

return
Negotiate.WithHeader("Location", "/roles/" + req.RoleId)
.WithModel(role);
};

this.Delete["/{roleId:guid}"] = _ =>
{
var req = this.Bind<DeleteRole>();
db.DeleteRole(req);
return this.Negotiate.WithStatusCode(HttpStatusCode.NoContent);
};
this.Delete ("/{roleId:guid}", _ => {
var req = this.Bind<DeleteRole> ();
db.DeleteRole (req);
return this.Negotiate.WithStatusCode (HttpStatusCode.NoContent);
});
}
}
}
127 changes: 58 additions & 69 deletions src/Nancy.Hal.Example/Model/Users/UsersModule.cs
@@ -1,86 +1,75 @@
namespace Nancy.Hal.Example.Model.Users
{
using Nancy;
using Nancy.Hal.Example.Model.Users.Commands;
using Nancy.Hal.Example.Model.Users.Queries;
using Nancy.ModelBinding;
using Nancy;
using Nancy.Hal.Example.Model.Users.Commands;
using Nancy.Hal.Example.Model.Users.Queries;
using Nancy.ModelBinding;
namespace Nancy.Hal.Example.Model.Users {

public class UsersModule : NancyModule
{
public UsersModule(Database db)
: base("/users")
{
this.Get["/"] = _ =>
{
var request = this.Bind<GetUserList>();
var users = db.GetAllUsersPaged(request);
public class UsersModule : NancyModule {
public UsersModule (Database db) : base ("/users") {
this.Get ("/", _ => {
var request = this.Bind<GetUserList> ();
var users = db.GetAllUsersPaged (request);

return Negotiate.WithModel(users);
};
return Negotiate.WithModel (users);
});

this.Get["/{userId:guid}"] = _ =>
{
var request = this.Bind<GetUserDetails>();
var user = db.GetUserById(request.UserId);
if (user == null)
{
return 404;
}
this.Get ("/{userId:guid}", _ => {
var request = this.Bind<GetUserDetails> ();
var user = db.GetUserById (request.UserId);
if (user == null) {
return 404;
}

return Negotiate.WithModel(user);
};
return Negotiate.WithModel (user);
});

this.Post["/"] = _ =>
{
var request = this.Bind<CreateUser>();
db.CreateUser(request);
var user = db.GetUserById(request.Id.GetValueOrDefault());
this.Post ("/", _ => {
var request = this.Bind<CreateUser> ();
db.CreateUser (request);
var user = db.GetUserById (request.Id.GetValueOrDefault ());

return
this.Negotiate.WithHeader("Location", LinkTemplates.Users.GetUser.CreateLink(new { Id = user.Id }).ToString())
.WithModel(user)
.WithStatusCode(HttpStatusCode.Created);
};
return
this.Negotiate.WithHeader ("Location", LinkTemplates.Users.GetUser.CreateLink (new { Id = user.Id }).ToString ())
.WithModel (user)
.WithStatusCode (HttpStatusCode.Created);
});

this.Put["/{userId:guid}"] = _ =>
{
var request = this.Bind<UpdateUserDetails>();
db.UpdateUser(request);
var user = db.GetUserById(request.UserId);
this.Put ("/{userId:guid}", _ => {
var request = this.Bind<UpdateUserDetails> ();
db.UpdateUser (request);
var user = db.GetUserById (request.UserId);

return this.Negotiate.WithModel(user)
.WithStatusCode(HttpStatusCode.OK);
};
return this.Negotiate.WithModel (user)
.WithStatusCode (HttpStatusCode.OK);
});

this.Put["/{userId:guid}/deactivate"] = _ =>
{
var request = this.Bind<DeactivateUser>();
db.Deactivate(request);
var user = db.GetUserById(request.UserId);
this.Put ("/{userId:guid}/deactivate", _ => {
var request = this.Bind<DeactivateUser> ();
db.Deactivate (request);
var user = db.GetUserById (request.UserId);

return this.Negotiate.WithModel(user)
.WithStatusCode(HttpStatusCode.OK);
};
return this.Negotiate.WithModel (user)
.WithStatusCode (HttpStatusCode.OK);
});

this.Put["/{userId:guid}/reactivate"] = _ =>
{
var request = this.Bind<ReactivateUser>();
db.Reactivate(request);
var user = db.GetUserById(request.UserId);
this.Put ("/{userId:guid}/reactivate", _ => {
var request = this.Bind<ReactivateUser> ();
db.Reactivate (request);
var user = db.GetUserById (request.UserId);

return this.Negotiate.WithModel(user)
.WithStatusCode(HttpStatusCode.OK);
};
return this.Negotiate.WithModel (user)
.WithStatusCode (HttpStatusCode.OK);
});

this.Put["/{userId:guid}/role/{roleId:guid}"] = _ =>
{
var request = this.Bind<ChangeUserRole>();
db.ChangeRole(request);
var user = db.GetUserById(request.UserId);
this.Put ("/{userId:guid}/role/{roleId:guid}", _ => {
var request = this.Bind<ChangeUserRole> ();
db.ChangeRole (request);
var user = db.GetUserById (request.UserId);

return this.Negotiate.WithModel(user)
.WithStatusCode(HttpStatusCode.OK);
};
return this.Negotiate.WithModel (user)
.WithStatusCode (HttpStatusCode.OK);

});
}
}
}