Skip to content

Commit

Permalink
iroiro dependency and eslint ijitta
Browse files Browse the repository at this point in the history
  • Loading branch information
pizzacat83 committed Mar 26, 2023
1 parent 726eafb commit 0ea119e
Show file tree
Hide file tree
Showing 7 changed files with 386 additions and 158 deletions.
3 changes: 1 addition & 2 deletions aws/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"@aws-sdk/client-ssm": "^3.299.0",
"@aws-sdk/client-sts": "^3.299.0",
"@aws-sdk/lib-dynamodb": "^3.299.0",
"@aws/dynamodb-data-mapper-annotations": "^0.7.3",
"@slack/web-api": "6",
"@tsconfig/node18": "^1.0.1",
"@types/common-tags": "^1.8.1",
Expand Down Expand Up @@ -60,7 +59,7 @@
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-react": "^7.26.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-unicorn": "^29.0.0",
"eslint-plugin-unicorn": "^32.0.1",
"fork-ts-checker-webpack-plugin": "^6.3.3",
"jest": "^26.6.3",
"serverless": "^2.65.0",
Expand Down
9 changes: 5 additions & 4 deletions aws/src/lib/aws/dynamodb/tiny-storage.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { GetCommand, PutCommand } from '@aws-sdk/lib-dynamodb';
import type { Option } from 'ts-results';
import { None, Some } from 'ts-results';
import { resourcePrefix } from '../utils';
Expand All @@ -12,29 +13,29 @@ export class TinyStorage<Content> {
) {}

async get(): Promise<Option<Item<Content>>> {
const result = await dynamodb.get({
const result = await dynamodb.send(new GetCommand({
/* eslint-disable @typescript-eslint/naming-convention */
TableName: tableName,
Key: {
key: this.key,
},
/* eslint-enable @typescript-eslint/naming-convention */
}).promise();
}));

return result.Item === undefined ?
None :
Some(result.Item as Item<Content>);
}

async set(value: Content): Promise<void> {
await dynamodb.put({
await dynamodb.send(new PutCommand({
/* eslint-disable @typescript-eslint/naming-convention */
TableName: tableName,
Item: {
key: this.key,
...value,
},
/* eslint-enable @typescript-eslint/naming-convention */
}).promise();
}));
}
}
2 changes: 1 addition & 1 deletion aws/src/lib/cache-calls.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { cacheCalls } from './cache-calls';

// async identity function
const slowAsync_ = async (result: number) => {
await promisify((...args) => process.nextTick(...args))();
await promisify((...args) => { process.nextTick(...args); })();
return result;
};

Expand Down
1 change: 1 addition & 0 deletions aws/src/lib/envvar/local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class EnvVarLocal implements EnvVar {
async loadEnv() {
const envvarObj = JSON.parse(await fs.readFile(
path.join(
// eslint-disable-next-line unicorn/prefer-module
__dirname, // envvar
'..', // lib
'..', // src
Expand Down
2 changes: 2 additions & 0 deletions aws/src/lib/slack/timestamp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import { datetimeToSlackTS, slackTSToDateTime } from './timestamp';

describe('datetimeToSlackTS', () => {
it('converts Date object to timestamp', () => {
// eslint-disable-next-line unicorn/numeric-separators-style
expect(datetimeToSlackTS(DateTime.fromMillis(1234567890123).setZone('Asia/Tokyo'))).toBe('1234567890.123000');
});
});

describe('slackTSToDateTime', () => {
it('converts timestamp to Date object', () => {
// eslint-disable-next-line unicorn/numeric-separators-style
expect(slackTSToDateTime('1234567890.123000')).toEqual(DateTime.fromMillis(1234567890123).setZone('Asia/Tokyo'));
});
});
2 changes: 1 addition & 1 deletion aws/src/watch-inshi/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const loadOldText = async (): Promise<Option<string>> => {
/* eslint-enable @typescript-eslint/naming-convention */
});
assert(res.Body !== undefined);
return Some(res.Body.toString());
return Some(await res.Body.transformToString());
} catch (error) {
if (error instanceof NoSuchKey) {
return None;
Expand Down

0 comments on commit 0ea119e

Please sign in to comment.