Skip to content

Commit

Permalink
fix(storage-server): return value
Browse files Browse the repository at this point in the history
  • Loading branch information
AliMD authored and njfamirm committed May 18, 2023
1 parent 0601384 commit 6e31502
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions services/storage-server/src/route/get.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@

import {config, logger} from '../config.js';
import {nanoServer} from '../lib/nano-server.js';
import {storageProvider} from '../lib/storage-provider.js';

import type {AlwatrConnection, AlwatrServiceResponse} from '@alwatr/nano-server';
import type {StringifyableRecord} from '@alwatr/type';

nanoServer.route('GET', '/', getDocument);
import type {Stringifyable} from '@alwatr/type';

function getDocument(connection: AlwatrConnection): AlwatrServiceResponse<StringifyableRecord, StringifyableRecord> {
nanoServer.route<Stringifyable>('GET', '/', (connection) => {
logger.logMethod?.('getDocument');

if (!connection.url.search) {
Expand All @@ -29,16 +25,8 @@ function getDocument(connection: AlwatrConnection): AlwatrServiceResponse<String

const document = storageEngine.get(params.id, true);

if (document == null) {
return {
ok: false,
statusCode: 404,
errorCode: 'document_not_found',
};
}

return {
ok: true,
data: document,
};
}
});

0 comments on commit 6e31502

Please sign in to comment.