How to exclude entity field from returned by controller JSON. NestJS + Typeorm

I’d suggest creating an interceptor that takes advantage of the class-transformer library: @Injectable() export class TransformInterceptor implements NestInterceptor { intercept( context: ExecutionContext, call$: Observable<any>, ): Observable<any> { return call$.pipe(map(data => classToPlain(data))); } } Then, simply exclude properties using @Exclude() decorator, for example: import { Exclude } from ‘class-transformer’; export class User { id: number; email: … Read more

Heroku + node.js: I have a server which uses multiple ports. How can I get Heroku to allocate them?

Okay, after doing some research I’ve found out that opening ports in Heroku is disabled and not allowed. The only way around this is to use sub-domains and then in-app to use a proxy module (like subdomain-router which I use). BUT – Heroku don’t let you create sub-domains on their domain, meaning that your-app.herokuapp.com is … Read more

how to list rooms on socket.io nodejs server

The short answer: io.sockets.adapter.rooms I analysed io: I got the following output: { server: { stack: [ [Object], [Object], [Object], [Object], [Object], [Object] ], connections: 3, allowHalfOpen: true, watcher: { host: [Circular], callback: [Function] }, _events: { request: [Function], connection: [Function: connectionListener], listening: [Object], upgrade: [Object] }, httpAllowHalfOpen: false, cache: {}, settings: { home: “https://stackoverflow.com/”, … Read more

“npm install” installs all dependencies in node_modules directory, instead of having them nested

Update: As Erik Pukinskis mentioned in the comments: As of npm 3.5, support for –legacy-bundling has been dropped. Yes, there is a way to have nested directories again by changing npm’s (version 3 as of this writing) default behaviour: Delete the currently present node_modules folder. Tell npm to install with legacy bundling for this one … Read more

React app error: Failed to construct ‘WebSocket’: An insecure WebSocket connection may not be initiated from a page loaded over HTTPS

For folks waiting for react-scripts for a patch: For local testing over https, you can manually edit node_modules/react-dev-utils/webpackHotDevClient.js Here’s the code you’ll want at line 62 of that file: protocol: window.location.protocol === ‘https:’ ? ‘wss’ : ‘ws’, For deployment follow below steps: npm install -g serve // This can be done locally too npm run … Read more

Nodemailer/Gmail – What exactly is a refresh token and how do I get one?

Notes by this answer original’s author: So, I finally managed to figure it out. I’m surprised I couldn’t find more ressources about that so for those who need to use Gmail with Nodemailer I found the answer here: http://masashi-k.blogspot.fr/2013/06/sending-mail-with-gmail-using-xoauth2.html Try creating a new User if you already had one and things ain’t working fine. It … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)