Skip to content

Commit

Permalink
feature userAccessPolicy: code review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
light-source committed Jan 10, 2025
1 parent e3b0188 commit 19bd2e4
Show file tree
Hide file tree
Showing 33 changed files with 34 additions and 35 deletions.
4 changes: 2 additions & 2 deletions packages/user-access-policy/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import type { RequestInspector } from "@blacklist/inspector/requestInspector.js"
import { createExpressRuleRouter } from "@rules/api/createExpressRuleRouter.js";
import { getExpressApiRuleRateLimits } from "@rules/api/getExpressApiRuleRateLimits.js";
import type { Rule } from "@rules/rule/rule.js";
import { createMongooseRulesStorage } from "@rules/storage/mongoose/createMongooseRulesStorage.js";
import { getMongooseRuleRecordSchema } from "@rules/storage/mongoose/getMongooseRuleRecordSchema.js";
import { createMongooseRulesStorage } from "@rules/storage/createMongooseRulesStorage.js";
import { getMongooseRuleRecordSchema } from "@rules/storage/record/getMongooseRuleRecordSchema.js";
import type { RulesStorage } from "@rules/storage/rulesStorage.js";

export {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
// limitations under the License.
import type { Model } from "mongoose";
import type {Rule} from "@rules/rule/rule.js";
import {MongooseRulesStorage} from "@rules/storage/mongoose/mongooseRulesStorage.js";
import type {RulesStorage} from "@rules/storage/rulesStorage.js";
import {MongooseRulesStorage} from "@rules/storage/mongooseRulesStorage.js";

const createMongooseRulesStorage = (
readingModel: Model<Rule> | null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
// limitations under the License.
import type { Schema } from "mongoose";
import type {Rule} from "@rules/rule/rule.js";
import {mongoosePerformanceRuleIndexes} from "@rules/storage/mongoose/indexes/mongoosePerformanceRuleIndexes.js";
import {mongooseUniqueRuleIndexes} from "@rules/storage/mongoose/indexes/mongooseUniqueRuleIndexes.js";
import {mongoosePerformanceRuleIndexes} from "@rules/storage/record/indexes/performance/mongoosePerformanceRuleIndexes.js";
import {mongooseUniqueRuleIndexes} from "@rules/storage/record/indexes/unique/mongooseUniqueRuleIndexes.js";
import {mongooseRule} from "@rules/rule/mongooseRule.js";

const getMongooseRuleRecordSchema = (): Schema<Rule> => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import type {MongooseIndex} from "@rules/storage/mongoose/indexes/mongooseIndex.js";
import type {MongooseIndex} from "@rules/storage/record/indexes/mongooseIndex.js";

const userIpIndexes: MongooseIndex[] = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import type {MongooseIndex} from "@rules/storage/mongoose/indexes/mongooseIndex.js";
import type {MongooseIndex} from "@rules/storage/record/indexes/mongooseIndex.js";

const globalIpIndexes: MongooseIndex[] = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
// limitations under the License.
import mongoose, { type Model } from "mongoose";
import type {RulesStorageFactory} from "@tests/benchmark/storageFactory/rulesStorageFactory.js";
import {MongooseRulesStorage} from "@rules/storage/mongoose/mongooseRulesStorage.js";
import type {RulesStorage} from "@rules/storage/rulesStorage.js";
import type {Rule} from "@rules/rule/rule.js";
import {getMongooseRuleRecordSchema} from "@rules/storage/mongoose/getMongooseRuleRecordSchema.js";
import {MongooseRulesStorage} from "@rules/storage/mongooseRulesStorage.js";
import {getMongooseRuleRecordSchema} from "@rules/storage/record/getMongooseRuleRecordSchema.js";

class MongooseRulesStorageFactory implements RulesStorageFactory {
async createRulesStorage(dbUrl: string): Promise<RulesStorage> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import { MongoMemoryServer } from "mongodb-memory-server";
import mongoose, { type Model } from "mongoose";
import { afterAll, beforeEach } from "vitest";
import {getMongooseRuleRecordSchema} from "@rules/storage/mongoose/getMongooseRuleRecordSchema.js";
import type {Rule} from "@rules/rule/rule.js";
import {getMongooseRuleRecordSchema} from "@rules/storage/record/getMongooseRuleRecordSchema.js";

const createTestMongooseRuleModel = async (): Promise<Model<Rule>> => {
const mongoServer = await MongoMemoryServer.create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
// limitations under the License.
import { describe } from "vitest";
import {createTestMongooseRuleModel} from "@tests/rules/storage/createTestMongooseRuleModel.js";
import {MongooseRulesStorage} from "@rules/storage/mongoose/mongooseRulesStorage.js";
import {TestFindRule} from "@tests/rules/storage/filters/search/generic/testFindRule.js";
import {MongooseRulesStorage} from "@rules/storage/mongooseRulesStorage.js";

describe("MongooseFindRule", async () => {
const testModel = await createTestMongooseRuleModel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { describe } from "vitest";
import {MongooseRulesStorage} from "@rules/storage/mongoose/mongooseRulesStorage.js";
import {TestFindRuleByUserId} from "@tests/rules/storage/filters/search/generic/testFindRuleByUserId.js";
import {createTestMongooseRuleModel} from "@tests/rules/storage/createTestMongooseRuleModel.js";
import {MongooseRulesStorage} from "@rules/storage/mongooseRulesStorage.js";

describe("MongooseFindRuleByUserId", async () => {
const testModel = await createTestMongooseRuleModel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { describe } from "vitest";
import {MongooseRulesStorage} from "@rules/storage/mongoose/mongooseRulesStorage.js";
import {
TestFindByMaskV4RangeMax
} from "@tests/rules/storage/filters/search/ip/v4/mask/maskRange/max/testFindByMaskV4RangeMax.js";
import {createTestMongooseRuleModel} from "@tests/rules/storage/createTestMongooseRuleModel.js";
import {MongooseRulesStorage} from "@rules/storage/mongooseRulesStorage.js";

describe("MongooseFindByMaskV4RangeMax", async () => {
const testModel = await createTestMongooseRuleModel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
// limitations under the License.
import { describe } from "vitest";
import {createTestMongooseRuleModel} from "@tests/rules/storage/createTestMongooseRuleModel.js";
import {MongooseRulesStorage} from "@rules/storage/mongoose/mongooseRulesStorage.js";
import {
TestFindByMaskV4RangeMin
} from "@tests/rules/storage/filters/search/ip/v4/mask/maskRange/min/testFindByMaskV4RangeMin.js";
import {MongooseRulesStorage} from "@rules/storage/mongooseRulesStorage.js";

describe("MongooseFindByMaskV4RangeMin", async () => {
const testModel = await createTestMongooseRuleModel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
// limitations under the License.
import { describe } from "vitest";
import {createTestMongooseRuleModel} from "@tests/rules/storage/createTestMongooseRuleModel.js";
import {MongooseRulesStorage} from "@rules/storage/mongoose/mongooseRulesStorage.js";
import {TestFindByMaskV4} from "@tests/rules/storage/filters/search/ip/v4/mask/testFindByMaskV4.js";
import {MongooseRulesStorage} from "@rules/storage/mongooseRulesStorage.js";

describe("MongooseFindByMaskV4", async () => {
const testModel = await createTestMongooseRuleModel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { describe } from "vitest";
import {MongooseRulesStorage} from "@rules/storage/mongoose/mongooseRulesStorage.js";
import {createTestMongooseRuleModel} from "@tests/rules/storage/createTestMongooseRuleModel.js";
import {TestFindByIpV4} from "@tests/rules/storage/filters/search/ip/v4/testFindByIpV4.js";
import {MongooseRulesStorage} from "@rules/storage/mongooseRulesStorage.js";

describe("MongooseFindByIpV4", async () => {
const testModel = await createTestMongooseRuleModel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
// limitations under the License.
import { describe } from "vitest";
import {createTestMongooseRuleModel} from "@tests/rules/storage/createTestMongooseRuleModel.js";
import {MongooseRulesStorage} from "@rules/storage/mongoose/mongooseRulesStorage.js";
import {
TestFindByIpMaskV6RangeMax
} from "@tests/rules/storage/filters/search/ip/v6/mask/maskRange/max/testFindByIpMaskV6RangeMax.js";
import {MongooseRulesStorage} from "@rules/storage/mongooseRulesStorage.js";

describe("MongooseFindByIpMaskV6RangeMax", async () => {
const testModel = await createTestMongooseRuleModel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
// limitations under the License.
import { describe } from "vitest";
import {createTestMongooseRuleModel} from "@tests/rules/storage/createTestMongooseRuleModel.js";
import {MongooseRulesStorage} from "@rules/storage/mongoose/mongooseRulesStorage.js";
import {
TestFindByIpMaskV6RangeMin
} from "@tests/rules/storage/filters/search/ip/v6/mask/maskRange/min/testFindByIpMaskV6RangeMin.js";
import {MongooseRulesStorage} from "@rules/storage/mongooseRulesStorage.js";

describe("MongooseFindByIpMaskV6RangeMin", async () => {
const testModel = await createTestMongooseRuleModel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
// limitations under the License.
import { describe } from "vitest";
import {TestFindByIpMaskV6} from "@tests/rules/storage/filters/search/ip/v6/mask/testFindByIpMaskV6.js";
import {MongooseRulesStorage} from "@rules/storage/mongoose/mongooseRulesStorage.js";
import {createTestMongooseRuleModel} from "@tests/rules/storage/createTestMongooseRuleModel.js";
import {MongooseRulesStorage} from "@rules/storage/mongooseRulesStorage.js";

describe("MongooseFindByIpMaskV6", async () => {
const testModel = await createTestMongooseRuleModel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import { describe } from "vitest";
import {
TestFindByIpMaskV6ShortRangeMax
} from "@tests/rules/storage/filters/search/ip/v6/short/mask/maskRange/max/testFindByIpMaskV6ShortRangeMax.js";
import {MongooseRulesStorage} from "@rules/storage/mongoose/mongooseRulesStorage.js";
import {createTestMongooseRuleModel} from "@tests/rules/storage/createTestMongooseRuleModel.js";
import {MongooseRulesStorage} from "@rules/storage/mongooseRulesStorage.js";

describe("MongooseFindByIpV6MaskV6ShortRangeMax", async () => {
const testModel = await createTestMongooseRuleModel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
// limitations under the License.
import { describe } from "vitest";
import {createTestMongooseRuleModel} from "@tests/rules/storage/createTestMongooseRuleModel.js";
import {MongooseRulesStorage} from "@rules/storage/mongoose/mongooseRulesStorage.js";
import {
TestFindByIpMaskV6ShortRangeMin
} from "@tests/rules/storage/filters/search/ip/v6/short/mask/maskRange/min/testFindByIpMaskV6ShortRangeMin.js";
import {MongooseRulesStorage} from "@rules/storage/mongooseRulesStorage.js";

describe("MongooseFindByIpMaskV6ShortRangeMin", async () => {
const testModel = await createTestMongooseRuleModel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
// limitations under the License.
import { describe } from "vitest";
import {TestFindByIpMaskV6Short} from "@tests/rules/storage/filters/search/ip/v6/short/mask/testFindByIpMaskV6Short.js";
import {MongooseRulesStorage} from "@rules/storage/mongoose/mongooseRulesStorage.js";
import {createTestMongooseRuleModel} from "@tests/rules/storage/createTestMongooseRuleModel.js";
import {MongooseRulesStorage} from "@rules/storage/mongooseRulesStorage.js";

describe("MongooseFindByIpMaskV6Short", async () => {
const testModel = await createTestMongooseRuleModel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
// limitations under the License.
import { describe } from "vitest";
import {TestFindByIpV6Short} from "@tests/rules/storage/filters/search/ip/v6/short/testFindByIpV6Short.js";
import {MongooseRulesStorage} from "@rules/storage/mongoose/mongooseRulesStorage.js";
import {createTestMongooseRuleModel} from "@tests/rules/storage/createTestMongooseRuleModel.js";
import {MongooseRulesStorage} from "@rules/storage/mongooseRulesStorage.js";

describe("MongooseFindByIpV6Short", async () => {
const testModel = await createTestMongooseRuleModel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
// limitations under the License.
import { describe } from "vitest";
import {TestFindByIpV6} from "@tests/rules/storage/filters/search/ip/v6/testFindByIpV6.js";
import {MongooseRulesStorage} from "@rules/storage/mongoose/mongooseRulesStorage.js";
import {createTestMongooseRuleModel} from "@tests/rules/storage/createTestMongooseRuleModel.js";
import {MongooseRulesStorage} from "@rules/storage/mongooseRulesStorage.js";

describe("MongooseFindByIpV6", async () => {
const testModel = await createTestMongooseRuleModel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import { describe } from "vitest";
import {
TestIpV4MaskUniqueIndex
} from "@tests/rules/storage/mongoose/indexes/unique/ip/v4/mask/testIpV4MaskUniqueIndex.js";
import {MongooseRulesStorage} from "@rules/storage/mongoose/mongooseRulesStorage.js";
import {createTestMongooseRuleModel} from "@tests/rules/storage/createTestMongooseRuleModel.js";
import {MongooseRulesStorage} from "@rules/storage/mongooseRulesStorage.js";

describe("MongooseIpV4MaskUniqueIndex", async () => {
const testModel = await createTestMongooseRuleModel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
// limitations under the License.
import { describe } from "vitest";
import {TestIpV4UniqueIndex} from "@tests/rules/storage/mongoose/indexes/unique/ip/v4/testIpV4UniqueIndex.js";
import {MongooseRulesStorage} from "@rules/storage/mongoose/mongooseRulesStorage.js";
import {createTestMongooseRuleModel} from "@tests/rules/storage/createTestMongooseRuleModel.js";
import {MongooseRulesStorage} from "@rules/storage/mongooseRulesStorage.js";

describe("MongooseIpV4UniqueIndex", async () => {
const testModel = await createTestMongooseRuleModel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import { describe } from "vitest";
import {
TestIpV6MaskUniqueIndex
} from "@tests/rules/storage/mongoose/indexes/unique/ip/v6/mask/testIpV6MaskUniqueIndex.js";
import {MongooseRulesStorage} from "@rules/storage/mongoose/mongooseRulesStorage.js";
import {createTestMongooseRuleModel} from "@tests/rules/storage/createTestMongooseRuleModel.js";
import {MongooseRulesStorage} from "@rules/storage/mongooseRulesStorage.js";

describe("MongooseIpV6MaskUniqueIndex", async () => {
const testModel = await createTestMongooseRuleModel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
// limitations under the License.
import { describe } from "vitest";
import {createTestMongooseRuleModel} from "@tests/rules/storage/createTestMongooseRuleModel.js";
import {MongooseRulesStorage} from "@rules/storage/mongoose/mongooseRulesStorage.js";
import {TestIpV6UniqueIndex} from "@tests/rules/storage/mongoose/indexes/unique/ip/v6/testIpV6UniqueIndex.js";
import {MongooseRulesStorage} from "@rules/storage/mongooseRulesStorage.js";

describe("MongooseIpV6UniqueIndex", async () => {
const testModel = await createTestMongooseRuleModel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
// limitations under the License.
import { describe } from "vitest";
import {createTestMongooseRuleModel} from "@tests/rules/storage/createTestMongooseRuleModel.js";
import {MongooseRulesStorage} from "@rules/storage/mongoose/mongooseRulesStorage.js";
import {
TestIpV6MaskFormatting
} from "@tests/rules/storage/record/fieldTests/ipV6Formatting/mask/testIpV6MaskFormatting.js";
import {MongooseRulesStorage} from "@rules/storage/mongooseRulesStorage.js";

describe("MongooseIpV6MaskFormatting", async () => {
const testModel = await createTestMongooseRuleModel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
// limitations under the License.
import { describe } from "vitest";
import {createTestMongooseRuleModel} from "@tests/rules/storage/createTestMongooseRuleModel.js";
import {MongooseRulesStorage} from "@rules/storage/mongoose/mongooseRulesStorage.js";
import {TestIpV6Formatting} from "@tests/rules/storage/record/fieldTests/ipV6Formatting/testIpV6Formatting.js";
import {MongooseRulesStorage} from "@rules/storage/mongooseRulesStorage.js";

describe("MongooseIpV6Formatting", async () => {
const testModel = await createTestMongooseRuleModel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
// limitations under the License.
import { describe } from "vitest";
import {createTestMongooseRuleModel} from "@tests/rules/storage/createTestMongooseRuleModel.js";
import {MongooseRulesStorage} from "@rules/storage/mongoose/mongooseRulesStorage.js";
import {
TestOptionalFieldsValidation
} from "@tests/rules/storage/record/fieldTests/validation/optional/testOptionalFieldsValidation.js";
import {MongooseRulesStorage} from "@rules/storage/mongooseRulesStorage.js";

describe("MongooseOptionalFieldsValidation", async () => {
const testModel = await createTestMongooseRuleModel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
// limitations under the License.
import { describe } from "vitest";
import {createTestMongooseRuleModel} from "@tests/rules/storage/createTestMongooseRuleModel.js";
import {MongooseRulesStorage} from "@rules/storage/mongoose/mongooseRulesStorage.js";
import {TestUserIdValidation} from "@tests/rules/storage/record/fieldTests/validation/userId/testUserIdValidation.js";
import {MongooseRulesStorage} from "@rules/storage/mongooseRulesStorage.js";

describe("MongooseUserIdValidation", async () => {
const testModel = await createTestMongooseRuleModel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
// limitations under the License.
import { describe } from "vitest";
import {createTestMongooseRuleModel} from "@tests/rules/storage/createTestMongooseRuleModel.js";
import {MongooseRulesStorage} from "@rules/storage/mongoose/mongooseRulesStorage.js";
import {TestUserIpValidation} from "@tests/rules/storage/record/fieldTests/validation/userIp/testUserIpValidation.js";
import {MongooseRulesStorage} from "@rules/storage/mongooseRulesStorage.js";

describe("MongooseUserIPValidation", async () => {
const testModel = await createTestMongooseRuleModel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
// limitations under the License.
import { describe } from "vitest";
import {createTestMongooseRuleModel} from "@tests/rules/storage/createTestMongooseRuleModel.js";
import {MongooseRulesStorage} from "@rules/storage/mongoose/mongooseRulesStorage.js";
import {
TestUserIpVersionValidation
} from "@tests/rules/storage/record/fieldTests/validation/userIpVersion/testUserIpVersionValidation.js";
import {MongooseRulesStorage} from "@rules/storage/mongooseRulesStorage.js";

describe("MongooseUserIpVersionValidation", async () => {
const testModel = await createTestMongooseRuleModel();
Expand Down

0 comments on commit 19bd2e4

Please sign in to comment.