generate salt if salt.txt doesnt exist, add readme
This commit is contained in:
parent
cd4738377b
commit
21bcf5c5ac
24
README.md
24
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
|
||||
```
|
||||
|
12
src/index.ts
12
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 } ]
|
||||
|
Loading…
Reference in New Issue
Block a user