我使用无服务器脱机开发Web项目。
我需要API密钥才能访问无服务器 AWS Lamda上的资源。
我的服务和提供者都有一个serverless.yml 。
在Postman中,我访问了我的路由(http://127.0.0.1:3333/segments/UUID/test),并且没有任何错误(如Forbidden message),Lambda已执行...
test:
handler: src/Api/segment.test
events:
- http:
path: segments/{segmentUuid}/test
method: post
request:
parameters:
paths:
segmentUuid: true
private: true
Run Code Online (Sandbox Code Playgroud)
该路由不受私有保护。
yaml aws-lambda serverless-framework serverless serverless-framework-offline
我想从TypeORM包中找到一位用户的所有文章。
在Sequelize上,我有这个:
async findAllByUser(userUuid: string, findOptions: object): Promise<Article[]> {
return await Article.findAll<Article>({
include: [{
model: User,
where: {
uuid: userUuid
}
}]
});
}
Run Code Online (Sandbox Code Playgroud)
我想要TypeORM的替代方案。
我尝试在带有管道的NestJS上使用 Joi 验证器。
https://docs.nestjs.com/pipes#object-schema-validation
import * as Joi from '@hapi/joi';
import { PipeTransform, Injectable, ArgumentMetadata, BadRequestException } from '@nestjs/common';
@Injectable()
export class JoiValidationPipe implements PipeTransform {
constructor(
private readonly schema: Joi.ObjectSchema,
) {}
transform(value: any, metadata: ArgumentMetadata) {
const { error } = Joi.validate(value, this.schema);
if (error) {
throw new BadRequestException('Validation failed');
}
return value;
}
}
Run Code Online (Sandbox Code Playgroud)
它不能正常工作。
类型错误:Joi.validate 不是函数
我刚刚在我的项目中安装了@nuxtjs/auth。
我Property '$auth' does not exist on type 'AuthLoginPage'
上课。
this.$auth.loginWith('local', {
data: {
username: 'your_username',
password: 'your_password'
}
});
Run Code Online (Sandbox Code Playgroud)
modules: [
// Doc: https://axios.nuxtjs.org/usage
'@nuxtjs/axios',
'@nuxtjs/auth',
'@nuxtjs/pwa',
],
...
auth: {
strategies: {
local: {
endpoints: {
login: {
url: 'http://127.0.0.1:3001/users/login',
method: 'post',
propertyName: 'token'
},
logout: {
url: 'http://127.0.0.1:3001/users/logout',
method: 'post'
},
user: {
url: 'http://127.0.0.1:3001/users/me',
method: 'get',
propertyName: 'user'
}
},
// tokenRequired: true,
// tokenType: 'bearer'
}
}
Run Code Online (Sandbox Code Playgroud)
我不可能使用 NuxtJS …
我尝试使用 PayPal 智能按钮在网站上进行付款。
我首先创建了一个计划,获取了它的 ID,然后通过 API 和 PHP 中的 PayPal SDK 命令激活了它。
该计划似乎正在积极进行。
<script src="https://www.paypal.com/sdk/js?client-id=sb-key&vault=true&disable-funding=card"></script>
<script>
paypal.Buttons({
env: 'sandbox',
createSubscription: function(data, actions) {
return actions.subscription.create({
'plan_id': 'P-85G86700MN...223CGEJWTI'
});
},
onApprove: function(data, actions) {
alert('You have successfully created subscription ' + data.subscriptionID);
}
}).render('#paypal-button-container');
</script>
Run Code Online (Sandbox Code Playgroud)
当我点击 PayPal 按钮付款时。我收到此错误:RESOURCE_NOT_FOUND
我不知道这一切意味着什么,遇到同样问题的人也没有得到支持。
我有一个 AuthGuard,负责检查控制器中的 JWT 令牌。我想在控制器中使用这个 Guard 来检查身份验证。我有这个错误:
Nest 无法解析 AuthGuard (?, +) 的依赖项。请确保索引 [0] 处的参数在当前上下文中可用。
import {
Controller,
Post,
Body,
HttpCode,
HttpStatus,
UseInterceptors,
UseGuards,
} from "@nestjs/common";
import { TestService } from "Services/TestService";
import { CreateTestDto } from "Dtos/CreateTestDto";
import { ApiConsumes, ApiProduces } from "@nestjs/swagger";
import { AuthGuard } from "Guards/AuthGuard";
@Controller("/tests")
@UseGuards(AuthGuard)
export class TestController {
constructor(
private readonly testService: TestService,
) {}
@Post("/create")
@HttpCode(HttpStatus.OK)
@ApiConsumes("application/json")
@ApiProduces("application/json")
async create(@Body() createTestDto: CreateTestDto): Promise<void> {
// this.testService.blabla();
}
}
Run Code Online (Sandbox Code Playgroud)
几周以来,我的网络杂志的图标不再显示,在我工作的浏览器上,也在我的个人电脑上。
我认为我没有更改配置。我尝试重新上传,但没有成功。
在 Google Chrome 开发者控制台中,favicon.ico (404) 上有错误,但在页面的源代码中,未调用此 URL。
然而,有两个带有 rel =“icon” 的标签链接和图标的 URL,如果我单击链接,图像就在那里。
我如何asyncData
在布局或组件中使用(显然是禁止的)?
因为我的侧边栏组件用于默认布局,我需要使用它asyncData
来显示来自后端的数据。如果我使用 Vuex 来获取数据......我不知道如何在每个页面上使用 global 来获取它。
@Component({
components: {
LeftDrawer
},
async asyncData({ app }) {
const latestPosts = await app.$axios.get(`/posts/latest`);
return {
latestPosts: latestPosts.data,
};
}
})
Run Code Online (Sandbox Code Playgroud) 我尝试获取 URL 中 name 参数的值:http://fakelocalhost:3000/page?name=test
我正在使用NuxtJS (v2.11.0) 和TypeScript,以及nuxt-property-decorator包 (v2.5.0)。
但是,我得到了一个未定义的结果console.log(params.name)
。
在这里,我的完整 TS 代码:
<script lang="ts">
import {
Component,
Vue
} from "nuxt-property-decorator";
@Component({
asyncData({ params }) {
console.log(params.name);
}
})
export default class extends Vue {}
</script>
Run Code Online (Sandbox Code Playgroud) typescript ×5
nuxt.js ×3
asyncdata ×2
nestjs ×2
aws-lambda ×1
favicon ×1
hapijs ×1
node.js ×1
paypal ×1
php ×1
serverless ×1
serverless-framework-offline ×1
typeorm ×1
vue.js ×1
wordpress ×1
yaml ×1