Created
February 4, 2020 09:26
-
-
Save bborgesr/a05889f6ab057d6ee697331f848b4062 to your computer and use it in GitHub Desktop.
A simple server to serve mock data for the Room Manager app (https://github.com/bborgesr/room-manager)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require("express"); | |
const cors = require("cors"); | |
const reservations = [ | |
{ | |
reservaID: 1, | |
usuarioID: 1, | |
salaID: 1, | |
data: "2020-01-31", | |
horaEntrada: "2020-01-31T10:00:00", | |
horaSaida: "2020-01-31T11:00:00" | |
}, | |
{ | |
reservaID: 2, | |
usuarioID: 1, | |
salaID: 1, | |
data: "2020-01-31", | |
horaEntrada: "2020-01-31T10:00:00", | |
horaSaida: "2020-01-31T11:00:00" | |
}, | |
{ | |
reservaID: 3, | |
usuarioID: 2, | |
salaID: 1, | |
data: "2020-01-31", | |
horaEntrada: "2020-01-31T10:00:00", | |
horaSaida: "2020-01-31T11:00:00" | |
}, | |
{ | |
reservaID: 4, | |
usuarioID: 2, | |
salaID: 1, | |
data: "2020-01-31", | |
horaEntrada: "2020-01-31T10:00:00", | |
horaSaida: "2020-01-31T11:00:00" | |
}, | |
{ | |
reservaID: 5, | |
usuarioID: 1, | |
salaID: 1, | |
data: "2020-01-31", | |
horaEntrada: "2020-01-31T10:00:00", | |
horaSaida: "2020-01-31T11:00:00" | |
}, | |
{ | |
reservaID: 6, | |
usuarioID: 1, | |
salaID: 2, | |
data: "2020-01-31", | |
horaEntrada: "2020-01-31T10:00:00", | |
horaSaida: "2020-01-31T11:00:00" | |
}, | |
{ | |
reservaID: 7, | |
usuarioID: 1, | |
salaID: 2, | |
data: "2020-01-31", | |
horaEntrada: "2020-01-31T10:00:00", | |
horaSaida: "2020-01-31T11:00:00" | |
}, | |
{ | |
reservaID: 8, | |
usuarioID: 1, | |
salaID: 3, | |
data: "2020-01-31", | |
horaEntrada: "2020-01-31T10:00:00", | |
horaSaida: "2020-01-31T11:00:00" | |
} | |
]; | |
const users = [ | |
{ | |
usuarioID: 1, | |
sobrenome: "Borges", | |
primeironome: "Barbara", | |
login: "bborges" | |
}, | |
{ | |
usuarioID: 2, | |
sobrenome: "Machado", | |
primeironome: "Sergio", | |
login: "smachado" | |
}, | |
{ | |
usuarioID: 3, | |
sobrenome: "Curioso", | |
primeironome: "Catarina", | |
login: "ccurioso" | |
}, | |
{ | |
usuarioID: 4, | |
sobrenome: "Blaya", | |
primeironome: "Felipe", | |
login: "fblaya" | |
}, | |
{ | |
usuarioID: 5, | |
sobrenome: "Mattos", | |
primeironome: "Marcelo", | |
login: "mmattos" | |
} | |
]; | |
const rooms = [ | |
{ | |
salaID: 1, | |
nome: "Porto" | |
}, | |
{ | |
salaID: 2, | |
nome: "Vila Nova de Gaia" | |
}, | |
{ | |
salaID: 3, | |
nome: "Matosinhos" | |
} | |
]; | |
const server = express(); | |
server.use(cors()); | |
server.get("/reservations", (req, res) => { | |
res.send(JSON.stringify(reservations)); | |
}); | |
server.get("/users", (req, res) => { | |
res.send(JSON.stringify(users)); | |
}); | |
server.get("/rooms", (req, res) => { | |
res.send(JSON.stringify(rooms)); | |
}); | |
server.listen(1337); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A simple server. To replicate, create a file
index.js
with the code above and in the terminal, type:yarn yarn add express yarn add cors node index.js # to run the server