Code Monkey home page Code Monkey logo

Comments (10)

bneigher avatar bneigher commented on June 3, 2024 1

alternatively -- if you published a new release to npm I will be out of your hair! Putting together a release and would prefer using the nestjs module over the slack sdk manually. much appreciated 🙏

from nestjs-slack.

simenandre avatar simenandre commented on June 3, 2024

Thanks for posting this.

I love the idea of exposing the WebClient instance, for sure! Do you have an idea for how the API could look like?

from nestjs-slack.

simenandre avatar simenandre commented on June 3, 2024

#271 might be relevant here as well?

from nestjs-slack.

bneigher avatar bneigher commented on June 3, 2024

it's similar, but why not just allow for a getter like follows:

Just expose client instance on the class, where class is the WebClient. in this way we can just use all of the sdk modules like so:

import { Injectable } from '@nestjs/common'
import { SlackService } from 'nestjs-slack'

@Injectable()
export class MyService {
  constructor(
    private slackService: SlackService
  ) {}

async myFunction(email) {
  const userResponse = await this.slackService.client.users.lookupByEmail(<>) // .client
  return userResponse.user
}

I can see about making a MR if you think this approach is OK

from nestjs-slack.

bneigher avatar bneigher commented on June 3, 2024

I think all that needs to change is making client public actually:

export declare class SlackService<C = Channels> {
    private readonly options: SlackConfig;
    public readonly client: WebClient; // <-- HERE
    private readonly log: LogSync;
    constructor(options: SlackConfig, client: WebClient | null, log: LogSync | null);
    sendText(text: string, opts?: Omit<SlackMessageOptions<C>, 'text' | 'blocks'>): Promise<void>;
    sendBlocks(blocks: Readonly<SlackBlockDto>[], opts?: Omit<SlackMessageOptions<C>, 'blocks'>): Promise<void>;
    postMessage(req: SlackMessageOptions<C>): Promise<void>;
    private runApiRequest;
    private runWebhookRequest;
    private runStdoutRequest;
    private runGoogleLoggingRequest;
}

from nestjs-slack.

simenandre avatar simenandre commented on June 3, 2024

I like it! Let's try and see how that would look :)

Would love to see a MR/PR :)

from nestjs-slack.

bneigher avatar bneigher commented on June 3, 2024

#283

from nestjs-slack.

bneigher avatar bneigher commented on June 3, 2024

@cobraz 🙏

from nestjs-slack.

bneigher avatar bneigher commented on June 3, 2024

I think the double ^^ in your package.json is preventing me from installing the module directly from the repo:

❯ npm i --save https://github.com/bjerkio/nestjs-slack.git
npm ERR! code 1
npm ERR! git dep preparation failed
npm ERR! command /Users/benneigher/.nvm/versions/node/v18.12.1/bin/node /Users/benneigher/.nvm/versions/node/v18.12.1/lib/node_modules/npm/bin/npm-cli.js install --force --cache=/Users/benneigher/.npm --prefer-offline=false --prefer-online=false --offline=false --no-progress --no-save --no-audit --include=dev --include=peer --include=optional --no-package-lock-only --no-dry-run
npm ERR! npm WARN using --force Recommended protections disabled.
npm ERR! npm ERR! code EINVALIDTAGNAME
npm ERR! npm ERR! Invalid tag name "^^9.0.0" of package "@nestjs/platform-express@^^9.0.0": Tags may not have any characters that encodeURIComponent encodes.
npm ERR!
npm ERR! npm ERR! A complete log of this run can be found in:
npm ERR! npm ERR!     /Users/benneigher/.npm/_logs/2023-01-31T19_28_09_518Z-debug-0.log

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/benneigher/.npm/_logs/2023-01-31T19_27_59_836Z-debug-0.log

Specifically this line in package.json @nestjs/platform-express@^^9.0.0

from nestjs-slack.

zindont avatar zindont commented on June 3, 2024

+1 on publish a new version

from nestjs-slack.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.