create-elysiajs
Version:
Scaffolding your Elysia project with the environment with easy!
31 lines (29 loc) • 1.07 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getLocksFile = getLocksFile;
const ts_dedent_1 = __importDefault(require("ts-dedent"));
function getLocksFile({ redis }) {
const imports = [];
const stores = [];
stores.push("memory: { driver: memoryStore() }");
imports.push(`import { memoryStore } from '@verrou/core/drivers/memory'`);
if (redis) {
stores.push("redis: { driver: redisStore({ connection: redis }) },");
imports.push(`import { redisStore } from '@verrou/core/drivers/redis'`);
imports.push(`import { redis } from './redis.ts'`);
}
return (0, ts_dedent_1.default /* ts */) `
import { Verrou } from "@verrou/core"
import { config } from "../config.ts"
${imports.join("\n")}
export const verrou = new Verrou({
default: config.LOCK_STORE,
stores: {
${stores.join(",\n")}
}
})
`;
}