Skip to content

Instantly share code, notes, and snippets.

View Odonno's full-sized avatar
🏠
Working from home

David Bottiau Odonno

🏠
Working from home
View GitHub Profile
@Odonno
Odonno / HealthChecks.cs
Created June 8, 2020 13:18
.NET Core Azure Templates - HealthChecks
services.AddHealthChecks()
.AddUrlGroup(new Uri("https://login.microsoftonline.com"), "azure ad")
.AddUrlGroup(new Uri("https://graph.microsoft.com"), "graph api")
.AddSignalRHub(() => CreateSignalrHubConnection(healthCheckConfig["SignalR:Values"]), "signalr hub - values");
services.AddHealthChecksUI();
@Odonno
Odonno / appsettings.json
Last active June 8, 2020 13:14
.NET Core Azure Templates - appsettings.json
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*",
"HealthChecks-UI": {
"HealthChecks": [
{
@Odonno
Odonno / AppInsights.cs
Created June 8, 2020 13:11
.NET Core Azure Templates - AppInsights
services.AddApplicationInsightsTelemetry();
services.AddLogging(config =>
{
config.AddApplicationInsights();
});
@Odonno
Odonno / GraphApiService.cs
Created June 8, 2020 13:11
.NET Core Azure Templates - GraphApiService
public interface IGraphApiService
{
Task<User> GetCurrentProfileAsync();
Task<IEnumerable<User>> SearchUsersAsync(string search, int limit);
Task<IEnumerable<User>> GetUsersAsync(IEnumerable<string> userIds);
}
@Odonno
Odonno / AzureAd.cs
Created June 8, 2020 13:10
.NET Core Azure Templates - AzureAd
var authSettings = configuration.GetSection("AzureAd").Get<AzureAdOptions>();
services
.AddAuthentication(sharedOptions =>
{
sharedOptions.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddJwtBearer(options =>
{
options.Audience = authSettings.ClientId;
@Odonno
Odonno / SignalR.cs
Created June 8, 2020 13:08
.NET Core Azure Templates - SignalR
if (env.IsDevelopment())
{
services.AddSignalR().AddNewtonsoftJsonProtocol();
}
else
{
string azureSignalrConnectionString = configuration["Azure:SignalR:ConnectionString"];
services.AddSignalR().AddNewtonsoftJsonProtocol().AddAzureSignalR(options =>
{
@Odonno
Odonno / recoil.hooks.ts
Created June 1, 2020 09:34
State management comparison - recoil - hooks
export const useTodos = () => useRecoilValue(todoListState);
export const useLoadTodos = () =>
useRecoilCallback(
async ({ set }) => {
const response = await fetch(`${apiUrl}/todos`);
const results = await response.json();
return set(todoListState, results);
},
[]
@Odonno
Odonno / recoil.atoms.ts
Created June 1, 2020 09:34
State management comparison - recoil - atoms
export const todoListState = atom<Todo[]>({
key: 'todolist',
default: [],
});
@Odonno
Odonno / mobx.context.ts
Created June 1, 2020 09:33
State management comparison - mobx - StoreContext
const StoreContext = createContext<TodoList>({} as TodoList);
type StoreContextProviderProps = {
children?: ReactNode;
};
export const StoreProvider = ({ children }: StoreContextProviderProps) => {
const todoList = new TodoList();
return (
@Odonno
Odonno / mobx.models.ts
Created June 1, 2020 09:32
State management comparison - mobx - Models
export class TodoList {
@observable.shallow list: Todo[] = [];
constructor() {
autorun(() => {
this.load();
});
}
@action