GithubHelp home page GithubHelp logo

bunblog.api's People

Stargazers

 avatar

Watchers

 avatar  avatar

bunblog.api's Issues

CI support

Add CI support:

  • Prepare .msbuild and .pubxml file (21cf5e4)
  • Travis-CI for Linux/OS X runtime
  • AppVeyor for Windows runtime (932da67)
  • Run unit test in Travis-CI and AppVeyor (bec7fd4)

Popup notification

Add popup notification by Kendo Notification

  • Triggered by JavaScript
  • Triggered by ASP.NET MVC TempData

Migration to .net core 3.0.0-preview9

  • Migration to .net core 3.0.0-preview9
  • GET /informations: Add system version(such as Debian 9, Windows 10) and runtime version(3.0.0-preview9) to the response body

Implement read and write blog function

  • Database design
  • Use ASP.NET Core MVC implement write blog function
  • Use ASP.NET Core Web API to provide Restful API and implement get blogs function
  • Use Angular4 implement show all blogs function

GET /posts/{id} returned an error

2020-04-19 21:51:06.0855||ERROR|ExceptionHandler|url: http://localhost/api/posts/7|action: |0HLV4C5EMHMUA:00000004| AutoMapper.AutoMapperMappingException: Error mapping types.

Mapping types:
Post -> BlogPostModel
BunBlog.Core.Domain.Posts.Post -> BunBlog.API.Models.Posts.BlogPostModel

Type Map configuration:
Post -> BlogPostModel
BunBlog.Core.Domain.Posts.Post -> BunBlog.API.Models.Posts.BlogPostModel

Destination Member:
MetadataList

 ---> System.InvalidOperationException: A second operation started on this context before a previous operation completed. This is usually caused by different threads using the same instance of DbContext. For more information on how to avoid threading issues with DbContext, see https://go.microsoft.com/fwlink/?linkid=2097913.
   at Microsoft.EntityFrameworkCore.Internal.ConcurrencyDetector.EnterCriticalSection()
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.Enumerator.MoveNext()
   at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.Load[TSource](IQueryable`1 source)
   at Microsoft.EntityFrameworkCore.Internal.EntityFinder`1.Load(INavigation navigation, InternalEntityEntry entry)
   at Microsoft.EntityFrameworkCore.Internal.LazyLoader.Load(Object entity, String navigationName)
   at Microsoft.EntityFrameworkCore.Proxies.Internal.LazyLoadingInterceptor.Intercept(IInvocation invocation)
   at Castle.DynamicProxy.AbstractInvocation.Proceed()
   at Castle.Proxies.PostProxy.get_MetadataList()
   at lambda_method(Closure , PostProxy , BlogPostModel , ResolutionContext )
   --- End of inner exception stack trace ---
   at lambda_method(Closure , PostProxy , BlogPostModel , ResolutionContext )
   at lambda_method(Closure , Object , Object , ResolutionContext )
   at BunBlog.API.Controllers.PostsController.GetAsync(Int32 id) in E:\Project\Github\BunBlog.API\src\BunBlog.API\Controllers\PostsController.cs:line 91
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)

Add multiple database support

