DEV Community Follow A space to discuss and keep up software development and manage your software career

For our back-end here at Plato, we decided to give NestJS a try. NestJS is easy to set up, it helps consistency and modularity, and integrate easily with the powerful TypeORM library. As our POC started to grow, we wanted to improve the robustness of our project by adding integration tests. We already had a decent code coverage but unit tests are not quite enough as it forces us to hide the comple
TypeORM x AuroraDataAPI - TIMEZONE問題への対処 ローカルタイムゾーンがJSTだとしたとき、 DBに書き込まれる時刻が9時間未来になる(JSTのまま書かれてしまう) DBから読み込まれる時刻が9時間過去になる(JST扱いで読まれてくる)問題への対処です。 前置き 本記事の解決法では、TypeORMの外側で自力で時刻を補正するため、 ライブラリ(TypeORMとAuroraプラグイン)の仕様が変わったり、バグが治った場合は毒になりえます。 そのへんの影響まで自分で管理してやんよシュババってひとむけです。 環境 Aurora Serverless MySQL 5.6 time_zone, system_time_zone: UTC TypeORM 0.2.24 typeorm-aurora-data-api-driver 1.1.8 Node 10 timezo
このようにさまざまなデコレータが用意されていますが、今回はサンプルで利用するデコレータに絞って説明します。他のデコレータについては、NestJSの公式ドキュメントなどを参照してください。 依存性注入(DI) 依存性注入(DI、Dependency Injection)とは、クラスの依存関係を解決する仕組みです。NestJSでは、依存性注入を使ってクラスの依存関係を解決します。 クラスの依存関係とは、クラスが他のクラスに依存している関係のことです。例えば、次のようなクラスAがあったとします。このクラスは他のクラスに依存していません。@Injectable()デコレータを使って、サービスを定義します。 @Injectable() class A { constructor() {} } そして、次のようなクラスBがあったとします。このクラスは、@Inject()デコレータを使って依存性を注入し
Query Builderを利用してSQLクエリを構築することができます。ここでは、基本的なSQLクエリ(SELECT, INSERT, UPDATE, DELETE)の構築方法を確認していきます。 QueryBuilderについて 使用方法 Connection Repository から QueryBuilder のインスタンスを取得できます。 また、QueryBuilderクラス を継承しているクラス( SelectQueryBuilder InsertQueryBuilder UpdateQueryBuilder DeleteQueryBuilder RelationQueryBuilder)が存在しており、それぞれ目的別に必要な機能が提供されています。 下記コードで確認します。 import { createConnection, getRepository } from 'ty
結論 ormconfig.jsに以下を追記する timezone: "Z", GitHubに上がっている公式のドキュメントに記載の通り、デフォルトは”local”になっており、ユーザのローカルのタイムゾーンが使われる。ちなみに、Zは「グリニッジ標準時<GMT>」を意味する略語。 timezone – the timezone configured on the MySQL server. This is used to typecast server date/time values to JavaScript Date object and vice versa. This can be local, Z, or an offset in the form +HH:MM or -HH:MM. (Default: local) https://github.com/typeorm/type
May 25, 2020 1. API with NestJS #1. Controllers, routing and the module structure 2. API with NestJS #2. Setting up a PostgreSQL database with TypeORM 3. API with NestJS #3. Authenticating users with bcrypt, Passport, JWT, and cookies 4. API with NestJS #4. Error handling and data validation 5. API with NestJS #5. Serializing the response with interceptors 6. API with NestJS #6. Looking into depen
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く