Files
dealplustech/node_modules/drizzle-orm/neon/rls.js
Kunthawat 5171a789e9 fix: Final restoration with port 80
 COMPLETED:
1. Dockerfile uses port 80 (astro preview)
2. BaseLayout imports globals.css
3. globals.css with Tailwind v4 @theme syntax
4. index.astro has Header, Footer, FixedContact
5. All image references fixed to existing files
6. Hero uses hdpe_pipe_main.jpg
7. Product cards use hdpe001.jpg
8. pt-20 on main for fixed header

 TESTED LOCALLY:
- Build: 15 pages in 1.27s
- Docker build successful
- Port 80 working
- Images load
- CSS works

Ready for Easypanel deployment.
2026-03-12 08:58:56 +07:00

69 lines
1.9 KiB
JavaScript

import { is } from "../entity.js";
import { pgPolicy } from "../pg-core/index.js";
import { PgRole, pgRole } from "../pg-core/roles.js";
import { sql } from "../sql/sql.js";
const crudPolicy = (options) => {
if (options.read === void 0) {
throw new Error("crudPolicy requires a read policy");
}
if (options.modify === void 0) {
throw new Error("crudPolicy requires a modify policy");
}
let read;
if (options.read === true) {
read = sql`true`;
} else if (options.read === false) {
read = sql`false`;
} else if (options.read !== null) {
read = options.read;
}
let modify;
if (options.modify === true) {
modify = sql`true`;
} else if (options.modify === false) {
modify = sql`false`;
} else if (options.modify !== null) {
modify = options.modify;
}
let rolesName = "";
if (Array.isArray(options.role)) {
rolesName = options.role.map((it) => {
return is(it, PgRole) ? it.name : it;
}).join("-");
} else {
rolesName = is(options.role, PgRole) ? options.role.name : options.role;
}
return [
read && pgPolicy(`crud-${rolesName}-policy-select`, {
for: "select",
to: options.role,
using: read
}),
modify && pgPolicy(`crud-${rolesName}-policy-insert`, {
for: "insert",
to: options.role,
withCheck: modify
}),
modify && pgPolicy(`crud-${rolesName}-policy-update`, {
for: "update",
to: options.role,
using: modify,
withCheck: modify
}),
modify && pgPolicy(`crud-${rolesName}-policy-delete`, {
for: "delete",
to: options.role,
using: modify
})
].filter(Boolean);
};
const authenticatedRole = pgRole("authenticated").existing();
const anonymousRole = pgRole("anonymous").existing();
const authUid = (userIdColumn) => sql`(select auth.user_id() = ${userIdColumn})`;
export {
anonymousRole,
authUid,
authenticatedRole,
crudPolicy
};
//# sourceMappingURL=rls.js.map