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.

server.js 858B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. var express = require('express');
  2. var bodyParser = require('body-parser');
  3. var app = express();
  4. var api = require('./patient.js');
  5. app.use(bodyParser.urlencoded({ extended: true }));
  6. app.use(bodyParser.json());
  7. app.get('/', (request, response) => {
  8. console.log("Anfrage erhalten");
  9. response.send("Hello World");
  10. })
  11. app.get('/patients', (req, res) => {
  12. res.json(api.readAll());
  13. });
  14. app.get('/patients/:id', (req, res) => {
  15. var patient = api.read(req.params.id);
  16. if (patient)
  17. res.json(patient);
  18. else
  19. res.sendStatus(404);
  20. })
  21. app.post('/patients', (req, res) => {
  22. });
  23. app.put('/patients/:id', (req, res) => {
  24. var count = api.update(req.params.id, req.body);
  25. res.json({ "count": count });
  26. });
  27. app.delete('/patients/:id', (req, res) => {
  28. });
  29. app.listen(3000, () => {
  30. console.log("MDT5/2 Server");
  31. })