{"size": 795, "ext": "js", "max_stars_repo_path": "colegio/src/servicos/MirageServer.js", "max_stars_repo_name": "Notnox/React", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "colegio/src/servicos/MirageServer.js", "max_issues_repo_name": "Notnox/React", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "colegio/src/servicos/MirageServer.js", "max_forks_repo_name": "Notnox/React", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25.6451612903, "max_line_length": 72, "alphanum_fraction": 0.5396226415}
import { createServer, Model } from 'miragejs';
import * as constants from './Constantes';
import { tAlunos } from  '../componentes/conts/tAlunos';

export function Servidor({environment = 'test'} = {}) {
    const server = createServer({
        environment,

        models: {
            tAluno: Model,
        },

        seeds(server){
            tAlunos.forEach(aluno => server.create("tAluno", aluno));
        },

        routes() {
            this.namespace = constants.DEVINHOUSE_API

            this.get('/tAlunos', schema => schema.tAlunos.all().models);

            this.delete('/tAlunos/:id', (schema, request) => {
                const id = request.params.id;

                return schema.tAlunos.find(id).destroy();
            });
        },
    });

    return server;
}