commit 414395b87daefb80cfe880b160b032e05bfde0bb Author: Tommy Parnell Date: Wed Jan 11 21:29:12 2017 -0500 init diff --git a/Hashr/.gitignore b/Hashr/.gitignore new file mode 100644 index 0000000..1b86e7e --- /dev/null +++ b/Hashr/.gitignore @@ -0,0 +1,268 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +project.fragment.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/ diff --git a/Hashr/.vscode/launch.json b/Hashr/.vscode/launch.json new file mode 100644 index 0000000..135279b --- /dev/null +++ b/Hashr/.vscode/launch.json @@ -0,0 +1,42 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (web)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + "program": "${workspaceRoot}\\bin\\Debug\\netcoreapp1.1\\Hashr.dll", + "args": [], + "cwd": "${workspaceRoot}", + "stopAtEntry": false, + "internalConsoleOptions": "openOnSessionStart", + "launchBrowser": { + "enabled": true, + "args": "${auto-detect-url}", + "windows": { + "command": "cmd.exe", + "args": "/C start ${auto-detect-url}" + }, + "osx": { + "command": "open" + }, + "linux": { + "command": "xdg-open" + } + }, + "env": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "sourceFileMap": { + "/Views": "${workspaceRoot}/Views" + } + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command.pickProcess}" + } + ] +} \ No newline at end of file diff --git a/Hashr/.vscode/tasks.json b/Hashr/.vscode/tasks.json new file mode 100644 index 0000000..9cd37c1 --- /dev/null +++ b/Hashr/.vscode/tasks.json @@ -0,0 +1,16 @@ +{ + "version": "0.1.0", + "command": "dotnet", + "isShellCommand": true, + "args": [], + "tasks": [ + { + "taskName": "build", + "args": [ + "${workspaceRoot}\\project.json" + ], + "isBuildCommand": true, + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/Hashr/Controllers/ValuesController.cs b/Hashr/Controllers/ValuesController.cs new file mode 100644 index 0000000..dc85778 --- /dev/null +++ b/Hashr/Controllers/ValuesController.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Routing; +using System.Security.Cryptography; +namespace Hashr.Controllers +{ + public class ValuesController : Controller + { // POST api/values + [HttpPost] + [Route("hashme")] + public async Task HashMe() + { + using(var memstream = new MemoryStream()) + using(var sha = SHA256.Create()) + { + await this.Request.Body.CopyToAsync(memstream); + return System.Text.Encoding.ASCII.GetString(sha.ComputeHash(memstream.ToArray())); + } + } + } +} diff --git a/Hashr/Dockerfile b/Hashr/Dockerfile new file mode 100644 index 0000000..048dfba --- /dev/null +++ b/Hashr/Dockerfile @@ -0,0 +1,13 @@ +FROM microsoft/dotnet:latest + +COPY . /app + +WORKDIR /app + +RUN ["dotnet", "restore"] + +RUN ["dotnet", "build"] + +EXPOSE 5000/tcp + +CMD ["dotnet", "run", "--server.urls", "http://*:5000"] diff --git a/Hashr/Program.cs b/Hashr/Program.cs new file mode 100644 index 0000000..1d71d6b --- /dev/null +++ b/Hashr/Program.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.Configuration; + +namespace Hashr +{ + public class Program + { + public static void Main(string[] args) + { + var config = new ConfigurationBuilder() + .AddCommandLine(args) + .AddEnvironmentVariables(prefix: "ASPNETCORE_") + .Build(); + + var host = new WebHostBuilder() + .UseConfiguration(config) + .UseKestrel() + .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIISIntegration() + .UseStartup() + .Build(); + + host.Run(); + } + } +} diff --git a/Hashr/Properties/launchSettings.json b/Hashr/Properties/launchSettings.json new file mode 100644 index 0000000..87ab414 --- /dev/null +++ b/Hashr/Properties/launchSettings.json @@ -0,0 +1,28 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:1479/", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "api/values", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "Hashr": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "http://localhost:5000/api/values", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/Hashr/README.md b/Hashr/README.md new file mode 100644 index 0000000..a066c38 --- /dev/null +++ b/Hashr/README.md @@ -0,0 +1,39 @@ +# Welcome to ASP.NET Core + +We've made some big updates in this release, so it’s **important** that you spend a few minutes to learn what’s new. + +You've created a new ASP.NET Core project. [Learn what's new](https://go.microsoft.com/fwlink/?LinkId=518016) + +## This application consists of: + +* Sample pages using ASP.NET Core MVC +* [Bower](https://go.microsoft.com/fwlink/?LinkId=518004) for managing client-side libraries +* Theming using [Bootstrap](https://go.microsoft.com/fwlink/?LinkID=398939) + +## How to + +* [Add a Controller and View](https://go.microsoft.com/fwlink/?LinkID=398600) +* [Add an appsetting in config and access it in app.](https://go.microsoft.com/fwlink/?LinkID=699562) +* [Manage User Secrets using Secret Manager.](https://go.microsoft.com/fwlink/?LinkId=699315) +* [Use logging to log a message.](https://go.microsoft.com/fwlink/?LinkId=699316) +* [Add packages using NuGet.](https://go.microsoft.com/fwlink/?LinkId=699317) +* [Add client packages using Bower.](https://go.microsoft.com/fwlink/?LinkId=699318) +* [Target development, staging or production environment.](https://go.microsoft.com/fwlink/?LinkId=699319) + +## Overview + +* [Conceptual overview of what is ASP.NET Core](https://go.microsoft.com/fwlink/?LinkId=518008) +* [Fundamentals of ASP.NET Core such as Startup and middleware.](https://go.microsoft.com/fwlink/?LinkId=699320) +* [Working with Data](https://go.microsoft.com/fwlink/?LinkId=398602) +* [Security](https://go.microsoft.com/fwlink/?LinkId=398603) +* [Client side development](https://go.microsoft.com/fwlink/?LinkID=699321) +* [Develop on different platforms](https://go.microsoft.com/fwlink/?LinkID=699322) +* [Read more on the documentation site](https://go.microsoft.com/fwlink/?LinkID=699323) + +## Run & Deploy + +* [Run your app](https://go.microsoft.com/fwlink/?LinkID=517851) +* [Run tools such as EF migrations and more](https://go.microsoft.com/fwlink/?LinkID=517853) +* [Publish to Microsoft Azure Web Apps](https://go.microsoft.com/fwlink/?LinkID=398609) + +We would love to hear your [feedback](https://go.microsoft.com/fwlink/?LinkId=518015) diff --git a/Hashr/Startup.cs b/Hashr/Startup.cs new file mode 100644 index 0000000..3b73fbc --- /dev/null +++ b/Hashr/Startup.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; + +namespace Hashr +{ + public class Startup + { + public Startup(IHostingEnvironment env) + { + var builder = new ConfigurationBuilder() + .SetBasePath(env.ContentRootPath) + .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) + .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) + .AddEnvironmentVariables(); + Configuration = builder.Build(); + } + + public IConfigurationRoot Configuration { get; } + + // This method gets called by the runtime. Use this method to add services to the container. + public void ConfigureServices(IServiceCollection services) + { + // Add framework services. + services.AddMvc(); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + { + loggerFactory.AddConsole(Configuration.GetSection("Logging")); + loggerFactory.AddDebug(); + + app.UseMvc(); + } + } +} diff --git a/Hashr/appsettings.json b/Hashr/appsettings.json new file mode 100644 index 0000000..723c096 --- /dev/null +++ b/Hashr/appsettings.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "IncludeScopes": false, + "LogLevel": { + "Default": "Debug", + "System": "Information", + "Microsoft": "Information" + } + } +} diff --git a/Hashr/project.json b/Hashr/project.json new file mode 100644 index 0000000..0dcebca --- /dev/null +++ b/Hashr/project.json @@ -0,0 +1,62 @@ +{ + "dependencies": { + "Microsoft.NETCore.App": { + "version": "1.1.0", + "type": "platform" + }, + "Microsoft.AspNetCore.Mvc": "1.1.0", + "Microsoft.AspNetCore.Routing": "1.1.0", + "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0", + "Microsoft.AspNetCore.Server.Kestrel": "1.1.0", + "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0", + "Microsoft.Extensions.Configuration.FileExtensions": "1.1.0", + "Microsoft.Extensions.Configuration.Json": "1.1.0", + "Microsoft.Extensions.Configuration.CommandLine": "1.1.0", + "Microsoft.Extensions.Logging": "1.1.0", + "Microsoft.Extensions.Logging.Console": "1.1.0", + "Microsoft.Extensions.Logging.Debug": "1.1.0", + "Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0" + }, + + "tools": { + "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final" + }, + + "frameworks": { + "netcoreapp1.1": { + "imports": [ + "dotnet5.6", + "portable-net45+win8" + ] + } + }, + + "buildOptions": { + "emitEntryPoint": true, + "preserveCompilationContext": true, + "debugType": "portable" + }, + + "runtimeOptions": { + "configProperties": { + "System.GC.Server": true + } + }, + + "publishOptions": { + "include": [ + "wwwroot", + "**/*.cshtml", + "appsettings.json", + "web.config" + ] + }, + + "scripts": { + "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] + }, + + "tooling": { + "defaultNamespace": "Hashr" + } +} diff --git a/Hashr/web.config b/Hashr/web.config new file mode 100644 index 0000000..a8d6672 --- /dev/null +++ b/Hashr/web.config @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/Worker/.gitignore b/Worker/.gitignore new file mode 100644 index 0000000..1b86e7e --- /dev/null +++ b/Worker/.gitignore @@ -0,0 +1,268 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +project.fragment.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/ diff --git a/Worker/Program.cs b/Worker/Program.cs new file mode 100644 index 0000000..bf8c52a --- /dev/null +++ b/Worker/Program.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Net.Http; +using System.Text; +namespace Worker +{ + public class Program + { + static HttpClient httpclient = new HttpClient(); + public static void Main(string[] args) + { + MainAsync(args).Wait(); + } + public static async Task MainAsync(string[] args) + { + while(true) + { + var bytes = await httpclient.GetByteArrayAsync("http://gen/8"); + var results = await httpclient.PostAsync("http://hashr/hashme", new ByteArrayContent(bytes)); + results.EnsureSuccessStatusCode(); + var hashResults = await results.Content.ReadAsStringAsync(); + var dbResult = await httpclient.GetStringAsync($"http://store/store?dt={DateTime.Now.ToString()}"); + await Task.Delay(1000); + } + } + } +} diff --git a/Worker/project.json b/Worker/project.json new file mode 100644 index 0000000..cc20bf2 --- /dev/null +++ b/Worker/project.json @@ -0,0 +1,23 @@ +{ + "version": "1.0.0-*", + "buildOptions": { + "emitEntryPoint": true + }, + + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.1.0" + } + }, + + "frameworks": { + "netcoreapp1.1": { + "imports": "dnxcore50" + } + }, + + "tooling": { + "defaultNamespace": "Worker" + } +} diff --git a/gen/Dockerfile b/gen/Dockerfile new file mode 100644 index 0000000..701e438 --- /dev/null +++ b/gen/Dockerfile @@ -0,0 +1,5 @@ +FROM python +RUN pip install Flask +COPY gen.py . +CMD ["python", "gen.py"] +EXPOSE 80 diff --git a/gen/gen.py b/gen/gen.py new file mode 100644 index 0000000..bc94a03 --- /dev/null +++ b/gen/gen.py @@ -0,0 +1,28 @@ +from flask import Flask, Response +import os +import socket +import time + +app = Flask(__name__) + +# Enable debugging if the DEBUG environment variable is set and starts with Y +app.debug = os.environ.get("DEBUG", "").lower().startswith('y') + +urandom = os.open("/dev/urandom", os.O_RDONLY) + + +@app.route("/") +def index(): + return "gen running" + + +@app.route("/") +def gen(how_many_bytes): + time.sleep(0.1) + return Response( + os.read(urandom, how_many_bytes), + content_type="application/octet-stream") + + +if __name__ == "__main__": + app.run(host="0.0.0.0", port=80) diff --git a/store/Gemfile b/store/Gemfile new file mode 100644 index 0000000..1f2b6e6 --- /dev/null +++ b/store/Gemfile @@ -0,0 +1,3 @@ +source "https://rubygems.org" +gem 'sinatra' +gem 'nokogiri' diff --git a/store/Gemfile.lock b/store/Gemfile.lock new file mode 100644 index 0000000..1a445a8 --- /dev/null +++ b/store/Gemfile.lock @@ -0,0 +1,24 @@ +GEM + remote: https://rubygems.org/ + specs: + mini_portile2 (2.1.0) + nokogiri (1.7.0.1-x64-mingw32) + mini_portile2 (~> 2.1.0) + rack (1.6.5) + rack-protection (1.5.3) + rack + sinatra (1.4.7) + rack (~> 1.5) + rack-protection (~> 1.4) + tilt (>= 1.3, < 3) + tilt (2.0.5) + +PLATFORMS + x64-mingw32 + +DEPENDENCIES + nokogiri + sinatra + +BUNDLED WITH + 1.13.7 diff --git a/store/app.rb b/store/app.rb new file mode 100644 index 0000000..515bb40 --- /dev/null +++ b/store/app.rb @@ -0,0 +1,47 @@ +require 'sinatra' +require 'date' +require 'json' + +get '/' do + content_type :json + getData.to_json +end + +get '/store' do + begin + requestDate = DateTime.parse(params['dt']) + rescue + requestDate = DateTime.now + end + hashKey = "#{requestDate.year}-#{requestDate.month}-#{requestDate.day}-#{requestDate.hour}-#{requestDate.minute}-#{requestDate.second}" + puts hashKey + coinsInHash = DB.dbHash[hashKey] + if coinsInHash + coinsInHash = coinsInHash.next + else + puts "setting to zero" + coinsInHash = 0 + end + DB.dbHash[hashKey] = coinsInHash + content_type :json + getData.to_json +end + +def getData + dt = Time.now + datumHash = (0...60).to_a.map { |e| + dts = dt - e + key = "#{dts.year}-#{dts.month}-#{dts.day}-#{dts.hour}-#{dts.min}-#{dts.sec}" + data = DB.dbHash[key] || 0 + {date:dts, value: data} + } +end + +class DB +@@DateTimeHash = {} + +def self.dbHash + @@DateTimeHash +end + +end diff --git a/store/config.ru b/store/config.ru new file mode 100644 index 0000000..76a6edf --- /dev/null +++ b/store/config.ru @@ -0,0 +1,2 @@ +require './app' +run Sinatra::Application diff --git a/ui/.bowerrc b/ui/.bowerrc new file mode 100644 index 0000000..2f00fdf --- /dev/null +++ b/ui/.bowerrc @@ -0,0 +1,4 @@ +{ + "directory": "public/components", + "json": "bower.json" +} diff --git a/ui/.editorconfig b/ui/.editorconfig new file mode 100644 index 0000000..d1d8a41 --- /dev/null +++ b/ui/.editorconfig @@ -0,0 +1,10 @@ +# http://editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/ui/.gitignore b/ui/.gitignore new file mode 100644 index 0000000..815f6f8 --- /dev/null +++ b/ui/.gitignore @@ -0,0 +1,4 @@ +node_modules/ +public/components +.nyc_output +.sass-cache diff --git a/ui/.yo-rc.json b/ui/.yo-rc.json new file mode 100644 index 0000000..b41d150 --- /dev/null +++ b/ui/.yo-rc.json @@ -0,0 +1,10 @@ +{ + "generator-express": { + "promptValues": { + "type": "Basic", + "viewEngine": "EJS", + "cssPreprocessor": "None", + "buildTool": "Gulp" + } + } +} \ No newline at end of file diff --git a/ui/app.js b/ui/app.js new file mode 100644 index 0000000..6ddf083 --- /dev/null +++ b/ui/app.js @@ -0,0 +1,69 @@ + + +var express = require('express'); +var path = require('path'); +var favicon = require('serve-favicon'); +var logger = require('morgan'); +var cookieParser = require('cookie-parser'); +var bodyParser = require('body-parser'); + +var routes = require('./routes/index'); + +var app = express(); + +var env = process.env.NODE_ENV || 'development'; +app.locals.ENV = env; +app.locals.ENV_DEVELOPMENT = env == 'development'; + +// view engine setup + +app.set('views', path.join(__dirname, 'views')); +app.set('view engine', 'ejs'); + +// app.use(favicon(__dirname + '/public/img/favicon.ico')); +app.use(logger('dev')); +app.use(bodyParser.json()); +app.use(bodyParser.urlencoded({ + extended: true +})); +app.use(cookieParser()); +app.use(express.static(path.join(__dirname, 'public'))); + +app.use('/', routes); + +/// catch 404 and forward to error handler +app.use(function(req, res, next) { + var err = new Error('Not Found'); + err.status = 404; + next(err); +}); + +/// error handlers + +// development error handler +// will print stacktrace + +if (app.get('env') === 'development') { + app.use(function(err, req, res, next) { + res.status(err.status || 500); + res.render('error', { + message: err.message, + error: err, + title: 'error' + }); + }); +} + +// production error handler +// no stacktraces leaked to user +app.use(function(err, req, res, next) { + res.status(err.status || 500); + res.render('error', { + message: err.message, + error: {}, + title: 'error' + }); +}); + + +module.exports = app; diff --git a/ui/bin/www b/ui/bin/www new file mode 100644 index 0000000..f3ef100 --- /dev/null +++ b/ui/bin/www @@ -0,0 +1,8 @@ +#!/usr/bin/env node +var app = require('../app'); + +app.set('port', process.env.PORT || 3000); + +var server = app.listen(app.get('port'), function() { + console.log('Express server listening on port ' + server.address().port); +}); diff --git a/ui/bower.json b/ui/bower.json new file mode 100644 index 0000000..2ae9977 --- /dev/null +++ b/ui/bower.json @@ -0,0 +1,13 @@ +{ + "name": "ui", + "version": "0.0.1", + "ignore": [ + "**/.*", + "node_modules", + "components" + ], + "dependencies": { + "rickshaw": "^1.6.0", + "jquery": "^3.1.1" + } +} diff --git a/ui/gulpfile.js b/ui/gulpfile.js new file mode 100644 index 0000000..ff7bfae --- /dev/null +++ b/ui/gulpfile.js @@ -0,0 +1,26 @@ +var gulp = require('gulp'), + nodemon = require('gulp-nodemon'), + plumber = require('gulp-plumber'), + livereload = require('gulp-livereload'); + + +gulp.task('develop', function () { + livereload.listen(); + nodemon({ + script: 'bin/www', + ext: 'js ejs coffee', + stdout: false + }).on('readable', function () { + this.stdout.on('data', function (chunk) { + if(/^Express server listening on port/.test(chunk)){ + livereload.changed(__dirname); + } + }); + this.stdout.pipe(process.stdout); + this.stderr.pipe(process.stderr); + }); +}); + +gulp.task('default', [ + 'develop' +]); diff --git a/ui/package.json b/ui/package.json new file mode 100644 index 0000000..c3623d4 --- /dev/null +++ b/ui/package.json @@ -0,0 +1,32 @@ +{ + "name": "ui", + "version": "0.0.1", + "private": true, + "main": "app.js", + "scripts": { + "start": "node ./bin/www", + "test": "mocha --recursive test", + "test:coverage": "nyc npm test", + "test:unit": "mocha --recursive test/middleware test/models test/routes", + "test:integration": "mocha --recursive test/integration" + }, + "dependencies": { + "express": "^4.13.3", + "serve-favicon": "^2.3.0", + "morgan": "^1.6.1", + "cookie-parser": "^1.3.3", + "body-parser": "^1.13.3", + "ejs": "^2.3.1" + }, + "devDependencies": { + "chai": "^3.5.0", + "debug": "^2.2.0", + "gulp": "^3.9.0", + "gulp-nodemon": "^2.0.2", + "gulp-livereload": "^3.8.0", + "gulp-plumber": "^1.0.0", + "mocha": "^3.0.2", + "nyc": "^10.0.0", + "supertest": "^2.0.0" + } +} diff --git a/ui/public/css/style.css b/ui/public/css/style.css new file mode 100644 index 0000000..30e047d --- /dev/null +++ b/ui/public/css/style.css @@ -0,0 +1,8 @@ +body { + padding: 50px; + font: 14px "Lucida Grande", Helvetica, Arial, sans-serif; +} + +a { + color: #00B7FF; +} \ No newline at end of file diff --git a/ui/routes/index.js b/ui/routes/index.js new file mode 100644 index 0000000..e69aa52 --- /dev/null +++ b/ui/routes/index.js @@ -0,0 +1,10 @@ +var express = require('express'); +var router = express.Router(); + +/* GET home page. */ + +router.get('/', function(req, res) { + res.render('index', { title: 'Express' }); +}); + +module.exports = router; diff --git a/ui/views/error.ejs b/ui/views/error.ejs new file mode 100644 index 0000000..c2d4fa3 --- /dev/null +++ b/ui/views/error.ejs @@ -0,0 +1,7 @@ +<% include header %> + + <%- message %> + <%- error.status %> + <%- error.stack %> + +<% include footer %> \ No newline at end of file diff --git a/ui/views/footer.ejs b/ui/views/footer.ejs new file mode 100644 index 0000000..691287b --- /dev/null +++ b/ui/views/footer.ejs @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/ui/views/header.ejs b/ui/views/header.ejs new file mode 100644 index 0000000..6b11aa3 --- /dev/null +++ b/ui/views/header.ejs @@ -0,0 +1,12 @@ + + + + + + <%- title %> + + <% if (ENV_DEVELOPMENT) { %> + + <% } %> + + diff --git a/ui/views/index.ejs b/ui/views/index.ejs new file mode 100644 index 0000000..f437aef --- /dev/null +++ b/ui/views/index.ejs @@ -0,0 +1,47 @@ +<% include header %> + +

+

bitminer

+
+ + + + + + + +<% include footer %>