Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 11:06
    Romakita commented #1125
  • 10:54
    jappyjan assigned #1125
  • 10:54
    jappyjan labeled #1125
  • 10:54
    jappyjan opened #1125
  • 09:51
    trailblazer2006 commented #1115
  • 09:08
    Romakita labeled #1124
  • 09:08
    Romakita commented #1124
  • 08:59
    Romakita commented #1115
  • 08:58
    Romakita commented #1115
  • 08:58
    Romakita commented #1115
  • 08:57
    Romakita closed #1124
  • 08:50
    Romakita synchronize #1124
  • 08:45
    Romakita synchronize #1124
  • 08:24
    Romakita opened #1124
  • 07:00
    stale[bot] closed #933
  • Nov 29 18:41
    jappyjan edited #1123
  • Nov 29 18:40
    jappyjan labeled #1123
  • Nov 29 18:40
    jappyjan assigned #1123
  • Nov 29 18:40
    jappyjan opened #1123
  • Nov 29 16:52
    trailblazer2006 commented #1115
Artur
@arturrozputnii
        @QueryParams('sort') sort: String[],

parse ok, but swagger is ugly

backend: [ 'id,asc', 'name,desc' ]

trying your last solution

Romain Lenzotti
@Romakita
No… String => string. String class isn’t a valid type in typescript
After, it’s possible to set custom Swagger schema definition for the parameter. we can see that tomorrow :)
Artur
@arturrozputnii

it works now, strange, but yesterday no

@QueryParams('sort', String) sort: string[]

log: backend: [ 'id,asc', 'name,desc' ]
swagger ui looks good

thx:)
it doesn't when you send one sort parameter
{
  "name": "AJV_VALIDATION_ERROR",
  "message": "Bad request on parameter \"request.query.sort\".\nAt undefined, value 'id,asc' should be array",
  "status": 400,
  "errors": [
    {
      "keyword": "type",
      "dataPath": "",
      "schemaPath": "#/type",
      "params": {
        "type": "array"
      },
      "message": "should be array",
      "schema": "array",
      "parentSchema": {
        "type": "array",
        "items": {
          "type": "string"
        }
      },
      "data": "id,asc",
      "collectionName": "Array"
    }
  ],
  "stack": "PARAM_VALIDATION_ERROR: Bad request on parameter \"request.query.sort\".\nAt undefined, value 'id,asc' should be array\n    at Function.from (/Users/artur/projects_ub/ubicoin/packages/backend/node_modules/@tsed/common/src/platform/errors/ParamValidationError.ts:19:21)\n    at handleError (/Users/artur/projects_ub/ubicoin/packages/backend/node_modules/@tsed/common/src/platform/services/PlatformHandler.ts:336:36)\n    at /Users/artur/projects_ub/ubicoin/packages/backend/node_modules/@tsed/common/src/platform/services/PlatformHandler.ts:343:14\n    at processTicksAndRejections (internal/process/task_queues.js:97:5)\n    at /Users/artur/projects_ub/ubicoin/packages/backend/node_modules/@tsed/common/src/platform/services/PlatformHandler.ts:341:15\n    at async Promise.all (index 4)\n    at PlatformExpressHandler.onRequest (/Users/artur/projects_ub/ubicoin/packages/backend/node_modules/@tsed/common/src/platform/services/PlatformHandler.ts:159:16)"
}
that's why i was chose only one string yesterday
use every time sort by two fields ;)
Romain Lenzotti
@Romakita
I just realised you can do that just by using a Model with @QueryParam.
I written a Gist with full integration test to help you:
https://gist.github.com/Romakita/2dd599b6905a08ab0301414599c3858a
Artur
@arturrozputnii
awesome, gonna try this, thx
Joe Garlick
@icabbi-joegarlick

I have another weird issue with returning an array of numbers:

[
  53.33319239999999,
  -1.5494472
]

Is being returned as:

[
  { },
  { }
]

Any ideas what would cause this? When breakpointing I can see in the variable that the object is correct but when I see the response in postman its wrong

lorenzomacdonald
@lorenzomacdonald

Anyone an idea how to access your socketservice from another localhost:4200 (Angular)?

This is the code from my appcomponent:

import { Component, OnInit } from '@angular/core';
import io from 'socket.io-client';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
  private socket: any;
  public data: any;

  constructor() {
    // Connect Socket with server URL
    this.socket = io('ws://127.0.0.1:8083',{
    path:"/socket.io/chat",  
    transports: ["websocket"]
    });


  }
  public ngOnInit(): void {
    this.socket.on('Message', data => {
      this.data = data;
    });
  }
}

Do we need to setup extra things on the server side apart from what the docs say?

import { Inject, InjectorService } from '@tsed/di';
import {Args, Emit, Input, IO, Namespace, Nsp, Socket, SocketService, SocketSession} from "@tsed/socketio";
import * as SocketIO from "socket.io";
import { ChatService } from './ChatService';

@SocketService("/chat")
export class ChatSocketService {

  // private chatService : ChatService|undefined;

  // @Inject()
  // injector: InjectorService;

  // $onInit() {
  //    this.chatService = this.injector.get<ChatService>(ChatService)
  // }  

  @Nsp nsp: SocketIO.Namespace;


  constructor(@IO private io: SocketIO.Server) {
    console.log("test");
  }



//   sendMessage(id:string, message:string){
//     this.chatService?.replyMessage(id,message);
//     console.log("reply");
// }

// replyMessage(id:string, message:string){
//       this.chatService?.replyMessage(id,message);
//       console.log("reply");
//   }

