-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
621cad4
commit 4a634c8
Showing
14 changed files
with
123 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
coverage* | ||
node_modules | ||
dist | ||
Dockerfile* | ||
docker-compose* | ||
.dockerignore | ||
.editorconfig | ||
.env | ||
.git | ||
.gitignore | ||
.DS_Store | ||
.vscode | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
FROM oven/bun:alpine | ||
|
||
ENV PORT= | ||
ENV DATABASE_URL= | ||
ENV ACCESS_TOKEN_AGE= | ||
ENV ACCESS_TOKEN_SECRET= | ||
|
||
LABEL maintainer="adeiskandarzulkarnaen@gmail.com" | ||
LABEL description="A Docker image for a Bun HONO application" | ||
LABEL version="1.0" | ||
|
||
WORKDIR /app | ||
|
||
COPY . . | ||
|
||
RUN bun install | ||
RUN bunx prisma generate | ||
|
||
EXPOSE $APP_PORT/tcp | ||
|
||
CMD ["sh", "-c", "bun run migrate:up && bun run start:dev"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
abstract class CacheServer { | ||
abstract set(key: string, value: string): Promise<void>; | ||
abstract get(key: string): Promise<string>; | ||
abstract delete(key:string): Promise<unknown>; | ||
}; | ||
|
||
export default CacheServer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { createClient, RedisClientType } from 'redis'; | ||
import CacheServer from '@applications/cache/CacheServer'; | ||
|
||
|
||
|
||
class RedisCacheServer implements CacheServer{ | ||
private client: RedisClientType; | ||
constructor() { | ||
this.client = createClient({ | ||
socket: { | ||
host: process.env.REDIS_HOST, | ||
} | ||
}); | ||
|
||
this.client.on('error', (error) => console.error(error)); | ||
this.client.connect(); | ||
} | ||
|
||
public async set(key: string, value: string, expirationInSecond = 1800) : Promise<void> { | ||
await this.client.set(key, value, { | ||
EX: expirationInSecond, | ||
}); | ||
} | ||
|
||
public async get(key: string): Promise<string> { | ||
const result = await this.client.get(key); | ||
if (!result) throw new Error('Cache tidak ditemukan'); | ||
return result; | ||
} | ||
|
||
public async delete(key: string): Promise<number> { | ||
return this.client.del(key); | ||
} | ||
}; | ||
|
||
export default RedisCacheServer; |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// const fs = require('fs'); | ||
|
||
// class StorageService { | ||
// constructor(folder) { | ||
// this._folder = folder; | ||
|
||
// if (!fs.existsSync(folder)) { | ||
// fs.mkdirSync(folder, { recursive: true }); | ||
// } | ||
// } | ||
|
||
// writeFile(file, meta) { | ||
// const filename = +new Date() + meta.filename; | ||
// const path = `${this._folder}/${filename}`; | ||
|
||
// const fileStream = fs.createWriteStream(path); | ||
|
||
// return new Promise((resolve, reject) => { | ||
// fileStream.on('error', (error) => reject(error)); | ||
// file.pipe(fileStream); | ||
// file.on('end', () => resolve(filename)); | ||
// }); | ||
// } | ||
|
||
// deleteFile(url) { | ||
// const filename = url.split('/').pop(); | ||
// const path = `${this._folder}/${filename}`; | ||
// fs.unlink(path, () => { | ||
// console.log('gagal menghapus, file tidak ditemukan'); | ||
// }); | ||
// } | ||
// } | ||
|
||
// module.exports = StorageService; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters