Skip to content

Instantly share code, notes, and snippets.

View ntakouris's full-sized avatar
🤖
Building robots

Theodoros Ntakouris ntakouris

🤖
Building robots
View GitHub Profile
import store from '@/store'
const nodeStatus = {
eventType: 'NODE_STATUS',
handle: function (event) {
const parsed = JSON.parse(event.data)
store.commit('nodes/updateNodeStatus', parsed)
}
}
import Handlers from './handlers'
export default function configureEventSources () {
const eventSource = new EventSource(ApiRoutes.EventSource)
for (const handler of Handlers) {
eventSource.addEventListener(handler.eventType, event => {
handler.handle(event)
})
}
}
import nodeStatus from './nodeStatus.js'
const Handlers = [
nodeStatus
]
export default Handlers
var swaggerOptions = new SwaggerOptions();
Configuration.GetSection(nameof(SwaggerOptions)).Bind(swaggerOptions);
app.UseSwagger(option => { option.RouteTemplate = swaggerOptions.JsonRoute; });
app.UseSwaggerUI(option =>
{
option.SwaggerEndpoint(swaggerOptions.UiEndpoint, swaggerOptions.Description);
});
namespace Tweetbook.Options
{
public class SwaggerOptions
{
public string JsonRoute { get; set; }
public string Description { get; set; }
public string UiEndpoint { get; set; }
}
"SwaggerOptions": {
"JsonRoute": "swagger/{documentName}/swagger.json",
"Description": "Our API",
"UIEndpoint": "v1/swagger.json"
}
services.AddSwaggerGen(x =>
{
x.SwaggerDoc("v1", new OpenApiInfo{ Title = "Tweetbook API", Version = "v1" });
}
using System;
using System.Linq;
using System.Threading.Tasks;
using Tweetbook.Domain;
namespace Tweetbook.Controllers.V1
{
public class PostsController : Controller
{
private List<Post> _posts;
using System;
namespace Tweetbook.Domain
{
public class Post
{
public Guid Id { get; set; }
}
}