At the beginning of the project, BunBlog only supports postgresql(#5), but in the future it will support multiple databases.

  • PostgreSQL
  • SQL Server
  • MySQL

Post Meta - "Visits"

Web API

  • Get metas Web API
  • Get single meta Web API
  • Get posts Web API returns visits
  • Get post detail Web API return visits

Web

  • Post list shows visits
  • Post detail shows visits

Url.RouteUrl() question

Route:

    app.UseMvc(routes =>
    {
        routes
            .MapRoute(
                name: "Web",
                template: "{controller=Home}/{action=Index}"
            )
            .MapAdminRoute();
    });

Area route:

    public static class IRouteBuilderExtensions
    {
        public static IRouteBuilder MapAdminRoute(this IRouteBuilder routeBuilder)
        {
            return routeBuilder
                    .MapAdminAreaRoute(
                        name: "Admin",
                        url: "{controller=Dashboard}/{action=Index}/{id?}"
                    )
                    .MapAdminAreaRoute(
                        name: "Dashboard",
                        url: "Dashboard",
                        defaults: new { controller = "Dashboard", action = "Index" }
                    )
                    .MapAdminAreaRoute(
                        name: "PostList",
                        url: "Post/{action}",
                        defaults: new { controller = "Post", action = "List" }
                    )
                    .MapAdminAreaRoute(
                        name: "EditPost",
                        url: "Post/Edit/{id:int}",
                        defaults: new { controller = "Post", action = "Edit" }
                    );
        }

        private static IRouteBuilder MapAdminAreaRoute(this IRouteBuilder routeBuilder, string name, string url)
        {
            return routeBuilder.MapAdminAreaRoute(name, url, null /* defaults */);
        }

        private static IRouteBuilder MapAdminAreaRoute(this IRouteBuilder routeBuilder, string name, string url, object defaults)
        {
            return routeBuilder.MapAreaRoute(name, "Admin", "Admin/" + url, defaults);
        }
    }

/Home/Index:

@* returns null *@
@Url.RouteUrl("Dashboard")

/Admin/Post/List:

@* returns /Post/List *@
@Url.RouteUrl("Web")

Why 😞 😞

完善 /authentication 下的功能

  • 实现通过 refresh_thoek 获取新 token 功能
    • 仍然使用 POST /authentication/token 协议
    • 请求时需要像调用其它需要授权的接口一样,将 access_token 放置在 Authorization 头中。后台仍然需要验证该 access_token 除有效期外的合法性,并从中获取用户名
    • 请求体 {"grant_type": "refresh_token", "refresh_token": "{{refresh_token}}"}
    • 响应内容与通过 password 获取 token 时一致
    • refresh_thoek 刷新后,原 refresh_thoek 将失效
  • 实现登出接口
    • 新增 GET /authentication/endsession 协议
    • 请求时需要授权
    • 成功返回 204
    • 登出后,原 access_token 将失效
  • 实现获取用户信息接口
    • 新增 GET /authentication/user 协议
    • 请求时需要授权
    • 成功返回 200 { userName: "user_id" }

Modify linkName of tag and category, returns 400

When change the linkName with PUT /api/tags/{linkName} and PUT /api/categories , always returns a 400 error.

Request: PUT /api/tags/test

{
    "linkName": "test-a",    <-- use a different linkName
    "displayName": "test tag"
}

Response:

{
    "type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
    "title": "Bad Request",
    "status": 400,
    "traceId": "0HLOQGN6QSAOG:00000004"
}

Why MsDeploySkipRules not work?

https://docs.microsoft.com/zh-cn/aspnet/core/publishing/web-publishing-vs#excluding-files

I want to skip wwwroot\lib folder, and use <MsDeploySkipRules>. I add

<ItemGroup>
  <MsDeploySkipRules Include="CustomSkipFolder">
    <ObjectName>dirPath</ObjectName>
    <AbsolutePath>wwwroot\lib</AbsolutePath>
  </MsDeploySkipRules>
</ItemGroup>

to Bun.Blog.Web.csproj, but it doesn't work, wwwroot\lib still be published.

But <Content> is possible:

  <ItemGroup>
    <Content Update="wwwroot/lib/**/*.*" CopyToPublishDirectory="Never" />
  </ItemGroup>

I want to know why <MsDeploySkipRules> not work ❓

Site links api

  • Add table SiteLink
  • GET /siteLinks
  • GET /siteLinks/{id}
  • POST /siteLinks
  • PUT /siteLinks/{id}
  • DELETE /siteLinks/{id}
  • cache

Blog settings api

  • Add Setting table
  • Store the setting definition in a json file blogSettingResources.json. This design can easily add setting items without modifying the program. If we want to use the new settings in the UI, just modify the file directly.
  • GET /settings Get settings list
  • PUT /settings/{code} Modify the specified settings

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.