Skip to content

baron-todo-app/server

Repository files navigation

通常の開発環境

初回のみ

git clone https://github.com/baron-todo-app/server
cd server
git submodule update --init --recursive


# db のみ起動 して nodeはローカルで dockerのホットリロードが遅いため
docker-compose up --build -d app_db;  docker-compose ps

# npm
yarn 


# マイグレーション 実行
yarn ts-node $(npm bin)/typeorm migration:run

# DB ドキュメント
docker-compose up app_db schemaspy
# schemaspy_local exited with code 0
# ctrl + c
yarn http-server doc/schemaspy

# コードドキュメント
yarn compodoc -p tsconfig.json -d doc/compodoc
yarn http-server doc/compodoc -p 8081

# test
yarn test:cov
yarn http-server doc/coverage/lcov-report -p 8082

# 起動
yarn start:dev

# GQL
# http://localhost:5000/voyager
# http://localhost:5000/graphql

# DB 
# http://127.0.0.1:8080

# コードドキュメント
# http://127.0.0.1:8081

# カバレッジ
# http://127.0.0.1:8082

2回目以降

# db のみ起動 して nodeはローカルで dockerのホットリロードが遅いため
docker-compose up --build -d app_db;  docker-compose ps

# 起動
yarn start:dev

mysql 接続

mysql -uroot -p -h 127.0.0.1

開発環境でのテスト

# DB関連の操作不可 -> つまり mockにする
# nestjsの思想, unit testの思想
yarn test

TypeORM で マイグレーション (初回)

xxx.entity.ts でモデル定義

# マイグレーションファイル作成
yarn ts-node $(npm bin)/typeorm migration:generate -n Initialize

# マイグレーション 実行
yarn ts-node $(npm bin)/typeorm migration:run

# マイグレーション 戻し
yarn ts-node $(npm bin)/typeorm migration:revert

TypeORM で マイグレーション (2回目以降)

# マイグレーション 実行
yarn ts-node $(npm bin)/typeorm migration:run

TypeORM で Alter Table したい

xxx.entity.ts でモデル更新

# これを育てる
typeorm migration:create -n Xxx

https://github.com/typeorm/typeorm/blob/master/docs/migrations.md

他に方法無し...

TypeOrm テーブル コメントつけたい

たぶん、今のとこはない 追加予定らしい

ALTER TABLE xxx COMMENT 'タスクを管理'

GQL memo

query  {
  foo: getTasks(FreeWord: {txt: ""}) {
    id
    title
    body
  }
}

query  {
  cc: getTask(GetTask: {id: 1}) {
    id
    title
  }  
}

mutation {
  addTask(AddTask: {title: "aaa" body: "bbb"}) {
    id
    title
    body
  }
}

mutation {
  updateTask(
    UpdateTask:{
      id: 1
      title: "aaa"
      body: "bbb"
    }) {
    id
  }
}

mutation {
 deleteTask(DeleteTask:{id: 1}) {
     id
     title
 }
}

docker memo

# 初期
docker pull mysql:5.7.24
docker run -d --name mysql -e MYSQL_ROOT_PASSWORD=mysql -e MYSQL_DATABASE=task -p 3306:3306  mysql:5.7.24 --character-set-server=utf8 --collation-server=utf8_unicode_ci

# 開始
docker start mysql

# 停止
docker stop mysql

# 対話形式
docker exec -it mysql bash
mysql -uroot -p
mysql

sql memo

insert into task.todo (title, body) values ("aaa", "abcd efg");
insert into task.todo (title, body) values ("aaa", "100%");
insert into task.todo (title, body) values ("bbb", "0% % _");
insert into task.todo (title, body) values ("bbb", "hoge fuga");
insert into task.todo (title, body) values ("bbb", "100% 200% 300%");
insert into task.todo (title, body) values ("bbb", "__ abc efg");
insert into task.todo (title, body) values ("bbb", "\\");

select * from task.todo;
delete from task.todo; select * from task.todo;

drop database task; create database task;

url

doc

  • mysql
    • docker-compose up app_db schemaspy
  • compodoc
    • yarn compodoc -p tsconfig.json -d doc/compodoc
    • yarn compodoc -p tsconfig.json -s # サーバ起動

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications, heavily inspired by Angular.

NPM Version Package License NPM Downloads Travis Linux Coverage Gitter Backers on Open Collective Sponsors on Open Collective

Description

Nest framework TypeScript starter repository.

Installation

$ npm install

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Test

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.

Stay in touch

License

Nest is MIT licensed.

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published