Skip to content

Commit

Permalink
refactor(ff-api): rename storageClient
Browse files Browse the repository at this point in the history
  • Loading branch information
alimd committed Dec 17, 2022
1 parent 2df46a9 commit 047a95b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion uniquely/flight-finder-api/src/lib/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import {config} from '../config.js';

import type {Job} from './type.js';

export const storage = new AlwatrStorageClient<Job>(config.storage);
export const storageClient = new AlwatrStorageClient<Job>(config.storage);
4 changes: 2 additions & 2 deletions uniquely/flight-finder-api/src/route/job/delete.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {config, logger} from '../../config.js';
import {nanoServer} from '../../lib/nano-server.js';
import {storage} from '../../lib/storage.js';
import {storageClient} from '../../lib/storage.js';

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

Expand All @@ -16,7 +16,7 @@ async function deleteJob(connection: AlwatrConnection): Promise<void> {
if (params === null) return;

try {
await storage.delete(params.id);
await storageClient.delete(params.id);
connection.reply({
ok: true,
data: {},
Expand Down
7 changes: 2 additions & 5 deletions uniquely/flight-finder-api/src/route/job/get.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {config, logger} from '../../config.js';
import {nanoServer} from '../../lib/nano-server.js';
import {storage} from '../../lib/storage.js';
import {storageClient} from '../../lib/storage.js';

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

Expand All @@ -13,10 +13,7 @@ async function getJob(connection: AlwatrConnection): Promise<void> {
if (connection.requireToken(config.nanoServer.accessToken) == null) return;

try {
connection.reply({
ok: true,
data: await storage.getAll(),
});
connection.reply(await storageClient.getStorage());
}
catch (err) {
logger.error('getJob', (err as Error).message ?? 'storage_error', (err as Error).stack ?? err);
Expand Down
6 changes: 3 additions & 3 deletions uniquely/flight-finder-api/src/route/job/put.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {config, logger} from '../../config.js';
import {nanoServer} from '../../lib/nano-server.js';
import {storage} from '../../lib/storage.js';
import {storageClient} from '../../lib/storage.js';

import type {Job} from '../../lib/type.js';
import type {AlwatrConnection} from '@alwatr/nano-server';
Expand All @@ -20,7 +20,7 @@ async function newJob(connection: AlwatrConnection): Promise<void> {
job.resultList = [];

try {
if (job.id !== 'auto_increment' && (await storage.has(job.id))) {
if (job.id !== 'auto_increment' && (await storageClient.has(job.id))) {
return connection.reply({
ok: false,
statusCode: 400,
Expand All @@ -31,7 +31,7 @@ async function newJob(connection: AlwatrConnection): Promise<void> {
connection.reply({
ok: true,
// FIXME:
data: (await storage.set(job)) as unknown as Record<string, unknown>,
data: (await storageClient.set(job)) as unknown as Record<string, unknown>,
});
}
catch (err) {
Expand Down

0 comments on commit 047a95b

Please sign in to comment.