avrahamcool / aleph1.skeletons Goto Github PK
View Code? Open in Web Editor NEWVSIX for Visual Studio 2017. that will add new Project Templates.
Home Page: https://marketplace.visualstudio.com/items?itemName=Aleph1.Aleph1SkeletonsWebAPIPackage
VSIX for Visual Studio 2017. that will add new Project Templates.
Home Page: https://marketplace.visualstudio.com/items?itemName=Aleph1.Aleph1SkeletonsWebAPIPackage
using SqlExpress requires additional installation.
by adding this target to the csproj - we can create a backup of the old project before publishing a new one.
cap the number of backups.
maybe move the backups and logs to a different folder on the machine?
activityID is changed when returning from an async operation.
we should use a custom field to maintain a reliable CorrelationID.
in globalASAX
HttpContext.Current.Items["CorrelationID"] = Guid.NewGuid();
---------------
in config
<column name="CorrelationID" layout="${aspnet-item:variable=CorrelationID}" />
---------------
install: NLog.web
<add xdt:Transform="SetAttributes" xdt:Locator="Match(key)" key="EnableCORS" value="false" />
<add xdt:Transform="Remove" xdt:Locator="Match(key)" key="Origins" />
<add xdt:Transform="Remove" xdt:Locator="Match(key)" key="Headers" />
<add xdt:Transform="Remove" xdt:Locator="Match(key)" key="Methods" />
<add xdt:Transform="Remove" xdt:Locator="Match(key)" key="ExposedHeaders" />
JSON outputted by WebAPI should be camelCase
d to accommodate with javascript standards.
input parameter should allow both camelCase
and PascalCase
.
replace it with:
IDependencyScope DI = actionContext.Request.GetDependencyScope();
ISecurity SecurityService = DI.GetService(typeof(ISecurity)) as ISecurity;
possible solution: check if still active before opening popup
X-XSS-Protection security header should be set to 0 by default in web.config, see:
PublishUrl = new Uri(Path.Combine(Directory.GetCurrentDirectory(), PublishUrl)).LocalPath;
if (!Directory.Exists(PublishUrl))
{
LogMessage = "Directory " + PublishUrl + " not found - Skipping Backup.";
return true;
}
const int MAX_BACKUPS = 3;
string backupFolder = new Uri(Path.Combine(PublishUrl, "./Backup")).LocalPath;
string LogsFolder = new Uri(Path.Combine(PublishUrl, "./Logs")).LocalPath;
string[] pathsToExclude = new[] { backupFolder, LogsFolder };
IEnumerable<FileInfo> filesToBackup = new DirectoryInfo(PublishUrl)
.EnumerateFiles("*", SearchOption.AllDirectories)
.Where(file => pathsToExclude.All(toExclude => !file.FullName.StartsWith(toExclude)));
DateTime? lastUpdatedFileDate = filesToBackup
.Select<FileInfo, DateTime?>(file => file.LastWriteTime)
.DefaultIfEmpty()
.Max();
if (!lastUpdatedFileDate.HasValue)
{
LogMessage = "Directory " + PublishUrl + " was empty - Skipping Backup.";
return true;
}
Directory.CreateDirectory(backupFolder);
string backupName = lastUpdatedFileDate.Value.ToString(@"yyyy-MM-dd HH.mm.ss");
Uri backupZipPathUri = new Uri(Path.Combine(backupFolder, backupName + ".zip"));
if (File.Exists(backupZipPathUri.LocalPath))
{
LogMessage = "Backup " + backupZipPathUri.AbsoluteUri + " already exists - Skipping Backup.";
}
else
{
string backupPath = Path.Combine(backupFolder, backupName);
Directory.CreateDirectory(backupPath);
foreach (FileInfo item in filesToBackup)
{
string newPath = item.FullName.Replace(PublishUrl, backupPath);
Directory.CreateDirectory(Directory.GetParent(newPath).FullName);
item.CopyTo(item.FullName.Replace(PublishUrl, backupPath));
}
ZipFile.CreateFromDirectory(backupPath, backupZipPathUri.LocalPath);
Directory.Delete(backupPath, true);
FileInfo[] oldBackups = new DirectoryInfo(backupFolder)
.GetFiles("*.zip");
foreach (FileInfo oldBackup in oldBackups
.OrderBy(file => file.CreationTime)
.Take(oldBackups.Length - MAX_BACKUPS))
{
oldBackup.Delete();
}
LogMessage = "Backup created at " + backupZipPathUri.AbsoluteUri;
}
foreach (FileInfo file in filesToBackup)
{
file.Delete();
}
IEnumerable<DirectoryInfo> directoriesToDelete = new DirectoryInfo(PublishUrl)
.EnumerateDirectories("*", SearchOption.TopDirectoryOnly)
.Where(dir => pathsToExclude.All(toExclude => !dir.FullName.StartsWith(toExclude)));
foreach (DirectoryInfo dir in directoriesToDelete)
{
dir.Delete(true);
}
return true;
as of FluentValidation v9, they no longer support .net Framework
for example:
different targets for some functions?
maybe not needed if we change the attribute to use diferrent logger per class - then it can be done from config without changing anything avrahamcool/Aleph1#5
different log level? [trace, warn etc'..?] what for?
we look for X-FORWARD-FOR
header instead of X-FORWARDED-FOR
the skeleton packs extra directories that should be removed before publishing.
bin
obj
logs
lookout for more..
add :blob
where we have :data
to ease the process of uploading the project to source control.
<system.webServer>
<modules>
<remove name="WebDAVModule" />
</modules>
<handlers>
<remove name="WebDAV" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
<httpProtocol>
<customHeaders>
<clear />
</customHeaders>
</httpProtocol>
<security>
<requestFiltering>
<hiddenSegments>
<add segment="Logs"/>
<add segment="Backup"/>
<add segment="Documentation"/>
</hiddenSegments>
</requestFiltering>
</security>
</system.webServer>
<system.net>
<settings>
<servicePointManager expect100Continue="false" />
</settings>
</system.net>
the versions above 16.7.9 compile with warnings because we also target vs2017.
vs2017 is crucial at this point.
when creating a new layer, it should be added to the selected folder.
TS will be handled by client stack.
IdleTimeOut package adds a default "mousewheel" event to the window.
this is somehow interfering with input of type number. (scrolling on a number type causes the numbers to change.)
can be fix by patching the library.
need more investigation.
CORS from config?
make sure application loads with correct defaults.
the gui for creating new layer should open with the deafult name starting with the namespace.
Create a Models folder, and AboutModel file.
and make it a random guid
need to remove proxy project from webapi template.json
turns out it's a lot easier to add code to a Layer, if you already have some files you can simply rename.
thanks @avivday.
not even sure if this is possible.
<DocumentationFile>..\Output\$(Configuration)\Documentation\ProjName.xml</DocumentationFile>
Use AssemblyName instead of literal name
Content Security Policy header should contain the following values:
default-src 'none';
base-uri 'none';
object-src 'none';
frame-ancestors 'none';
connect-src 'self' https://www.google.com;
script-src 'self' 'strict-dynamic' 'sha256-CHANGE_THIS' https://www.google.com https://www.gstatic.com;
style-src 'self' https://www.gstatic.com 'unsafe-inline';
frame-src 'self' https://www.google.com;
img-src 'self' data: blob: https://www.gstatic.com;
font-src 'self' data: blob: https://fonts.gstatic.com;
worker-src 'self' https://www.google.com https://www.gstatic.com;
child-src 'self' https://www.google.com https://www.gstatic.com;
media-src 'self';
form-action 'self';
require-trusted-types-for 'script'
Google reCAPTCHA URLs are included and will work by default.
Also, please note that in order to @import
fonts from Google Fonts, you should add https://fonts.googleapis.com
to style-src
.
References:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.