小编dew*_*wey的帖子

NestJS 控制器未映射

所以我有一个将部署在 docker 容器中的 API。这个 API 有authentications控制器,简单而不特别。

当我在本地机器上以开发模式启动 API 时,将找到 auth 控制器并且一切正常。在我的本地机器上构建和运行它也是如此。但是当我对项目进行 dockerize 并在虚拟机上运行它时,我将无法访问 auth 控制器。每个其他控制器都在工作,但 auth 控制器不存在。

查看 docker 日志,不会映射任何身份验证控制器。本地和构建的 docker 镜像都应该包含相同的项目文件。

身份验证控制器:

import {
  Controller,
  Post,
  Delete,
  UseGuards,
  Request,
  Body,
} from '@nestjs/common';

import { AuthenticationsService } from './authentications.service';
import { JwtAuthGuard } from '../shared/guards/jwtAuth.guard';
import { SignInDTO } from './dtos/addGraphNodeToGraphByGraphId.dto';

@Controller('authentications')
export class AuthenticationsController {
  constructor(
    private readonly authenticationsService: AuthenticationsService,
  ) {}

  @Post()
  public signIn(@Body() { username, password }: SignInDTO): Promise<string> {
    return this.authenticationsService.signIn(username, password);
  } …
Run Code Online (Sandbox Code Playgroud)

javascript docker typeorm nestjs

10
推荐指数
3
解决办法
2150
查看次数

VSCode Prettier 没有格式化 PHP

所以我用 Prettier 设置了 vscode,但它不会格式化 .php 文件。.html 文件与 Prettier 一起工作正常。所以当我有一个带有 HTML 代码的 .php 时,它的格式会有所不同,因为我使用 Beautify 作为最后一个选项。

如何让 Prettier 自动格式化 .php 文件并且 .php 中的 html 代码与 .html 文件相同?

设置.json

{
  "sync.autoDownload": true,
  "sync.autoUpload": true,
  "sync.forceDownload": true,
  "sync.forceUpload": true,
  "workbench.iconTheme": "vscode-icons",
  "sync.gist": "715bf022af486e449cae9313183b9a56",
  "sync.quietSync": true,
  "typescript.updateImportsOnFileMove.enabled": "always",
  "window.zoomLevel": 0,
  "vetur.format.defaultFormatter.js": "vscode-typescript",
  "vetur.format.defaultFormatter.ts": "vscode-typescript",
  "eslint.codeActionsOnSave.mode": "all",
  "workbench.colorTheme": "Atom One Dark",
  "beautify.language": {
    "html": ["php", "blade"]
  },
  // These are all my auto-save configs
  "editor.formatOnSave": true,
  // turn it off for JS and JSX, we …
Run Code Online (Sandbox Code Playgroud)

html php eslint visual-studio-code prettier

10
推荐指数
4
解决办法
2万
查看次数

当应用程序/ JSON发送数据时抛出错误

我想通过来通过身体发送数据application/json。这是我的要求: 请求数据的图像

但是有了这个我只能得到:

如果请求实体的内容类型不是application / x-www-form-urlencoded,则使用@FormParam

错误图片

我的代码:

<cffunction name="createInstance" access="remote" returntype="any" produces="application/json" httpmethod="POST" restpath="/instances">
   <cfargument name="customerId" required="true" restArgSource="form" type="string" default=""/>
   <cfargument name="name" required="true" restArgSource="form" type="string" default=""/>
   <cfargument name="datasource" required="false" restArgSource="form" type="string" default=""/>
   <cfargument name="startDate" required="true" restArgSource="form" type="string" default=""/>
   <cfargument name="expirationDate" required="false" restArgSource="form" type="string" default=""/>
   <cfargument name="amount" required="true" restArgSource="form" type="numeric" default=-1/>

   <cfreturn name>
</cffunction>
Run Code Online (Sandbox Code Playgroud)

rest coldfusion

8
推荐指数
1
解决办法
268
查看次数

表格排序日期不正确

预期:我将从返回的 API 中获取日期时间字符串。该值"2019-08-15T15:58:14.597Z"应在表格中显示为`DD-MM-YYYY HH:MM。Vuetify 自带数据表组件,可以对数据进行升序和降序排序。我还想将此功能用于日期,使其升序和降序排序。

简短的问题:API 中的日期应保存并以表格中的另一种“样式”显示,但排序功能使用实际日期对象。

我目前的代码:

<template>
    <v-content class="mt-12 ml-12">
        <h1 class="font-weight-black display-3">Servers</h1>

        <v-data-table
            class="elevation-1"
            :headers="headers"
            :items="columns"
            :items-per-page="15"
        >
        </v-data-table>

        <ul id="example-1">
            <li v-for="(data, index) in columns.data" :key="index">
                {{ data.attributes }}
            </li>
        </ul>
    </v-content>
</template>

<script>
import instances from '../services/instances';

export default {
  data() {
    return {
      columns: [],
      headers: [
        { text: 'Server Name', value: 'attributes.name' },
        { text: 'Spieler', value: 'attributes.playerCount' },
        { text: 'Avg. FPS', value: 'attributes.details.rust_fps_avg' },
        { text: 'Wiped', value: 'attributes.details.rust_last_wipe' …
Run Code Online (Sandbox Code Playgroud)

date vue.js vuetify.js

6
推荐指数
1
解决办法
3283
查看次数

使用Bootstrap在Vue中创建导航抽屉

我想创建一个带有侧菜单的基本管理面板。它应该看起来像这样:https : //vuetifyjs.com/en/examples/layouts/baseline

到目前为止,我已经做到了:

window.onload = () => {
  new Vue({
    el: '#app',
    data() {
      return {
        name: 'BootstrapVue',
        show: true
      }
    },
  })
}
Run Code Online (Sandbox Code Playgroud)
body {
  padding-top: 57px;
}
Run Code Online (Sandbox Code Playgroud)
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<script src="//unpkg.com/bootstrap-vue@2.0.2/dist/bootstrap-vue.js"></script>
<script src="//unpkg.com/babel-polyfill/dist/polyfill.min.js"></script>
<link href="//unpkg.com/bootstrap-vue@2.0.2/dist/bootstrap-vue.css" rel="stylesheet" />
<link href="//unpkg.com/bootstrap@4.3.1/dist/css/bootstrap.min.css" rel="stylesheet" />

<div id="app">
  <div>
    <b-navbar variant="dark" type="dark" fixed="top">
      <b-navbar-brand href="#">NavBar</b-navbar-brand>
    </b-navbar>
    <b-container fluid>
      <b-row>
        <b-col cols="2" class="pl-0">
          <b-nav vertical class="bg-light border-right position-fixed">
            <b-nav-item>
              This topic is way too long to be displayed correctly!
            </b-nav-item>
          </b-nav>
        </b-col> …
Run Code Online (Sandbox Code Playgroud)

vue.js bootstrap-4 bootstrap-vue

6
推荐指数
0
解决办法
90
查看次数

MongoDB最佳实践-一对多关系

根据这篇文章,我应该嵌入一个“引用”:MongoDB关系:嵌入还是引用?

User.js

const mongoose = require('mongoose');

const Schema = mongoose.Schema;

const userSchema = new Schema({
    email: {
        type: String,
        required: true
    },
    password: {
        type: String,
        required: true
    },
    createdEvents: ['Event']
});

module.exports = mongoose.model('User', userSchema);
Run Code Online (Sandbox Code Playgroud)

Event.js

const mongoose = require('mongoose');

const Schema = mongoose.Schema;

const eventSchema = new Schema({
    title: {
        type: String,
        required: true
    },
    description: {
        type: String,
        required: true
    },
    price: {
        type: Number,
        required: true
    },
    date: {
        type: Date,
        required: true …
Run Code Online (Sandbox Code Playgroud)

javascript mongoose mongodb

5
推荐指数
0
解决办法
43
查看次数

关系在 TypeGraphQL 中无法正常工作(您需要为...提供显式类型)

我想在 TypeGraphQL 中创建用户和文档之间的简单关系。所以一个用户可以创建无限的文档,而一个文档只有一个创建者。但我收到一个错误。

用户

import { Entity, PrimaryGeneratedColumn, Column, BaseEntity, OneToMany } from "typeorm";
import { Field, ID, ObjectType } from "type-graphql";

import { Doc } from "./Doc";

@ObjectType()
@Entity()
export class User extends BaseEntity {
    @Field(() => ID)
    @PrimaryGeneratedColumn()
    id: number;

    @Field()
    @Column()
    firstName: string;

    @Field()
    @Column()
    lastName: string;

    @Field()
    @Column()
    nickname: string;

    @Field()
    @Column("text", { unique: true })
    email: string;

    @Column()
    password: string;

    @Field({ nullable: true })
    @Column()
    created: Date;

    @Field()
    @Column()
    gender: string;

    @OneToMany(() => Doc, doc …
Run Code Online (Sandbox Code Playgroud)

javascript graphql typeorm typegraphql

5
推荐指数
1
解决办法
2230
查看次数

NestJS 最小化 dockerfile

我想dockerize我的nestjs api。使用下面列出的配置,图像变得 319MB 大。有什么比多阶段更简单的减小图像大小的方法?

文件

FROM node:12.13-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
CMD npm start
Run Code Online (Sandbox Code Playgroud)

.dockerignore

.git
.gitignore
node_modules/
dist/
Run Code Online (Sandbox Code Playgroud)

docker dockerfile nestjs

5
推荐指数
1
解决办法
1244
查看次数

返回 JSON 对象

有没有办法通过 ColdFusion 中的函数返回真实的 JSON 对象?我当前的解决方案是将查询转换为字符串,并在另一个 CF 文件中将其转换回 JSON 对象:

<cffunction name="addLicense" access="remote" returntype="string" returnFormat="JSON" httpmethod="POST">
  <cfquery datasource="hostmanager" name="createCustomer">
    SELECT * FROM license
  </cfquery>
  <cfreturn serializeJSON(createCustomer)>
</cffunction>
Run Code Online (Sandbox Code Playgroud)

rest coldfusion json cfml

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

pbkdf2返回128个字符而不是64个字符的哈希

我想在创建用户时创建密码哈希并将其存储到我的数据库中。我的数据库密码列存储的哈希值为64个字符(nvarchar(64))。我的哈希配置:

const byteAmount: number = Number(process.env.BYTE_AMOUNT) || 16;
const iterations: number = Number(process.env.ITERATIONS) || 100;
const length: number = Number(process.env.LENGTH) || 64;
const algorithm: string = process.env.ALGORITHM || 'sha512';
const conversion: string = process.env.CONVERSION || 'Hex';
Run Code Online (Sandbox Code Playgroud)

当哈希用户纯文本密码时,我使用此功能

public hashPassword = (password: BinaryLike, passwordSalt: BinaryLike): string => {
    const { iterations, length, algorithm }: { iterations: number, length: number, algorithm: string } = passwordConfig;
    const passwordHash: string = pbkdf2Sync(password, passwordSalt, iterations, length, algorithm).toString(passwordConfig.conversion);
    return passwordHash;
}
Run Code Online (Sandbox Code Playgroud)

不幸的是,哈希函数返回具有128个字符的密码哈希。是否可以定义哈希长度,还是总是返回128个字符长的哈希?

javascript cryptography pbkdf2 node.js cryptojs

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