Skip to content

Commit

Permalink
publish package
Browse files Browse the repository at this point in the history
  • Loading branch information
wjamilaion committed Oct 25, 2023
1 parent 2971534 commit 37ea421
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 3 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20'

- name: Install dependencies
run: npm install

- name: Run tests
run: npm test
26 changes: 26 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Publish to npm
on:
release:
types:
- published

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 20
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
run: npm ci

- name: Publish to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --access public
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@rubix/redis-connector",
"name": "@aiondigital/redis-connector",
"version": "1.0.0",
"description": "redis connector of all rubix services",
"description": "redis connector for NestJs based services",
"main": "dist/index.js",
"scripts": {
"test": "jest",
Expand All @@ -27,21 +27,24 @@
},
"homepage": "https://github.com/aiondigitalengineering/redis-connector#readme",
"devDependencies": {
"@nestjs/cache-manager": "^2.1.0",
"@nestjs/common": "^10.1.0",
"@nestjs/testing": "^10.1.0",
"@types/jest": "^29.5.3",
"@types/node": "^20.4.2",
"@typescript-eslint/eslint-plugin": "^6.1.0",
"eslint": "^8.45.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"ioredis": "^5.3.2",
"ioredis-mock": "^8.8.1",
"jest": "^29.6.1",
"prettier": "^3.0.0",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typescript": "^5.1.6"
},
"dependencies": {
"peerDependencies": {
"@nestjs/cache-manager": "^2.1.0",
"@nestjs/common": "^10.1.0",
"ioredis": "^5.3.2"
Expand Down
12 changes: 12 additions & 0 deletions src/redis-client/redis-client.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ export class RedisClientService implements OnModuleDestroy {
private readonly logger: Logger = new Logger(RedisClientService.name);

constructor(@Inject(CACHE_MANAGER) private cache: Cache) {}

redisClient() {
(this.cache.store as RedisStore).client;
}

onModuleDestroy() {
this.disconnect();
Expand Down Expand Up @@ -42,6 +46,14 @@ export class RedisClientService implements OnModuleDestroy {
return true;
}

async sadd(listName: string, member: string) {
(this.cache.store as RedisStore).client.sadd(listName, member);
}

async srem(listName: string, member: string) {
(this.cache.store as RedisStore).client.srem(listName, member);
}

async reset(): Promise<void> {
await this.cache.reset();
}
Expand Down

0 comments on commit 37ea421

Please sign in to comment.