This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import store from '@/store' | |
const nodeStatus = { | |
eventType: 'NODE_STATUS', | |
handle: function (event) { | |
const parsed = JSON.parse(event.data) | |
store.commit('nodes/updateNodeStatus', parsed) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
}) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import nodeStatus from './nodeStatus.js' | |
const Handlers = [ | |
nodeStatus | |
] | |
export default Handlers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var swaggerOptions = new SwaggerOptions(); | |
Configuration.GetSection(nameof(SwaggerOptions)).Bind(swaggerOptions); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.UseSwagger(option => { option.RouteTemplate = swaggerOptions.JsonRoute; }); | |
app.UseSwaggerUI(option => | |
{ | |
option.SwaggerEndpoint(swaggerOptions.UiEndpoint, swaggerOptions.Description); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Tweetbook.Options | |
{ | |
public class SwaggerOptions | |
{ | |
public string JsonRoute { get; set; } | |
public string Description { get; set; } | |
public string UiEndpoint { get; set; } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"SwaggerOptions": { | |
"JsonRoute": "swagger/{documentName}/swagger.json", | |
"Description": "Our API", | |
"UIEndpoint": "v1/swagger.json" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services.AddSwaggerGen(x => | |
{ | |
x.SwaggerDoc("v1", new OpenApiInfo{ Title = "Tweetbook API", Version = "v1" }); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using System.Threading.Tasks; | |
using Tweetbook.Domain; | |
namespace Tweetbook.Controllers.V1 | |
{ | |
public class PostsController : Controller | |
{ | |
private List<Post> _posts; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace Tweetbook.Domain | |
{ | |
public class Post | |
{ | |
public Guid Id { get; set; } | |
} | |
} |