見出し画像

DOAP2023開発日記 #1

コードネームDOAP2022の開発を中断して数ヶ月。何をしていたのか、きれいさっぱり忘れている。理由ははっきりしている。メモを取らないからだ。開発中はコードの末端まで記憶できるのに、数日触れていないだけで曖昧になり、一月以上離れると記憶喪失になる。そんなことではいけないことはわかっている。だから、記録していこう。

DOAPとは

DOAPは、Domino OAuth2 Providerの略で、DominoサーバにOAuth2サービス機能を追加し、利用したいWebアプリケーションにNotes/Dominoユーザでログインできるようにする。ちなみに初版は2018年。私の技術の向上と、限定的な機能を強化するために、システムを刷新する。

新規Sailsサーバの作成

まず、DominoにOAuth2でアクセスするクライアント用Webアプリを作成する。Webアプリは、バックエンドにSails.jsサーバ、フロントエンドにNext.jsを使う。

まずはWebアプリのバックエンドを作成する。

$ node -v
v12.22.7

$ npm -v
6.14.15

$ npx sails new server2023
npx: 230個のパッケージを9.983秒でインストールしました。
 Choose a template for your new Sails app:
 1. Web App  ·  Extensible project with auth, login, & password recovery
 2. Empty    ·  An empty Sails app, yours to configure
 (type "?" for help, or <CTRL+C> to cancel)
? 2
 info: Installing dependencies...
Press CTRL+C to cancel.
(to skip this step in the future, use --fast)
 info: Created a new Sails app `server-2023`!

$ cd server2023

どんなパッケージがインストールされたのか、package.jsonを確認してみる。

{
  "name": "server-2023",
  "private": true,
  "version": "0.0.0",
  "description": "a Sails application",
  "keywords": [],
  "dependencies": {
    "sails": "^1.5.2",
    "grunt": "1.0.4",
    "sails-hook-grunt": "^5.0.0",
    "sails-hook-orm": "^4.0.0",
    "sails-hook-sockets": "^2.0.0",
    "@sailshq/connect-redis": "^3.2.1",
    "@sailshq/socket.io-redis": "^5.2.0",
    "@sailshq/lodash": "^3.10.3"
  },
  "devDependencies": {
    "eslint": "5.16.0"
  },
  "scripts": {
    "start": "NODE_ENV=production node app.js",
    "test": "npm run lint && npm run custom-tests && echo 'Done.'",
    "lint": "./node_modules/eslint/bin/eslint.js . --max-warnings=0 --report-unused-disable-directives && echo '✔  Your .js files look good.'",
    "custom-tests": "echo \"(No other custom tests yet.)\" && echo"
  },
  "main": "app.js",
  "repository": {
    "type": "git",
    "url": "git://github.com/tkondoh/server-2023.git"
  },
  "author": "tkondoh",
  "license": "",
  "engines": {
    "node": "^12.22"
  }
}

知らない間にsailsがv1.5になっている!

バージョン管理開始

次に、Gitでバージョン管理できるようにする。

$ git init
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint: 
hint:   git config --global init.defaultBranch <name>
hint: 
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint: 
hint:   git branch -m <name>
Initialized empty Git repository in /.../server2023/.git/

$ git config user.name "Takahide Kondoh"

$ git config user.email tkondoh@chiburu.com

$ touch CHANGELOG.md

CHANGELOG.mdを以下のように編集する。

# 変更ログ

## [master] 0.0.0.0-2022.06.18

* 新規作成。

最初の状態をコミットする。

$ git add -A

