// setting.ts

function setting(){
    const config = {
        site_title: "ពហុព័ត៌មាន",
        page_title: "ទំព័រ​ដើម",
        message: "",
        count: 0,
        post_amount: 10,
    }

    return config;
}


import { config } from "config";
await config({export: true});
const secret_key = Deno.env.get("SECRET_KEY");


import { MongoClient } from "mongodb";
const client = await new MongoClient();
await client.connect(Deno.env.get('DATABASE_URI'));
const mongo_db = client.database(Deno.env.get('DB_NAME'));


import { connect } from "redis"
const redis_db = await connect({
    hostname: Deno.env.get('REDIS_URI'),
    port: parseInt(Deno.env.get('REDIS_PORT')),
    password: Deno.env.get('REDIS_PASSWORD'),
});

///////////////////////////////////

export { setting, secret_key, mongo_db, redis_db };

 

// import_map.json
{
  "imports": {
    "$fresh/": "https://deno.land/x/fresh@1.0.2/",
    "preact": "https://esm.sh/preact@10.10.0",
    "preact/": "https://esm.sh/preact@10.10.0/",
    "preact-render-to-string": "https://esm.sh/preact-render-to-string@5.2.1?external=preact",
    "setting": "./setting.ts",
    "config": "https://deno.land/std@0.147.0/dotenv/mod.ts",
    "mongodb": "https://deno.land/x/mongo@v0.30.1/mod.ts",
    "redis": "https://deno.land/x/redis@v0.26.0/mod.ts",
    "jwt": "https://deno.land/x/djwt@v2.2/mod.ts",
    "bcrypt": "./bcrypt.ts"
  }
}

 

// .env

SECRET_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
DATABASE_URI=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
DB_NAME=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
REDIS_URI=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
REDIS_PASSWORD=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
REDIS_PORT=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

 

GitHub: https://github.com/Sokhavuth/khmerweb-fresh

Deno Deploy: https://khmerweb.deno.dev/