@Vandesm14/

REST Test API

Express

No description

fork
loading
Files
  • index.js
  • db.js
  • db.sqlite3
  • package-lock.json
  • package.json

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.7382023612389772","path":"index.js","file":{"path":"index.js","content":{"asEncoding":{"base64":"Y29uc3QgZXhwcmVzcyA9IHJlcXVpcmUoJ2V4cHJlc3MnKTsKY29uc3QgYm9keVBhcnNlciA9IHJlcXVpcmUoJ2JvZHktcGFyc2VyJyk7CmNvbnN0IGRiID0gcmVxdWlyZSgnLi9kYicpOwpjb25zdCBmcyA9IHJlcXVpcmUoJ2ZzJyk7Cgpjb25zdCBhcHAgPSBleHByZXNzKCk7CgphcHAudXNlKGJvZHlQYXJzZXIuanNvbigpKTsKYXBwLnVzZShib2R5UGFyc2VyLnVybGVuY29kZWQoeyBleHRlbmRlZDogdHJ1ZSB9KSk7CgphcHAudXNlKGV4cHJlc3Muc3RhdGljKCdwdWJsaWMnKSk7CgphcHAuZ2V0KCcvJywgKHJlcSwgcmVzKSA9PiB7CglyZXMuc2VuZCgnSGVsbG8gRXhwcmVzcyBhcHAnKTsKfSk7CgphcHAuZ2V0KCcvYXBpL2VjaG8vOnBhcmFtKicsIChyZXEsIHJlcykgPT4gewoJcmVzLnNlbmQocmVxLnBhcmFtcy5wYXJhbSk7Cn0pOwoKYXBwLmdldCgnL2FwaS9lY2hvZGJsLzpwYXJhbTEvOnBhcmFtMicsIChyZXEsIHJlcykgPT4gewoJcmVzLnNlbmQocmVxLnBhcmFtcy5wYXJhbTEgKyAnLCAnICsgcmVxLnBhcmFtcy5wYXJhbTIpOwp9KTsKCmFwcC5nZXQoJy9hcGkvZWNob3F1ZXJ5LyonLCAocmVxLCByZXMpID0+IHsKCXJlcy5zZW5kKHJlcS5xdWVyeS5xKTsKfSk7CgphcHAuZ2V0KCcvYXBpJywgKHJlcSwgcmVzKSA9PiB7CglyZXMuc2VuZCgnQVBJIGlzIEFDVElWRScpOwp9KTsKCmFwcC5saXN0ZW4oMzAwMCwgKCkgPT4gY29uc29sZS5sb2coJ3NlcnZlciBzdGFydGVkJykpOw=="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const express = require('express');
const bodyParser = require('body-parser');
const db = require('./db');
const fs = require('fs');

const app = express();

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));

app.use(express.static('public'));

app.get('/', (req, res) => {
	res.send('Hello Express app');
});

app.get('/api/echo/:param*', (req, res) => {
	res.send(req.params.param);
});

app.get('/api/echodbl/:param1/:param2', (req, res) => {
	res.send(req.params.param1 + ', ' + req.params.param2);
});

app.get('/api/echoquery/*', (req, res) => {
	res.send(req.query.q);
});

app.get('/api', (req, res) => {
	res.send('API is ACTIVE');
});

app.listen(3000, () => console.log('server started'));