  /**
   * Triggered the namespace is created
   */
  $onNamespaceInit(nsp: SocketIO.Namespace) {
    console.log("Namespace created");

  }

  /**
   * Triggered when a new client connects to the Namespace.
   */
  $onConnection(@Socket socket: SocketIO.Socket, @SocketSession session: SocketSession) {
      console.log("client connected");
  }

  /**
   * Triggered when a client disconnects from the Namespace.
   */
  $onDisconnect(@Socket socket: SocketIO.Socket) {

  }

  @Input("Message")
  myMethod(@Args(0) message: string, @Socket socket: Socket, @Namespace nsp: Namespace){
    console.log("Message");
  }

}
Romain Lenzotti
@Romakita
@icabbi-joegarlick Have you the latest version of v6. Can you give me more details

I tested that:

  @Get("/scenario12")
  public testScenario12() {
    return [53.33319239999999, -1.5494472];
  }

It works with the latest version

@lorenzomacdonald Instead of create your socket in app component, you should create the socket instance in an injectable service.
@Injectable() // 
export class SocketService {
   private socket: any;

  constructor() {
    // Connect Socket with server URL
    this.socket = io('ws://127.0.0.1:8083',{
        path:"/socket.io/chat",  
        transports: ["websocket"]
    });
  }
  on<T = any>(msg): Promise<T> {
    return new Promise((resolve) => this.socket.on(msg, resolve))
  } 
}
Romain Lenzotti
@Romakita
Then inject the server in your different components
You can look on this module also: https://www.npmjs.com/package/ngx-socket-io
Joe Garlick
@icabbi-joegarlick

Hi @Romakita Im using: 6.10.2

    "@tsed/common": "^6.10.2",
    "@tsed/core": "^6.10.2",
    "@tsed/di": "^6.10.2",
    "@tsed/exceptions": "^6.10.2",
    "@tsed/json-mapper": "^6.10.2",
    "@tsed/platform-express": "^6.10.2",
    "@tsed/swagger": "^6.10.2",

When in VSCode debugging I see this output on the return:
image
However when I press continue this is what I get in postman:
image2

Pavel
@freez10
@Romakita is it a know issue that one can not init new project with tsed-cli using npm as the package manager?
And it case tsed-cli is installed globally you are not prompted to chose the package manager (no idea why), so it defaults to npm so you can not init new project at all %)
Romain Lenzotti
@Romakita
Yes, yesterday I released two fix after it to solve the problem with NPM and the proxy
The prompt is only proposed if you have Yarn and NPM
7768
@7768
Hi, dumb question. It is possible to have the PlatformLogMiddleware log the request json in a single line instead of multiple lines?
Romain Lenzotti
@Romakita
Yes in production mode the log is in only one line.
In dev mode, is in multiple to be more readable
Barys Yakavita
@borisbsu
image.png
how to inject TSED service into typeorm entity listener?
Pavel
@freez10

Tank you @Romakita

The prompt is only proposed if you have Yarn and NPM

Hm.. I have tsed-cli installed with yarn and I have npm as well but I'm not prompted with PM selection. So probably another small bug. Maybe too small and hard to reproduce to worry about it :)

Romain Lenzotti
@Romakita
@freez10 v2.5.1 will fix the issue
7768
@7768

Yes in production mode the log is in only one line.

Hm.. is this the right way to launch in production mode? NODE_ENV=production node build/index.js
still getting multiple lines...

Romain Lenzotti
@Romakita
Capture d’écran 2020-11-22 à 14.31.10.png
For me it works.
Idem with a compiled app
ITninja04
@ITninja04
Hello everyone. I'm having trouble setting the GraphQL Context for my users. Normal auth works through the regular controllers, but for the life of me I cannot figure out how to expose the user context through to Apollo. Has anyone been able to pull this off?
Joe Garlick
@jcbjoe
For my issue above It was due to using the @Returns decorator thanks for the help @Romakita
Romain Lenzotti
@Romakita
Hello @ITninja04
This question must be addressed to TypeGraphql team ^^
haa sorry
@ITninja04 I don’t know, I don’t know really how the Apollo server works
And without a code example, I can’t help you :)
ITninja04
@ITninja04
I have a pretty good idea of how it works, the problem though is I cannot seem to pull my user out of DI
Pavel
@freez10
@Romakita hello! Just one thought I'd like to share with you :) Would be really great to have a possibility to do something like
@MinLength(6).CustomValidationMessage('My custom message about the password length')
password: string
Romain Lenzotti
@Romakita
Humm… It could be possible if Ajv allow this usage.
Because message validation is generated by Ajv not by Ts.ED itself
@freez10 Can you check if ajv is able to do that, and open an enhancement request on github please :)

Hello everybody I added a new template issue to get your feedback over the Ts.ED Framework. It would be great if you took the time to fill in this feedback. This will add content to the website and promote the framework based on your reviews.

It’s here: https://github.com/TypedProject/tsed/issues/new/choose
Then click on « Say thank you » and fill the issue ;)

Also: Ts.ED had his a dedicated twitter account https://twitter.com/TsED_io !!!

Romain Lenzotti
@Romakita
2 replies
Romain Lenzotti
@Romakita
Yes I moved the board to the organization level.
https://github.com/orgs/TypedProject/projects/1