Skip to content

Commit

Permalink
feat: add heroku ci
Browse files Browse the repository at this point in the history
  • Loading branch information
William Koller committed Apr 27, 2022
1 parent 9598706 commit 8bb2b69
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 3 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/heroku.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: 'Production'

on:
push:
branchs:
- main
- master
pull_request:
- main
- master

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]
mongodb-version: [4.2]
redis-version: [4, 5, 6]

steps:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Start MongoDB
uses: supercharge/mongodb-github-action@1.1.0
with:
mongodb-version: ${{ matrix.mongodb-version }}

- name: Start Redis
uses: supercharge/redis-github-action@1.4.0
with:
redis-version: ${{ matrix.redis-version }}

- name: Install dependencies
run: yarn --frozen-lockfile
1 change: 1 addition & 0 deletions src/modules/cache/cache.settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { CachesRepository } from './repositories/caches.repository';
export const imports = [
BaseCacheModule.register({
url: process.env.REDIS_URL,
isGlobal: true,
}),
];

Expand Down
10 changes: 7 additions & 3 deletions src/modules/cache/repositories/caches.repository.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { GET_BOOKS_CACHE_KEY } from '@/modules/cache/constants/books-cache-key.constant';
import { CACHE_MANAGER, Inject, Injectable } from '@nestjs/common';
import { Cache } from 'cache-manager';

@Injectable()
export class CachesRepository {
constructor(@Inject(CACHE_MANAGER) private readonly cacheManager: Cache) {}
constructor(@Inject(CACHE_MANAGER) private readonly cacheManager) {
const client = cacheManager.store.getClient();
client.on('err', (err) => {
console.info(err);
});
}
async clearCache(): Promise<void> {
const keys: string[] = await this.cacheManager.store.keys();

Expand All @@ -20,6 +24,6 @@ export class CachesRepository {
}

async getCache(name: string): Promise<number> {
return await this.cacheManager.get<number>(name);
return await this.cacheManager.get(name);
}
}

0 comments on commit 8bb2b69

Please sign in to comment.