Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for Node-Restify #353

Merged
merged 7 commits into from
Apr 18, 2013
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
4 changes: 2 additions & 2 deletions src/Libraries/Node/Node.Core/Network/HttpServerRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ namespace NodeApi.Network {

[ScriptImport]
[ScriptIgnoreNamespace]
public sealed class HttpServerRequest : ReadableStream, IEventEmitter {
public class HttpServerRequest : ReadableStream, IEventEmitter {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't notice something in the restify docs to document the restify request deriving from the core http equivalents.

Independent of that though, I feel it might be better to simply duplicate, since:

  • Not necessary everything on HttpServerRequest should be on the RestifyRequest.
  • This opens up derivation possibilities in script# code which would neither be right, nor supported.

Same applies to HttpServerResponse.

Might be best duplicating the relevant properties.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Restify's Request API section, it says that it wraps all of the node ServerRequest API's, events and properties, plus the Restify specific entities.

I don't think we should be replicating functionality as we'll have to keep them in sync every time there are changes in Node's Request object. Same goes for Response.

I can duplicate for now, although I have not been successful at using git squash and have previous changes discarded after sending a pull request. Earlier I had to drop my repo and re-fork to get rid of some of the things. If you have any insights into how to do it, that'll be helpful.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there's a way to undo changes/history for a specific file from an existing push.
I'm assuming that by using git commit --squash, you want me to bundle all the changes in a single request.


private HttpServerRequest() {
protected HttpServerRequest() {
}

[ScriptField]
Expand Down
4 changes: 2 additions & 2 deletions src/Libraries/Node/Node.Core/Network/HttpServerResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ namespace NodeApi.Network {

[ScriptImport]
[ScriptIgnoreNamespace]
public sealed class HttpServerResponse : WritableStream, IEventEmitter {
public class HttpServerResponse : WritableStream, IEventEmitter {

private HttpServerResponse() {
protected HttpServerResponse() {
}

[ScriptField]
Expand Down
80 changes: 80 additions & 0 deletions src/Libraries/Node/Node.Restify/Node.Restify.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{1ECC689C-2542-4EE8-8A86-7627E63F44F8}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>NodeApi.Restify</RootNamespace>
<AssemblyName>Script.Node.Restify</AssemblyName>
<NoStdLib>True</NoStdLib>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\..\ScriptSharp.snk</AssemblyOriginatorKeyFile>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>..\..\..\..\bin\Debug\</OutputPath>
<DebugSymbols>false</DebugSymbols>
<DefineConstants>DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>..\..\..\..\bin\Debug\Script.Node.Restify.xml</DocumentationFile>
<NoWarn>1591, 0661, 0660, 1684</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<DebugSymbols>false</DebugSymbols>
<Optimize>true</Optimize>
<OutputPath>..\..\..\..\bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>..\..\..\..\bin\Release\Script.Node.Restify.xml</DocumentationFile>
<NoWarn>1591, 0661, 0660, 1684</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\..\ScriptSharp.cs">
<Link>Properties\ScriptSharp.cs</Link>
</Compile>
<Compile Include="RestifyLogger.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RestifyApplication.cs" />
<Compile Include="RestifyCallback.cs" />
<Compile Include="RestifyChain.cs" />
<Compile Include="RestifyError.cs" />
<Compile Include="RestifyHandler.cs" />
<Compile Include="RestifyHttpClient.cs" />
<Compile Include="RestifyJsonClient.cs" />
<Compile Include="RestifyJsonClientOptions.cs" />
<Compile Include="RestifyRequest.cs" />
<Compile Include="RestifyResponse.cs" />
<Compile Include="RestifyRoute.cs" />
<Compile Include="RestifyServer.cs" />
<Compile Include="RestifyServerGetOptions.cs" />
<Compile Include="RestifyServerOptions.cs" />
<Compile Include="RestifyStringClient.cs" />
<Compile Include="RestifyThrottleOptions.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Core\CoreLib\CoreLib.csproj">
<Project>{36d4b098-a21c-4725-acd3-400922885f38}</Project>
<Name>CoreLib</Name>
</ProjectReference>
<ProjectReference Include="..\Node.Core\Node.Core.csproj">
<Project>{4a9f7ce9-5a45-4b28-ad01-05528709b6e4}</Project>
<Name>Node.Core</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Target Name="AfterBuild">
<Copy SourceFiles="@(ScriptInfo)" DestinationFiles="$(OutputPath)$(AssemblyName).txt" />
</Target>
<Import Project="..\..\..\packages\ScriptSharp.0.8\tools\ScriptSharp.targets" Condition="Exists('..\..\..\packages\ScriptSharp.0.8\tools\ScriptSharp.targets')" />
</Project>
11 changes: 11 additions & 0 deletions src/Libraries/Node/Node.Restify/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// AssemblyInfo.cs
// Script#/Libraries/Node/Restify
// This source code is subject to terms and conditions of the Apache License, Version 2.0.
//

using System;
using System.Reflection;

[assembly: AssemblyTitle("Script.Node.Restify")]
[assembly: AssemblyDescription("Script# NodeJS Restify Module API")]
[assembly: ScriptAssembly("restify")]
10 changes: 10 additions & 0 deletions src/Libraries/Node/Node.Restify/Properties/ScriptInfo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Node Express Module
===============================================================================

This assembly provides access to Restify Module APIs for NodeJS applications.
This is only meant for use at development time, so you can reference and compile
your c# code against restify APIs.

More information is on http://mcavage.github.com/node-restify/.

-------------------------------------------------------------------------------
80 changes: 80 additions & 0 deletions src/Libraries/Node/Node.Restify/RestifyApplication.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// Restify.cs
// Script#/Libraries/Node/Restify
// This source code is subject to terms and conditions of the Apache License, Version 2.0.
//

using System;
using System.Runtime.CompilerServices;

namespace NodeApi.Restify {

[ScriptImport]
[ScriptIgnoreNamespace]
[ScriptName("restify")]
public static class RestifyApplication {

public static RestifyChainedHandler[] AcceptParser(string[] serverAcceptable) {
return null;
}

public static RestifyChainedHandler[] AuthorizationParser() {
return null;
}

public static RestifyChainedHandler[] BodyParser() {
return null;
}

public static RestifyChainedHandler[] ConditionalRequest() {
return null;
}

public static RestifyHttpClient CreateHttpClient() {
return null;
}

public static RestifyJsonClient CreateJsonClient() {
return null;
}

public static RestifyJsonClient CreateJsonClient(RestifyJsonClientOptions options) {
return null;
}

public static RestifyServer CreateServer() {
return null;
}

public static RestifyServer CreateServer(RestifyServerOptions rs) {
return null;
}

public static RestifyStringClient CreateStringClient() {
return null;
}

public static RestifyChainedHandler[] DateParser() {
return null;
}

public static RestifyChainedHandler[] GZipResponse() {
return null;
}

public static RestifyChainedHandler[] JsonBodyParser() {
return null;
}

public static RestifyChainedHandler[] Jsonp() {
return null;
}

public static RestifyChainedHandler QueryParser() {
return null;
}

public static RestifyChainedHandler[] Throttle(RestifyThrottleOptions options) {
return null;
}
}
}
9 changes: 9 additions & 0 deletions src/Libraries/Node/Node.Restify/RestifyCallback.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// RestifyCallback.cs
// Script#/Libraries/Node/Restify
// This source code is subject to terms and conditions of the Apache License, Version 2.0.
//

namespace NodeApi.Restify {

public delegate void RestifyCallback(RestifyError error, RestifyRequest request, RestifyResponse response, object content);
}
26 changes: 26 additions & 0 deletions src/Libraries/Node/Node.Restify/RestifyChain.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// RestifyChain.cs
// Script#/Libraries/Node/Restify
// This source code is subject to terms and conditions of the Apache License, Version 2.0.
//

using System;
using System.Runtime.CompilerServices;

namespace NodeApi.Restify {

[ScriptIgnoreNamespace]
[ScriptImport]
public sealed class RestifyChain {

private RestifyChain() {
}

[ScriptSkip]
public void Continue() {
}

[ScriptSkip]
public void Error(Exception error) {
}
}
}
17 changes: 17 additions & 0 deletions src/Libraries/Node/Node.Restify/RestifyError.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// RestifyError.cs
// Script#/Libraries/Node/Restify
// This source code is subject to terms and conditions of the Apache License, Version 2.0.
//

using System.Runtime.CompilerServices;

namespace NodeApi.Restify {

[ScriptIgnoreNamespace]
[ScriptImport]
public sealed class RestifyError {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

internal ctor?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch again. Added internal ctor.


internal RestifyError() {
}
}
}
18 changes: 18 additions & 0 deletions src/Libraries/Node/Node.Restify/RestifyHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// RestifyHandler.cs
// Script#/Libraries/Node/Restify
// This source code is subject to terms and conditions of the Apache License, Version 2.0.
//

using System;
using System.Runtime.CompilerServices;

namespace NodeApi.Restify {

[ScriptImport]
[ScriptIgnoreNamespace]
public delegate void RestifyHandler(RestifyRequest request, RestifyResponse response);

[ScriptImport]
[ScriptIgnoreNamespace]
public delegate RestifyChainedHandler RestifyChainedHandler(RestifyRequest request, RestifyResponse response, Func<bool, RestifyChainedHandler> next);
}
17 changes: 17 additions & 0 deletions src/Libraries/Node/Node.Restify/RestifyHttpClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// RestifyHttpClient.cs
// Script#/Libraries/Node/Restify
// This source code is subject to terms and conditions of the Apache License, Version 2.0.
//

using System.Runtime.CompilerServices;

namespace NodeApi.Restify {

[ScriptImport]
[ScriptIgnoreNamespace]
public sealed class RestifyHttpClient : RestifyStringClient {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am assuming these classes actually have specific functionality/APIs that hasn't been mapped out yet and eventually will be, hence makes sense to have these classes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's correct. I haven't had the need to use them yet so I'll implement their functionality as we get to using it (which helps me validate that the implementation works).


private RestifyHttpClient() {
}
}
}
21 changes: 21 additions & 0 deletions src/Libraries/Node/Node.Restify/RestifyJsonClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// RestifyJsonClient.cs
// Script#/Libraries/Node/Restify
// This source code is subject to terms and conditions of the Apache License, Version 2.0.
//

using System.Collections;
using System.Runtime.CompilerServices;

namespace NodeApi.Restify {

/// <summary>
/// sends and expects application/json
/// </summary>
[ScriptImport]
[ScriptIgnoreNamespace]
public sealed class RestifyJsonClient : RestifyStringClient {

private RestifyJsonClient() {
}
}
}