Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update api paths #645

Merged
merged 1 commit into from
Sep 27, 2023
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
2 changes: 1 addition & 1 deletion packages/client/src/components/About.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default {

showSystemInfo() {
this.$emit('mask', 1);
Common.fetch('system').then(data => {
Common.fetch('api/v1/system').then(data => {
this.systemInfoDialog = true;
this.systemInfo = data;
this.$emit('mask', -1);
Expand Down
16 changes: 8 additions & 8 deletions packages/client/src/components/Files.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
</template>

<template v-if="thumbnails.show" #[`item.thumb`]="{ item }">
<v-img :src="`./files/${item.columns.name}/thumbnail`"
<v-img :src="`api/v1/files/${item.columns.name}/thumbnail`"
width="128"
:max-height="thumbnails.size" :max-width="thumbnails.size"
:contain="true" />
Expand Down Expand Up @@ -174,7 +174,7 @@ export default {
methods: {
actionList() {
this.$emit('mask', 1);
Common.fetch('context').then(context => {
Common.fetch('api/v1/context').then(context => {
this.actions = context.actions;
this.$emit('mask', -1);
}).catch(error => {
Expand All @@ -185,7 +185,7 @@ export default {

fileList() {
this.$emit('mask', 1);
Common.fetch('files').then(files => {
Common.fetch('api/v1/files').then(files => {
this.files = files;
this.$emit('mask', -1);
}).catch(error => {
Expand All @@ -196,7 +196,7 @@ export default {

fileRemove(file) {
this.$emit('mask', 1);
Common.fetch(`files/${file.name}`, {
Common.fetch(`api/v1/files/${file.name}`, {
method: 'DELETE'
}).then(data => {
this.$emit('notify', {type: 'i', message: `${this.$t('files.message:deleted', [data.name])}`});
Expand All @@ -217,7 +217,7 @@ export default {

renameFileConfirm() {
this.$emit('mask', 1);
Common.fetch(`files/${this.editedItem.name}`, {
Common.fetch(`api/v1/files/${this.editedItem.name}`, {
method: 'PUT',
headers: {
'Accept': 'application/json',
Expand Down Expand Up @@ -250,7 +250,7 @@ export default {
refresh = true;
const name = this.selectedFiles[0].name;
try {
await Common.fetch(`files/${name}`, {method: 'DELETE'});
await Common.fetch(`api/v1/files/${name}`, {method: 'DELETE'});
this.$emit('notify', {type: 'i', message: `${this.$t('files.message:deleted', [name])}`});
} catch (error) {
this.$emit('notify', {type: 'e', message: error});
Expand All @@ -269,7 +269,7 @@ export default {
refresh = true;
const filename = this.selectedFiles[0].name;
try {
await Common.fetch(`files/${filename}/actions/${actionName}`, {method: 'POST'});
await Common.fetch(`api/v1/files/${filename}/actions/${actionName}`, {method: 'POST'});
this.$emit('notify', {type: 'i', message: `${this.$t('files.message:action', [actionName, filename])}`});
} catch (error) {
this.$emit('notify', {type: 'e', message: error});
Expand All @@ -283,7 +283,7 @@ export default {
},

open(file) {
window.location.href = `files/${file.name}`;
window.location.href = `api/v1/files/${file.name}`;
},

selectToggle(value) {
Expand Down
12 changes: 6 additions & 6 deletions packages/client/src/components/Scan.vue
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ export default {

let data = Common.clone(this.request);

this._fetch('preview', {
this._fetch('api/v1/preview', {
method: 'POST',
body: JSON.stringify(data),
headers: {
Expand All @@ -383,7 +383,7 @@ export default {

deletePreview() {
this.mask(1);
Common.fetch('preview', {
Common.fetch('api/v1/preview', {
method: 'DELETE'
}).then(() => {
this.notify({ type: 'i', message: this.$t('scan.message:deleted-preview') });
Expand Down Expand Up @@ -489,7 +489,7 @@ export default {
this.notify({ type: 'i', message: this.$t('scan.message:loading-devices') });
}, 250);

return this._fetch('context').then(context => {
return this._fetch('api/v1/context').then(context => {
window.clearTimeout(timer);

if (context.devices && context.devices.length > 0) {
Expand All @@ -508,7 +508,7 @@ export default {
},

deviceRefresh() {
this._fetch('context', {
this._fetch('api/v1/context', {
method: 'DELETE'
}).then(() => {
this.readContext();
Expand All @@ -517,7 +517,7 @@ export default {

readPreview() {
// Gets the preview image as a base64 encoded jpg and updates the UI
const uri = 'preview?' + new URLSearchParams(
const uri = 'api/v1/preview?' + new URLSearchParams(
this.request.filters.map(e => ['filter', e]));

this._fetch(uri, {
Expand Down Expand Up @@ -551,7 +551,7 @@ export default {
}

const data = Common.clone(this.request);
this._fetch('scan', {
this._fetch('api/v1/scan', {
method: 'POST',
body: JSON.stringify(data),
headers: {
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/components/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export default {

reset() {
this.$emit('mask', 1);
Common.fetch('context', {
Common.fetch('api/v1/context', {
method: 'DELETE'
}).then(() => {
this.$emit('mask', -1);
Expand Down
6 changes: 1 addition & 5 deletions packages/client/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@ import packageJson from './package.json'
export default defineConfig({
server: {
proxy: {
'/api': 'http://localhost:8080',
'/api-docs': 'http://localhost:8080',
'/context': 'http://localhost:8080',
'/files': 'http://localhost:8080',
'/preview': 'http://localhost:8080',
'/scan': 'http://localhost:8080',
'/system': 'http://localhost:8080',
}
},
plugins: [
Expand Down
26 changes: 13 additions & 13 deletions packages/server/src/express-configurer.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,25 +60,25 @@ function formatForLog(req) {
const EndpointSpecs = [
{
method: 'delete',
path: '/context',
path: '/api/v1/context',
callback: async (req, res) => {
api.deleteContext();
res.send({});
}
},
{
method: 'get',
path: '/context',
path: '/api/v1/context',
callback: async (req, res) => res.send(await api.readContext())
},
{
method: 'get',
path: '/files',
path: '/api/v1/files',
callback: async (req, res) => res.send(await api.fileList())
},
{
method: 'post',
path: /\/files\/([^/]+)\/actions\/([^/]+)/,
path: /\/api\/v1\/files\/([^/]+)\/actions\/([^/]+)/,
callback: async (req, res) => {
const fileName = req.params[0];
const actionName = req.params[1];
Expand All @@ -88,7 +88,7 @@ const EndpointSpecs = [
},
{
method: 'get',
path: /\/files\/([^/]+)\/thumbnail/,
path: /\/api\/v1\/files\/([^/]+)\/thumbnail/,
callback: async (req, res) => {
const name = req.params[0];
const buffer = await api.readThumbnail(name);
Expand All @@ -98,7 +98,7 @@ const EndpointSpecs = [
},
{
method: 'get',
path: /\/files\/([^/]+)/,
path: /\/api\/v1\/files\/([^/]+)/,
callback: async (req, res) => {
const name = req.params[0];
const file = FileInfo.unsafe(config.outputDirectory, name);
Expand All @@ -107,12 +107,12 @@ const EndpointSpecs = [
},
{
method: 'delete',
path: '/files/*',
path: '/api/v1/files/*',
callback: async (req, res) => res.send(api.fileDelete(req.params[0]))
},
{
method: 'put',
path: '/files/*',
path: '/api/v1/files/*',
callback: async (req, res) => {
const name = req.params[0];
const newName = req.body.newName;
Expand All @@ -126,7 +126,7 @@ const EndpointSpecs = [
},
{
method: 'get',
path: '/preview',
path: '/api/v1/preview',
callback: async (req, res) => {
const buffer = await api.readPreview(req.query.filter);
res.send({
Expand All @@ -136,22 +136,22 @@ const EndpointSpecs = [
},
{
method: 'delete',
path: '/preview',
path: '/api/v1/preview',
callback: async (req, res) => res.send(api.deletePreview())
},
{
method: 'post',
path: '/preview',
path: '/api/v1/preview',
callback: async (req, res) => res.send(await api.createPreview(req.body))
},
{
method: 'post',
path: '/scan',
path: '/api/v1/scan',
callback: async (req, res) => res.send(await api.scan(req.body))
},
{
method: 'get',
path: '/system',
path: '/api/v1/system',
callback: async (req, res) => res.send(await api.readSystem())
}
];
Expand Down
16 changes: 8 additions & 8 deletions packages/server/src/swagger.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
paths:
/context:
/api/v1/context:
delete:
summary: Deletes cached context
description: |
Expand Down Expand Up @@ -30,7 +30,7 @@ paths:
schema:
$ref: '#/definitions/Context'

/files:
/api/v1/files:
get:
summary: List all scanned files
description: |
Expand All @@ -47,7 +47,7 @@ paths:
items:
$ref: '#/definitions/FileInfo'

/files/{filename}:
/api/v1/files/{filename}:
delete:
summary: Deletes a scanned file
description: |
Expand Down Expand Up @@ -121,7 +121,7 @@ paths:
'200':
description: OK

/files/{filename}/thumbnail:
/api/v1/files/{filename}/thumbnail:
get:
summary: Gets an image thumbnail
description: |
Expand All @@ -142,7 +142,7 @@ paths:
'200':
description: OK

/files/{filename}/actions/{actionName}:
/api/v1/files/{filename}/actions/{actionName}:
post:
summary: Performs an action on a file
description: |
Expand All @@ -167,7 +167,7 @@ paths:
'200':
description: OK

/preview:
/api/v1/preview:
delete:
summary: Deletes the currently stored preview
description: |
Expand Down Expand Up @@ -230,7 +230,7 @@ paths:
type: object
example: {}

/scan:
/api/v1/scan:
post:
summary: Create a scan
description: |
Expand All @@ -257,7 +257,7 @@ paths:
schema:
$ref: '#/definitions/ScanResponse'

/system:
/api/v1/system:
get:
summary: Gets host system information
description: |
Expand Down
Loading