Skip to content

Commit

Permalink
Merge pull request #2 from madhushaw1012/main
Browse files Browse the repository at this point in the history
Reduced parametric lines
  • Loading branch information
dipan29 authored Oct 29, 2020
2 parents 2ac2b34 + 1526cd5 commit b813580
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
7 changes: 3 additions & 4 deletions routes/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ router.post('/create', async (req, res) => {
});

router.post('/delete', async (req, res) => {
const { api_key } = req.body;
const { owner } = req.body;
const { api_key, owner } = req.body;

Keys.findOneAndDelete({ api_key, owner }).then(async key => {
if (key) {
// Delete all variables here - TODO
Expand Down Expand Up @@ -72,8 +72,7 @@ router.post('/list', async (req, res) => {
})

router.post('/stats', async (req, res) => {
const { api_key } = req.body;
const { owner } = req.body;
const { api_key, owner } = req.body;
Keys.findOne({ api_key, owner })
.then(key => {
if (key) {
Expand Down
20 changes: 6 additions & 14 deletions routes/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ router.get('/', async (req, res) => {

// Get Values of Entities - GET supported for /api-key/entity or POST /content
router.get('/:api_key/:entity', async (req, res) => {
const { api_key } = req.params;
const { entity } = req.params;
const { api_key, entity } = req.params;
// console.log({api_key, entity});
Values.findOne({ api_key, entity }).then(value => {
if (value) {
Expand All @@ -31,8 +30,7 @@ router.get('/:api_key/:entity', async (req, res) => {
});
});
router.post('/content', async (req, res) => {
const { api_key } = req.body;
const { entity } = req.body;
const { api_key, entity } = req.params;
Values.findOne({ api_key, entity }).then(value => {
if (value) {
res.status(200).json({
Expand Down Expand Up @@ -101,9 +99,7 @@ router.post('/create', async (req, res) => {
});

router.post('/set', async (req, res) => {
const { api_key } = req.body;
const { entity } = req.body;
const { content } = req.body;
const { api_key, entity, content } = req.body;

Values.findOne({ api_key, entity }).then(async value => {
if (value.type === (typeof content).toLowerCase()) {
Expand All @@ -130,8 +126,7 @@ router.post('/set', async (req, res) => {

// Set Data - GET Method
router.get('/set/:api_key/:entity/:value', async (req, res) => {
const { api_key } = req.params;
const { entity } = req.params;
const { api_key, entity } = req.params;
const content = req.params.value;

Values.findOne({ api_key, entity }).then(async value => {
Expand All @@ -152,9 +147,7 @@ router.get('/set/:api_key/:entity/:value', async (req, res) => {
});

router.post('/list-entities', async (req, res) => {
const { api_key } = req.body;
const { owner } = req.body;

const { api_key, owner } = req.body;
Keys.findOne({ api_key, owner }).then(async key => {
if (key) {
Values.find({ api_key })
Expand All @@ -177,8 +170,7 @@ router.post('/list-entities', async (req, res) => {

// Delete Entity
router.post('/delete', async (req, res) => {
const { api_key } = req.body;
const { entity } = req.body;
const { api_key, entity } = req.body;
Values.findOneAndDelete({ api_key, entity }).then(async value => {
if (value) {
res.status(200).json({
Expand Down

0 comments on commit b813580

Please sign in to comment.