built read endpoint
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
meta {
|
meta {
|
||||||
name: create plan
|
name: create plan
|
||||||
type: http
|
type: http
|
||||||
seq: 2
|
seq: 3
|
||||||
}
|
}
|
||||||
|
|
||||||
post {
|
post {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
meta {
|
meta {
|
||||||
name: delete plan
|
name: delete plan
|
||||||
type: http
|
type: http
|
||||||
seq: 7
|
seq: 8
|
||||||
}
|
}
|
||||||
|
|
||||||
delete {
|
delete {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
meta {
|
meta {
|
||||||
name: list plans
|
name: list plans
|
||||||
type: http
|
type: http
|
||||||
seq: 1
|
seq: 2
|
||||||
}
|
}
|
||||||
|
|
||||||
get {
|
get {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
meta {
|
meta {
|
||||||
name: move plan
|
name: move plan
|
||||||
type: http
|
type: http
|
||||||
seq: 5
|
seq: 6
|
||||||
}
|
}
|
||||||
|
|
||||||
put {
|
put {
|
||||||
|
|||||||
16
.bruno/Plan Endpoints/read plan.bru
Normal file
16
.bruno/Plan Endpoints/read plan.bru
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
meta {
|
||||||
|
name: read plan
|
||||||
|
type: http
|
||||||
|
seq: 1
|
||||||
|
}
|
||||||
|
|
||||||
|
get {
|
||||||
|
url: http://localhost:14014/api/read/[planId]
|
||||||
|
body: none
|
||||||
|
auth: inherit
|
||||||
|
}
|
||||||
|
|
||||||
|
settings {
|
||||||
|
encodeUrl: true
|
||||||
|
timeout: 0
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
meta {
|
meta {
|
||||||
name: rename plan
|
name: rename plan
|
||||||
type: http
|
type: http
|
||||||
seq: 4
|
seq: 5
|
||||||
}
|
}
|
||||||
|
|
||||||
put {
|
put {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
meta {
|
meta {
|
||||||
name: undelete plan
|
name: undelete plan
|
||||||
type: http
|
type: http
|
||||||
seq: 6
|
seq: 7
|
||||||
}
|
}
|
||||||
|
|
||||||
put {
|
put {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
meta {
|
meta {
|
||||||
name: update plan
|
name: update plan
|
||||||
type: http
|
type: http
|
||||||
seq: 3
|
seq: 4
|
||||||
}
|
}
|
||||||
|
|
||||||
put {
|
put {
|
||||||
|
|||||||
10
mod.ts
10
mod.ts
@@ -36,7 +36,15 @@ Deno.serve({ port: config.api.port }, async (req) => {
|
|||||||
// SSR "home page"
|
// SSR "home page"
|
||||||
return genericResponse(STATUS_CODE.NotImplemented, 'WIP');
|
return genericResponse(STATUS_CODE.NotImplemented, 'WIP');
|
||||||
} else if (path.startsWith('/read/')) {
|
} else if (path.startsWith('/read/')) {
|
||||||
return genericResponse(STATUS_CODE.NotImplemented, 'WIP');
|
const planId = path.replace('/read/', '');
|
||||||
|
|
||||||
|
const plans = await dbClient.query('SELECT name, folder, data FROM plans WHERE id = ?', [planId]).catch(() => {
|
||||||
|
failed = true;
|
||||||
|
});
|
||||||
|
if (failed) return genericResponse(STATUS_CODE.InternalServerError, "Couldn't read DB.");
|
||||||
|
if (!plans.length) return genericResponse(STATUS_CODE.NotFound, 'Plan ID does not exist.');
|
||||||
|
|
||||||
|
return genericResponse(STATUS_CODE.OK, JSON.stringify(plans[0]));
|
||||||
} else if (path.startsWith('/list/')) {
|
} else if (path.startsWith('/list/')) {
|
||||||
const userId = path.replace('/list/', '');
|
const userId = path.replace('/list/', '');
|
||||||
const userMatch = await dbClient.query('SELECT id FROM users WHERE id = ?', [userId]).catch(() => {
|
const userMatch = await dbClient.query('SELECT id FROM users WHERE id = ?', [userId]).catch(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user