3 Star 0 Fork 0

mirrors_thinktecture/nodejs-aspnetcore-webapi

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

Node.js Web API for .NET developers

This repository contains a Web API sample built with Node.js and ASP.NET Core 1.0. A Angular 2 client is used to communicate with the APIs. A lot of things in this repo are covered by a blog series.

Projects

Both Node.js and ASP.NET Core 1.0 APIs are split into two projects:

  • STS: Contains a Secure Token Service, which can generate and validate access tokens
  • Web API: Contains a Web API for manipulating customers.
    • The following methods are supported. All methods need a valid access token, otherwise it will return a 401 Unauthorized.
      • HTTP GET api/customer/list: Returns a list of all customers
      • HTTP POST api/customer: Creates a new customer
      • HTTP DELETE api/customer/{id}: Removes a customer
    • Swagger support via http://localhost:5000/swagger
    • Both project can either use an InMemory storage or a PostgreSQL backend. Per default, they use PostgreSQL.
      • Node.js:
        • Switch the service.configure(false) to true here
        • Additionally Node.js supports MongoDB which can be switched here
        • Default PostgreSQL settings:
          • Host: localhost
          • Database name: CustomerSampleNodejs
          • Username: CustomerSample
          • Password: CustomerSample
          • Can be configured in server/index.js
      • ASP.NET Core 1.0:
        • Switch the comments within ConfigureDI here
        • Default PostgreSQL settings:
          • Host: localhost
          • Database name: CustomerSampleVNext
          • Username: CustomerSample
          • Password: CUstomerSample
          • Can be configured in Startup.cs

You can either start both projects as Node.js or as ASP.NET Core 1.0. They won't work together, so you can not use Node.js STS and ASP.NET Core 1.0 Web API.

Setup

PostgreSQL

For a general admin UI to create users and databases, you can use pgAdmin, which works on all platforms.

OS X

The easiest way to use PostgreSQL on Mac OS X is by installing Postgres.app. Then use the pgAdmin to create the user and databases as shown above.

Windows

To install PostgreSQL on Windows you can use a graphical installer which can be downloaded here. It comes with pgAdmin, so you don't need to install it separately. After installation use pgAdmin to create the user and databases as shown above.

MongoDB

To install MongoDB, head over to the official website, download and install it regarding their documentation.

MongoDB is currently not supported for ASP.NET Core 1.0 Web API project, yet.

Node.js

  • Install Node.js > v5 .
  • Execute npm install within the root of this repository to install all necessary dependencies. You will encounter some npm err or npm warn. That's okay, since this repository uses a lot beta versions. It will not break the application.

ASP.NET Core 1.0

  • ASP.NET 5.
  • After installing ASP.NET 5 you need to execute dnu restore in src/aspNetCore/STS and src/aspNetCore/WebAPI.

Starting

Node.js

  • STS: To start STS execute node index.js in src/nodejs/STS. It will then be accessible via http://localhost:5001.
  • Web API: To start Web API execute node index.js in src/nodejs/WebAPI. It will then be accessible via http://localhost:5000.

ASP.NET Core 1.0

  • STS: To start STS execute dnx web in src/aspNetCore/STS. It will then be accessible via http://localhost:5001.
  • Web API: To start Web API execute dnx web in src/aspNetCore/WebAPI. It will then be accessible via http://localhost:5000.

Angular 2 Client

To start the Angular 2 Client, run npm run watch within the root of the repository. You can access the client via http://localhost:8000. The credentials are

  • Username: bob
  • Password: bob

Since both backends lack a support for user management, those credentials are the only one which are working.

Presentation

If you want to start the presentation yourself, you need to spin up a static http server (like node-static) in the presentation directory.

Third-Party Libraries

This section contains notable third-party libraries.

General

Node.js

ASP.NET Core 1.0

Angular 2 Client

Contributors

  • ppa-pawe: Added Node.js MongoDB support

Additional resources

空文件

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_thinktecture/nodejs-aspnetcore-webapi.git
git@gitee.com:mirrors_thinktecture/nodejs-aspnetcore-webapi.git
mirrors_thinktecture
nodejs-aspnetcore-webapi
nodejs-aspnetcore-webapi
master

搜索帮助