$ git commit -m 0.0.0.0-2022.06.18
[master (root-commit) f250961] 0.0.0.0-2022.06.18
 71 files changed, 11957 insertions(+)
 create mode 100644 .editorconfig
 create mode 100644 .eslintignore
 create mode 100644 .eslintrc
 create mode 100644 .gitignore
 create mode 100644 .npmrc
 create mode 100644 .sailsrc
 create mode 100644 CHANGELOG.md
 create mode 100644 Gruntfile.js
 create mode 100644 README.md
 create mode 100644 api/controllers/.gitkeep
 create mode 100644 api/helpers/.gitkeep
 create mode 100644 api/models/.gitkeep
 create mode 100644 api/policies/.gitkeep
 create mode 100644 app.js
 create mode 100644 assets/.eslintrc
 create mode 100644 assets/dependencies/.gitkeep
 create mode 100644 assets/dependencies/sails.io.js
 create mode 100644 assets/favicon.ico
 create mode 100644 assets/images/.gitkeep
 create mode 100644 assets/js/.gitkeep
 create mode 100644 assets/styles/importer.less
 create mode 100644 assets/templates/.gitkeep
 create mode 100644 config/blueprints.js
 create mode 100644 config/bootstrap.js
 create mode 100644 config/custom.js
 create mode 100644 config/datastores.js
 create mode 100644 config/env/production.js
 create mode 100644 config/globals.js
 create mode 100644 config/http.js
 create mode 100644 config/i18n.js
 create mode 100644 config/locales/de.json
 create mode 100644 config/locales/en.json
 create mode 100644 config/locales/es.json
 create mode 100644 config/locales/fr.json
 create mode 100644 config/log.js
 create mode 100644 config/models.js
 create mode 100644 config/policies.js
 create mode 100644 config/routes.js
 create mode 100644 config/security.js
 create mode 100644 config/session.js
 create mode 100644 config/sockets.js
 create mode 100644 config/views.js
 create mode 100644 package-lock.json
 create mode 100644 package.json
 create mode 100644 tasks/config/babel.js
 create mode 100644 tasks/config/clean.js
 create mode 100644 tasks/config/concat.js
 create mode 100644 tasks/config/copy.js
 create mode 100644 tasks/config/cssmin.js
 create mode 100644 tasks/config/hash.js
 create mode 100644 tasks/config/less.js
 create mode 100644 tasks/config/sails-linker.js
 create mode 100644 tasks/config/sync.js
 create mode 100644 tasks/config/uglify.js
 create mode 100644 tasks/config/watch.js
 create mode 100644 tasks/pipeline.js
 create mode 100644 tasks/register/build.js
 create mode 100644 tasks/register/buildProd.js
 create mode 100644 tasks/register/compileAssets.js
 create mode 100644 tasks/register/default.js
 create mode 100644 tasks/register/linkAssets.js
 create mode 100644 tasks/register/linkAssetsBuild.js
 create mode 100644 tasks/register/linkAssetsBuildProd.js
 create mode 100644 tasks/register/polyfill.js
 create mode 100644 tasks/register/prod.js
 create mode 100644 tasks/register/syncAssets.js
 create mode 100644 views/.eslintrc
 create mode 100644 views/404.ejs
 create mode 100644 views/500.ejs
 create mode 100644 views/layouts/layout.ejs
 create mode 100644 views/pages/homepage.ejs

動作確認

念のため動作確認する。

$ npx sails lift

 info: Starting app...

 info: 
 info:                .-..-.
 info: 
 info:    Sails              <|    .-..-.
 info:    v1.5.2              |\
 info:                       /|.\
 info:                      / || \
 info:                    ,'  |'  \
 info:                 .-'.-==|/_--'
 info:                 `--'-------' 
 info:    __---___--___---___--___---___--___
 info:  ____---___--___---___--___---___--___-__
 info: 
 info: Server lifted in `/.../server2023`
 info: To shut down Sails, press <CTRL> + C at any time.
 info: Read more at https://sailsjs.com/support.

debug: -------------------------------------------------------
debug: :: Sat Jun 18 2022 14:18:44 GMT+0900 (GMT+09:00)

debug: Environment : development
debug: Port        : 1337
debug: -------------------------------------------------------

http://localhost:1337にアクセスする

Sailsホーム画面

まとめ

まずはクライアントアプリのWebサーバをNode.js/Sails.jsでひな形を作ってみた。

この記事が気に入ったらサポートをしてみませんか?