generate salt if salt.txt doesnt exist, add readme

This commit is contained in:
TopchetoEU 2023-06-27 06:25:34 +03:00
parent cd4738377b
commit 21bcf5c5ac
No known key found for this signature in database
GPG Key ID: 24E57B2E9C61AD19
2 changed files with 30 additions and 6 deletions

View File

@ -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
```

View File

@ -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 } ]