diff --git a/src/app.ts b/src/app.ts index 4f21747..dc42931 100644 --- a/src/app.ts +++ b/src/app.ts @@ -15,6 +15,10 @@ class ServerApp { console.log('Starting the server'); this.server = express(); + if (!process.env.API_KEY || !process.env.API_SECRET || !process.env.BUCKET_UUID) { + throw new Error('API_KEY, API_SECRET, or BUCKET_UUID is not set.'); + } + this._apiInst = new ApillonApi(process.env.API_KEY, process.env.API_SECRET); this.middlewares(); diff --git a/src/config/index.ts b/src/config/index.ts index dda32b8..77c51de 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -1,3 +1,3 @@ export * from './rateLimiter'; -export const port = process.env.PORT || 3000; +export const port = process.env.PORT || 6666; diff --git a/src/helpers/index.ts b/src/helpers/index.ts index e69de29..717b657 100644 --- a/src/helpers/index.ts +++ b/src/helpers/index.ts @@ -0,0 +1,5 @@ +import { createHash } from 'crypto'; + +export const sha256Hash = (input: string) => { + return createHash('sha256').update(input).digest('hex'); +} diff --git a/src/routes.ts b/src/routes.ts index 000c15a..644a543 100644 --- a/src/routes.ts +++ b/src/routes.ts @@ -1,5 +1,7 @@ import { Router } from 'express'; import { PlayableBuild } from './types'; +import { sha256Hash } from './helpers'; + const routes = Router(); routes.get('/', (req, res) => { @@ -21,7 +23,7 @@ routes.get('/available-builds', async (req, res) => { folders.map((i) => { return { name: i.name, - id: i.id, + id: sha256Hash(i.CID), }; }), );