diff --git a/README.md b/README.md index 0fdaaf8..22fba4b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,21 @@ -# Awesome Project Build with TypeORM +# Clonegur -Steps to run this project: +Created by TopchetoEU -1. Run `npm i` command -2. Setup database settings inside `data-source.ts` file -3. Run `npm start` command +## Technologies: + +- Deno +- Angular +- My brainz + +## What is this? + +This is exactly what the title sells it for - it's an imgur clone (but kinda worse). + +## How to use? + +Currently, we only have a backend, which can be easily run via the command (in the main directory): + +```sh +$ deno run -A src/index.ts +``` diff --git a/src/index.ts b/src/index.ts index d966344..bcffa0b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,8 +1,18 @@ import { MongoClient } from "https://deno.land/x/mongo@v0.31.2/mod.ts"; import { RootRouter } from "./routers/RootRouter.ts"; +import * as bcrypt from "https://deno.land/x/bcrypt@v0.4.1/mod.ts"; export default async function clonegur() { - const salt = new TextDecoder().decode(await Deno.readFile('keys/salt.txt')); + let salt; + + try { + salt = new TextDecoder().decode(await Deno.readFile('keys/salt.txt')); + } + catch { + salt = await bcrypt.genSalt(); + await Deno.writeFile('keys/salt.txt', new TextEncoder().encode(salt)); + } + const db = await new MongoClient().connect({ db: 'clonegur', servers: [ { host: '127.0.0.1', port: 27017 } ]