Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions api/main_endpoints/routes/Cleezy.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const { MEMBERSHIP_STATE } = require('../../util/constants.js');
let CLEEZY_URL = process.env.CLEEZY_URL
|| 'http://localhost:8000';
let URL_SHORTENER_BASE_URL =
process.env.NODE_ENV === 'production' ? 'https://sce.sjsu.edu/s/' : 'http://localhost:8000/find/';
process.env.NODE_ENV === 'production' ? 'https://sce.sjsu.edu/s/' : 'http://localhost:8000/url/find/';

router.get('/list', async (req, res) => {
if(!ENABLED) {
Expand All @@ -34,7 +34,7 @@ router.get('/list', async (req, res) => {
const returnData = await cleezyHelpers.searchCleezyUrls({ page, search, sortColumn, sortOrder });
res.json(returnData);
} catch (err) {
logger.error('/listAll had an error', err);
logger.error('/url/list had an error', err);
if (err.response && err.response.data) {
res.status(err.response.status).json({ error: err.response.data });
} else {
Expand All @@ -53,12 +53,12 @@ router.post('/createUrl', async (req, res) => {
// eslint-disable-next-line camelcase
if (expiresAt) jsonbody.expires_at = expiresAt;
try {
const response = await axios.post(CLEEZY_URL + '/create_url', jsonbody);
const response = await axios.post(CLEEZY_URL + '/url/create', jsonbody);
const data = response.data;
const u = new URL( data.alias, URL_SHORTENER_BASE_URL);
res.json({ ...data, link: u });
} catch (err) {
logger.error('/createUrl had an error', err);
logger.error('/url/create had an error', err);
res.status(err.response.status).json({ error: err.response.data?.detail || err.response.data || 'Unknown error from Cleezy' });
}
});
Expand All @@ -70,12 +70,12 @@ router.post('/deleteUrl', async (req, res) => {
}
const { alias } = req.body;
axios
.post(CLEEZY_URL + '/delete/' + alias)
.post(CLEEZY_URL + '/url/delete/' + alias)
.then(() => {
res.sendStatus(OK);
})
.catch(err => {
logger.error('/deleteUrl had an error', err);
logger.error('/url/delete had an error', err);
res.status(err.response.status).json({ error: err.response.status });
});
});
Expand Down
2 changes: 1 addition & 1 deletion api/main_endpoints/util/cleezyHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let URL_SHORTENER_BASE_URL =
const searchCleezyUrls = async ({ page, search, sortColumn, sortOrder, limit }) => {
try {
const cleezyQuery = search?.replace(/[^a-zA-Z0-9]/g, '');
const cleezyRes = await axios.get(CLEEZY_URL + '/list', {
const cleezyRes = await axios.get(CLEEZY_URL + '/url/list', {
params: {
page,
...(cleezyQuery !== undefined && { search: cleezyQuery }),
Expand Down
2 changes: 1 addition & 1 deletion nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ http {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

proxy_pass http://cleezy-app/find/$alias;
proxy_pass http://cleezy-app/url/find/$alias;
}

location ~ ^/qr/(?<alias>.*)$ {
Expand Down
Loading