index.js 770 B

1234567891011121314151617181920212223242526272829303132333435
  1. const express = require('express');
  2. var pjson = require('./package.json');
  3. const app = express();
  4. app.get('/api/v1/getNotepad', function (req, res) {
  5. console.log('Recieved GetNotepad request');
  6. res.type('json');
  7. res.send('{"posts": ["post1"]}');
  8. });
  9. app.get('/api/v1/ping', function (req, res) {
  10. console.log('Recieved Ping request');
  11. res.type('text/plain');
  12. res.send('pong');
  13. });
  14. app.get('/api/v1/info', function (req, res) {
  15. console.log('Recieved Info request');
  16. res.type('json');
  17. var response =
  18. {
  19. "version": pjson.version
  20. };
  21. res.send(JSON.stringify(response));
  22. });
  23. app.get('/', function (req, res) {
  24. console.log('Recieved / request');
  25. res.send("");
  26. });
  27. app.listen(5312, function () {
  28. console.log('Listening on port 5312...');
  29. });