web/src/server.js

28 lines
502 B
JavaScript

// src/server.js
import { createServer, Model } from 'miragejs'
export function makeServer ({ environment = 'development' } = {}) {
const server = createServer({
environment,
models: {
user: Model
},
seeds (server) {
server.create('user', { name: 'Bob' })
server.create('user', { name: 'Alice' })
},
routes () {
this.namespace = 'api'
this.get('/users', (schema) => {
return schema.users.all()
})
}
})
return server
}