小编pir*_*max的帖子

AWS-无服务器脱机框架上是否提供API密钥?

我使用无服务器脱机开发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

3
推荐指数
1
解决办法
756
查看次数

TypeORM - findAll 方法查找用户的所有文章

我想从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的替代方案。

typescript typeorm

3
推荐指数
1
解决办法
3万
查看次数

NestJS 管道 Joi.validate()(不是函数)

我尝试在带有管道的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 不是函数

hapijs nestjs

3
推荐指数
1
解决办法
3572
查看次数

不存在带有属性的 NuxtJS Auth 错误

我刚刚在我的项目中安装了@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)

我的 nuxt.config.ts

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 …

typescript nuxt.js

3
推荐指数
2
解决办法
3622
查看次数

PayPal PHP SDK 不适用于订阅,获取 RESOURCE_NOT_FOUND

我尝试使用 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

我不知道这一切意味着什么,遇到同样问题的人也没有得到支持。

在此输入图像描述

php paypal paypal-sandbox

3
推荐指数
1
解决办法
1769
查看次数

Nest 无法解析 AuthGuard(Guard 装饰器)的依赖关系

我有一个 AuthGuard,负责检查控制器中的 JWT 令牌。我想在控制器中使用这个 Guard 来检查身份验证。我有这个错误:

Nest 无法解析 AuthGuard (?, +) 的依赖项。请确保索引 [0] 处的参数在当前上下文中可用。

测试控制器.ts

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)

AuthGuard.ts …

node.js typescript nestjs

2
推荐指数
1
解决办法
2866
查看次数

WordPress 网站图标未显示在 Google Chrome 选项卡上

几周以来,我的网络杂志的图标不再显示,在我工作的浏览器上,也在我的个人电脑上。

我认为我没有更改配置。我尝试重新上传,但没有成功。

https://www.yubigeek.com/

在 Google Chrome 开发者控制台中,favicon.ico (404) 上有错误,但在页面的源代码中,未调用此 URL。

然而,有两个带有 rel =“icon” 的标签链接和图标的 URL,如果我单击链接,图像就在那里。

favicon wordpress

2
推荐指数
1
解决办法
5900
查看次数

NuxtJS - 在布局或组件中使用 asyncData 方法

我如何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)

typescript vue.js vue-component nuxt.js asyncdata

2
推荐指数
2
解决办法
8556
查看次数

使用 NuxtJS 和 AsyncData 方法从 URL 获取查询字符串值

我尝试获取 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 nuxt.js asyncdata

2
推荐指数
2
解决办法
3789
查看次数