我正在写一个Angular 6图书馆,无法弄清楚如何进入打字稿.
我用以下方法生成了应用: ng new mylibapp
然后我使用以下方法添加了库: ng g library @abc/cool-lib -p abc
当我表演时: ng build @abc/cool-lib
它会在mylibapp/dist/abc/cool-lib文件夹中生成代码
我现在如何调试此代码并在位于的ts文件中设置断点 mylibapp/projects/abc/cool-lib/src/lib
我正在尝试在我的角度npm包中创建我认为称为辅助入口点的东西。我想要以下两个切入点
@scope/data-service
@scope/data-service/models
Run Code Online (Sandbox Code Playgroud)
使用angular-cli生成基本包会生成以下结构
scope
????data-service
? karma.conf.js
? ng-package.json
? ng-package.prod.json
? package.json
? tsconfig.lib.json
? tsconfig.spec.json
? tslint.json
?
????src
? public_api.ts
? test.ts
?
????lib
data-service.component.spec.ts
data-service.component.ts
data-service.module.ts
data-service.service.spec.ts
data-service.service.ts
Run Code Online (Sandbox Code Playgroud)
根据ng-packagr 文档,您可以在名为datas的数据服务下添加一个文件夹,然后package.json在该文件夹中添加第二个文件夹,但是ng-packagr似乎使用的结构与angular-cli略有不同。理想情况下,我正在尝试对类似于https://github.com/angular/angular/tree/master/packages/common的结构进行建模,但只要公开了@scope/data-service,@scope/data-service/models我就会很高兴。
当我尝试创建类似于ng-packager建议的结构时,我得到了
error TS6059: File 'C:/projects/data-service-app/projects/scope/data-service/models/src/index.ts' is not under 'rootDir' 'C:\projects\data-service-app\projects\scope\data-service\src'. 'rootDir' is expected to contain all source files.
当我将models目录移动到data-service\src目录中时,我的入口点是
@scope/data-service
@scope/data-service/src/models
Run Code Online (Sandbox Code Playgroud)
如何摆脱二级入口上的src?
使用angular-cli时,使用辅助入口点创建库的正确方法是什么?
在TypeScript中创建winston记录器的正确方法是什么,它将记录快速摩根中间件记录?我找到了许多JavaScript示例,但是将它们转换为TypeScript时遇到了麻烦,因为我收到了错误Type '{ write: (message: string, encoding: any) => {}; logger: any; }' is not assignable to type '(options?: any) => ReadableStream'. Object literal may only specify known properties, and 'write' does not exist in type '(options?: any) => ReadableStream'.
这是我的代码:
import { Logger, transports } from 'winston';
// http://tostring.it/2014/06/23/advanced-logging-with-nodejs/
// https://www.loggly.com/ultimate-guide/node-logging-basics/
const logger = new Logger({
transports: [
new (transports.Console)({
level: process.env.NODE_ENV === 'production' ? 'error' : 'debug',
handleExceptions: true,
json: false,
colorize: true
}),
new (transports.File)({
filename: 'debug.log', …Run Code Online (Sandbox Code Playgroud) 我试图找出修补对象集合的最佳方法.我试图改变许多对象的排序顺序,并认为jsonpatch可能是正确的方法.我的对象看起来像:
[
{
"ID": "100",
"FirstName": "John",
"LastName": "Smith",
"Email": "jsmith@test.com",
"SortOrder": 1
},
{
"ID": "125",
"FirstName": "John",
"LastName": "Doe",
"Email": "jdoe@test.com",
"SortOrder": 3
},
{
"ID": "50",
"FirstName": "james",
"LastName": "johnson",
"Email": "jjohnson@test.com",
"SortOrder": 2
},
]
Run Code Online (Sandbox Code Playgroud)
我创建了一个端点,允许补丁请求使用jsonpatch请求更新集合中的多个对象,如下所示:
[
{
"op": "replace",
"path": "/1/SortOrder",
"value": 2
},
{
"op": "replace",
"path": "/0/SortOrder",
"value": 1
},
{
"op": "replace",
"path": "/2/SortOrder",
"value": 3
}
]
Run Code Online (Sandbox Code Playgroud)
我想要做的是使用jsonpatch路径中的ID属性.我目前的对象结构可能吗?它看起来像:
[
{
"op": "replace",
"path": "/125/SortOrder",
"value": 2
},
{
"op": "replace",
"path": …Run Code Online (Sandbox Code Playgroud) 我一直在努力使用nginx和supervisor在EC2 ubuntu实例上运行几个asp.net核心web应用程序。我一次可以成功运行一个应用程序,只需在nginx设置中交换端口并重新加载即可在运行于5000和5001的正在运行的.netcore应用程序之间进行交换。在一个路径上工作,即:主机名/应用1,主机名/应用2。
这是我的Nginx Config。谁能指出我做错了什么?我的主管正在运行两个应用程序,我可以通过查看日志并在默认位置“ /”中更改端口来进行验证。
server {
listen 80 default_server;
listen [::]:80 default_server;
# location / {
# proxy_pass http://localhost:5000;
# proxy_http_version 1.1;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection keep-alive;
# proxy_set_header Host $host;
# proxy_cache_bypass $http_upgrade;
# }
location /app1 {
rewrite ^/app1(.*) /$1 break;
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /app2{
rewrite ^/app2(.*) /$1 break;
proxy_pass http://localhost:5001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header …Run Code Online (Sandbox Code Playgroud) angular ×2
angular-cli ×2
ng-packagr ×2
typescript ×2
asp.net-core ×1
c# ×1
json ×1
json-patch ×1
morgan ×1
nginx ×1
node.js ×1
winston ×1