目前我在当前站点(example.com/wordpress)的子文件夹中安装了WordPress .我如何使它可以从子域访问wordpress?
即我希望wordpress可以从这个地址访问:wordpress.example.com,并且所有的链接,帖子和页面仍然可以完美地工作,例如wordpress.example.com/my-wp-post/
如果它与主持人有所不同,我特别询问1&1.
谢谢
根据我对集合论的了解,当您取两个集合的并集时,您会覆盖两个集合并取结果集。当你取两个集合的交集时,你将两个集合重叠并取彼此重叠的部分。
对于数字,这很好用:
type SomeUnion = (1 | 2 | 3) | (2 | 3 | 4)
const someUnion: SomeUnion // typeof someUnion is 1 | 2 | 3 | 4
type SomeIntersect = (1 | 2 | 3) & (2 | 3 | 4)
const someIntersect: SomeIntersect // typeof someIntersect is 2 | 3
Run Code Online (Sandbox Code Playgroud)
对于对象键,在我看来,交集和联合操作的工作非常不直观。
type ObjUnion = { one: string, two: string } | { two: string, three: string }
const objUnionKeys: keyof ObjUnion // typeof objUnionKeys is 'two' …Run Code Online (Sandbox Code Playgroud) 我正在尝试将S3文件存储集成到我的NodeJS应用程序中.本教程解释了如何直接上传到S3非常好,但它不适合我的需要,因为我希望只能通过我的网络应用程序的API访问这些文件.我不希望文件在他们的S3网址上公开,我只是希望它们可以通过例如/api/files/<user_id>/<item_id>/<filename>.
我希望下载通过我的API的原因是我可以检查是否允许用户查看此特定文件.
我希望上传通过我的服务器的原因是我知道<item_id>分配文件名,因为这将与其MongoDB _id属性相同.如果我_id在第一个项目有Mongo之前将文件上传到S3,我就无法做到这一点.
我看过但是找不到一个简单的教程,如何通过我的NodeJS应用程序将文件从S3传输到客户端,反之亦然.
谢谢
TL;DR:如何让我的声明文件default在将其作为 ES6 模块导入时声明 MyModule 是导出,但module.exports在作为 commonjs 导入时声明它是对象?
我正在使用 Rollup 来捆绑我的模块,以便它可以作为 commonjs 和 ES6 模块导入。
// rollup.config.js
import ts from "rollup-plugin-typescript2";
export default {
input: "src/index.ts",
output: [
{
file: "dist/bundle.js",
format: "cjs"
},
{
file: "dist/bundle.es.js",
format: "es"
}
],
plugins: [ts({ clean: true })]
};
Run Code Online (Sandbox Code Playgroud)
在我的 package.json 中:
// package.json
{ ...
"main": "dist/bundle.js",
"module": "dist/bundle.es.js",
... }
Run Code Online (Sandbox Code Playgroud)
这是我的模块本身:
// src/index.ts
class MyModule {...}
export default MyModule;
Run Code Online (Sandbox Code Playgroud)
现在,我可以通过requireing 和importing成功导入这个模块:
// …Run Code Online (Sandbox Code Playgroud) 我有一个函数可以验证 JSON 响应以确保它对应于给定的形状。
这是我定义所有可能的 JSON 值的类型——取自https://github.com/microsoft/TypeScript/issues/1897#issuecomment-338650717
type AnyJson = boolean | number | string | null | JsonArray | JsonMap;
type JsonMap = { [key: string]: AnyJson };
type JsonArray = AnyJson[];
Run Code Online (Sandbox Code Playgroud)
现在我有一个函数来进行验证,给定要验证的对象和一个具有 shape 的模拟对象T。
function isValid<T extends AnyJson>(obj: AnyJson, shape: T): obj is T {
// ... implementation
}
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试使用接口和真实对象调用该函数时,我Thing在类型参数下收到类型错误
interface Response {
Data: Thing[]; // Thing is an interface defined elsewhere
};
isValid<Response>(data, { Data: [] })
// ^^^^^^^^
Run Code Online (Sandbox Code Playgroud)
Type 'Response' does not …Run Code Online (Sandbox Code Playgroud) 我正在尝试拦截第三方网站的获取事件并在 Chrome 扩展程序中修改其请求正文。事件处理程序不允许修改请求正文chrome.webRequest.onBeforeRequest。但看起来常规服务工作人员确实有能力侦听和修改 fetch 事件,并使用我自己的响应手动响应请求,这意味着我应该能够拦截请求,修改正文,将修改后的请求发送到API,然后使用我修改后的请求的响应来响应原始请求。
正如我在“网络”面板中看到的那样,尽管网站触发了大量的获取事件,但这些事件处理程序似乎都没有被触发。
// background.js
self.onfetch = (event) => console.log(event.request); // never shows
// or
self.addEventListener("fetch", (event) => {
console.log(event.request); // never shows
});
Run Code Online (Sandbox Code Playgroud)
console.log我可以通过查看Service Worker 控制台中出现的其他日志(顶级日志以及事件触发的日志)来"install"验证Service Worker 是否正在运行
// background.js
console.log(self); // works
self.addEventListener("install", (event) => {
console.log(event); // works
});
Run Code Online (Sandbox Code Playgroud)
提取事件处理程序是否不会被触发,因为出于安全原因不允许扩展服务工作人员访问这些事件处理程序?这是有道理的,我只是没有在任何地方明确地看到这个记录,所以最好知道这是否确实是一个平台限制或者我是否做错了什么。
如果这确实是扩展平台的限制,是否有其他方法可以使用 Chrome 扩展来修改第三方网站上的请求正文?
google-chrome-extension service-worker service-worker-events
从MongoDB数据库返回Mongoose文档时,您不能只编辑返回的文档.你需要通过.toObject()函数将它转换为普通的JavaScript对象- JSON.parse(JSON.stringify(doc))它还没有对我有用 - 或者它.
我的问题是为什么会这样?为什么它们不是默认返回简单,易用的JavaScript对象?
我一直在尝试创建一个由T值为字符串的类型键组成的类型.在伪代码中它会是keyof T where T[P] is a string.
我能想到的唯一方法是分两步:
// a mapped type that filters out properties that aren't strings via a conditional type
type StringValueKeys<T> = { [P in keyof T]: T[P] extends string ? T[P] : never };
// all keys of the above type
type Key<T> = keyof StringValueKeys<T>;
Run Code Online (Sandbox Code Playgroud)
然而,TS编译器说这Key<T>简直等于keyof T,即使我通过将它们设置为never使用条件类型来过滤掉其值不是字符串的键.
所以它仍然允许这样,例如:
interface Thing {
id: string;
price: number;
other: { stuff: boolean };
}
const key: Key<Thing> …Run Code Online (Sandbox Code Playgroud) 我认为新的VS Code调试器'use strict';在文件中停止的原因是由于新版本的Node中有些奇怪的贬损行为,或者是因为我的代码中有一些奇怪的错误。
然后我意识到“突破第一线”是一件事,也是人们想要的。为什么这是一件事?我知道我的脚本有第一行,非常感谢。如果没有的话,我会有更大的问题。那么调试器为什么需要这样做?
我在 Idris 源代码中到处都看到过它,但我还没有找到它的含义的解释。我得到的最接近的是发现它RigCount在语法参考中被调用。但它是什么?
test : (0 a : b) -> b
test x = x
-- ^^^ Error
Run Code Online (Sandbox Code Playgroud)
当上面的例子发生时,会抛出一个错误:While processing right hand side of test. x is not accessible in this context.
将其更改为 1 会进行类型检查,但不会进一步说明其含义。
test : (1 a : b) -> b
test x = x
Run Code Online (Sandbox Code Playgroud) 我收到此错误
[ts] Type '{ type: string; }' is not assignable to type 'A'.
Run Code Online (Sandbox Code Playgroud)
用下面的代码
interface Action {
type: string;
}
function requestEntities<A extends Action>(type: string) {
return function (): A {
return { type };
};
}
Run Code Online (Sandbox Code Playgroud)
为什么不能分配?Aextended Action,它只有一个属性:type,它是一个字符串。这是什么问题
是A可能具有更多属性的问题吗?那我怎么告诉TypeScript A仍然只有该type: string属性而没有别的呢?
编辑
仅供参考,我要添加泛型A的原因是因为A它将具有特定的字符串作为type属性,例如{ string: 'FETCH_ITEMS' }。
我尝试使用 EB CLI 创建新的 Elastic Beanstalk 环境,但由于选项无效而失败,即使我的配置中未设置该选项。
我正在运行的命令:
$ eb create my-new-environment -v --timeout 15
Run Code Online (Sandbox Code Playgroud)
我收到的错误:
2020-09-27 08:45:00 ERROR "option_settings" in one of the configuration files failed validation. More details to follow.
2020-09-27 08:45:00 ERROR Invalid option value: '1.0' (Namespace: 'aws:autoscaling:updatepolicy:rollingupdate', OptionName: 'MinInstancesInService'): You can't enable rolling updates for a single-instance environment.
2020-09-27 08:45:01 ERROR Failed to launch environment.
Run Code Online (Sandbox Code Playgroud)
但我没有aws:autoscaling:updatepolicy:rollingupdate在我的配置文件中指定!
# .ebextensions/settings.config
option_settings:
aws:elasticbeanstalk:managedactions:
ManagedActionsEnabled: true
PreferredStartTime: "Thu:04:00"
aws:elasticbeanstalk:managedactions:platformupdate:
UpdateLevel: minor
InstanceRefreshEnabled: true
aws:elasticbeanstalk:command:
DeploymentPolicy: AllAtOnce
aws:elasticbeanstalk:environment:
EnvironmentType: …Run Code Online (Sandbox Code Playgroud) 我试图在C中创建一副牌.我想要实现这个的方法是通过一个2维数组deck[51][1],每个将有52个插槽,每个插槽2个.第一个插槽将包含卡值(1-52),第二个插槽将包含套装(1-4).
我尝试使用以下代码分配:
int deck[51][1];
int i;
int j;
int suit = 1;
int main()
{
for(i=0; i<52; i++){
for(j=0; j<2; j++){
if(j==0){
deck[i][j] = i+1;
} else {
deck[i][j] = suit % 4;
}
suit++;
}
}
Run Code Online (Sandbox Code Playgroud)
然后我尝试使用以下双循环打印出每张卡的值:
for(i=0; i<52; i++){
for(j=0; j<2; j++){
printf("%i ",deck[i][j]);
}
printf("\n");
}
return 0;
Run Code Online (Sandbox Code Playgroud)
}
然而,它不是导致52行的卡片值,而是它的套装,它只是显示一个奇怪的
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
Run Code Online (Sandbox Code Playgroud)
等等,直到
51 52
52 0
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚为什么它没有将suit % 4 …
typescript ×5
mongodb ×2
node.js ×2
amazon-s3 ×1
arrays ×1
c ×1
commonjs ×1
ebcli ×1
es6-modules ×1
express ×1
generics ×1
idris ×1
idris2 ×1
javascript ×1
mapped-types ×1
mongoose ×1
subdomain ×1
wordpress ×1