You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
spa_instat_tv/src/utilits/Mirage/Mirage.ts

43 lines
982 B

// eslint-disable-next-line import/no-extraneous-dependencies
import {
createServer,
Model,
} from 'miragejs'
import auth from './Fixtures/auth'
// eslint-disable-next-line
interface Props {
environment: string,
}
export function makeServer({ environment = 'test' }: Props) {
return createServer({
environment,
factories: {},
fixtures: {
auth,
},
models: {
auth: Model.extend<Partial<any>>({}),
},
routes() {
this.namespace = '/api'
// this.urlPrefix = Url.TokenServer
// this.passthrough(); // Allow unhandled requests on the current domain to pass through
this.get(
'/dashboard/1.0/workplace-count-employee/:id',
(schema, request) => (
schema
.all('auth')
.models.find(
({ structureId }) => structureId === request.params.id,
)?.attrs || {}
),
)
},
seeds(server) {
server.loadFixtures()
},
})
}