Skip to content

Commit

Permalink
Merge pull request #6 from ThyagoMC/main
Browse files Browse the repository at this point in the history
adding url params filter + adding model for internal list api
  • Loading branch information
ThyagoMC authored Nov 18, 2021
2 parents 2317773 + 89bdd58 commit 38bffd4
Show file tree
Hide file tree
Showing 4 changed files with 473 additions and 93 deletions.
9 changes: 5 additions & 4 deletions mocks/@types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export type Response = {
is?: {
statusCode?: number;
headers?: {
[key: string]: string | number;
[key: string]: string | number | boolean;
};
body?: Primitive | Json;
};
Expand All @@ -74,17 +74,18 @@ export type StubsModule = {

export type ApiMethods = "LIST" | "GET" | "POST" | "PUT" | "DELETE" | "PATCH";

export type ApiData = {
export type ApiData<T> = {
state: string;
api: RegExpString;
data?: any[];
dataPriority?: number;
model: string;
methods?: ApiMethods[];
config?: any;
config?: T;
};

export type ApiCollection = {
[key: string]: ApiData;
[key: string]: ApiData<any>;
};

export type ApiStub = {
Expand Down
5 changes: 3 additions & 2 deletions mocks/api-model/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { ApiCollection, ApiData, ApiStub, StubsModule } from "../@types";
import * as listTotal from "./list-total";
import * as internalList from "./internal-list";

import { config, imposter } from "../mconfig";
import logger from "fancy-log";

type InitStubs = (name: string, configApi: ApiData, db: string) => StubsModule;
type InitStubs = (name: string, configApi: ApiData<any>, db: string) => StubsModule;

type Models = {
[key: string]: InitStubs;
};

export const models: Models = {
"list-total": listTotal.initStubs,
"internal-list": internalList.initStubs,
};

export function initApi(packName: string, apiCollection: ApiCollection) {
Expand Down
Loading

0 comments on commit 38bffd4

Please sign in to comment.