Skip to content

Commit bcf083e

Browse files
committed
Fix: wrong status code
1 parent 254ccd6 commit bcf083e

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

controllers/api.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var refreshPairs;
88
var codes;
99
var url;
1010
var access;
11-
/*202: Accepted - everything is ok.
11+
/*200: Ok - everything is ok.
1212
/*308: Permanent Redirect - this url will always redirect to this path.
1313
/*400: Bad request - incorrect request syntax.
1414
/*401: Unauthorized - missing identification.
@@ -67,7 +67,7 @@ async function apiNew(res, u, p, l, rb, pair) {
6767
await refreshPairs();
6868
var msg = "Short url has been registered.";
6969
var response = { message: msg, label: l, shortUrl: `${url}${p}`, orgUrl: u, registeredBy: rb };
70-
return res.json({ status: codes.acc, response: response });
70+
return res.json({ status: codes.ok, response: response });
7171
}
7272
return res.json({ status: codes.badReq, response: `Page \`${url}${p}\` is already taken.` });
7373
}
@@ -88,7 +88,7 @@ async function apiEditPage(res, p, np, rb, pair) {
8888
var msg = "Short url has been updated.";
8989
//prettier-ignore
9090
var response = { message: msg, label: pair.label, shortUrl: `${url}${np}`, orgUrl: pair.url, registeredBy: pair.registeredBy, clicks: pair.clicks || 0 };
91-
return res.json({ status: codes.acc, response: response });
91+
return res.json({ status: codes.ok, response: response });
9292
}
9393
//[Update url]
9494
async function apiEditUrl(res, p, nu, rb, pair) {
@@ -104,7 +104,7 @@ async function apiEditUrl(res, p, nu, rb, pair) {
104104
var msg = "Short url has been updated.";
105105
//prettier-ignore
106106
var response = { message: msg, label: pair.label, shortUrl: `${url}${p}`, orgUrl: nu, registeredBy: pair.registeredBy, clicks: pair.clicks || 0 };
107-
return res.json({ status: codes.acc, response: response });
107+
return res.json({ status: codes.ok, response: response });
108108
}
109109
//[Change label]
110110
async function apiEditLabel(res, p, nl, rb, pair) {
@@ -120,7 +120,7 @@ async function apiEditLabel(res, p, nl, rb, pair) {
120120
var msg = "Short url has been updated.";
121121
//prettier-ignore
122122
var response = { message: msg, label: nl, shortUrl: `${url}${p}`, orgUrl: pair.url, registeredBy: pair.registeredBy, clicks: pair.clicks || 0 };
123-
return res.json({ status: codes.acc, response: response });
123+
return res.json({ status: codes.ok, response: response });
124124
}
125125
//[Search in urls]
126126
async function apiSearch(res, u, p, l, rb) {
@@ -149,7 +149,7 @@ async function apiSearch(res, u, p, l, rb) {
149149
if (a.clicks > b.clicks) return 1;
150150
return 0;
151151
});
152-
return res.json({ status: codes.acc, response: response });
152+
return res.json({ status: codes.ok, response: response });
153153
}
154154
//[Delete a url]
155155
async function apiDelete(res, p, l, rb, pair) {
@@ -166,7 +166,7 @@ async function apiDelete(res, p, l, rb, pair) {
166166
await pair.delete();
167167
//[Refresh Database]
168168
await refreshPairs();
169-
return res.json({ status: codes.acc, response: response });
169+
return res.json({ status: codes.ok, response: response });
170170
}
171171
//[Refresh database]
172172
async function apiRefresh(res, rb) {
@@ -191,7 +191,7 @@ async function apiRefresh(res, rb) {
191191
var response = {
192192
message: [`Databse refreshed succesefully.`, `${aAmount} added.`, `${rAmount} removed.`, `${cAmount} changed.`],
193193
};
194-
return res.json({ status: codes.acc, response: response });
194+
return res.json({ status: codes.ok, response: response });
195195
}
196196
//aid func
197197
function prep(p, r, c, u, a) {

controllers/redirect.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var refreshPairs;
66
var codes;
77
var url;
88
var access;
9-
/*202: Accepted - everything is ok.
9+
/*200: Ok - everything is ok.
1010
/*308: Permanent Redirect - this url will always redirect to this path.
1111
/*400: Bad request - incorrect request syntax.
1212
/*401: Unauthorized - missing identification.

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ async function refreshPairs(url, access) {
6868
}
6969
}
7070
const codes = {
71-
acc: 202,
71+
ok: 200,
7272
permRedir: 308,
7373
badReq: 400,
7474
unaothReq: 401,

0 commit comments

Comments
 (0)