Skip to content

Commit 4355374

Browse files
committed
fixing db
1 parent c425458 commit 4355374

30 files changed

+47
-805
lines changed

CHANGELOG.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@
1010
- [js-node/expressjs] webpush push notification sample [sample](js-node/expressjs/public/demo-express/pn.html)
1111
- [js-node/expressjs] SSO (OAuth, OIDC, SAML) sample [sample](js-node/expressjs/public/demo-express/sso.html)
1212
- [js-node/expressjs] try to removed passport & passport-saml, use @node-saml/node-saml
13-
- [wip] to use Typescript and tsoa ? or use JSDoc?
13+
- [js-node/expressjs] remove sentry, APM for userland to choose and implement
14+
- [@es-labs/node] SSO for oidc to opt to use IDP or issue own token
15+
- [@es-labs/node] make APP_NAME and NODE_ENV from env var only
16+
- [js-node/dbdeploy] db might be shared... so create a seperate project for it (move existing deploy/db folder)
17+
- [tbd] work to remove APP_NAME in @es-labs/node
18+
- [tbd] clean up auth in @es-labs/node
19+
- [tbd] move error handling to @ss-labs/node/express/init or preRoute
20+
- [tbd] to use Typescript and tsoa ? or use JSDoc?
1421

1522
### Version 0.6.11
1623
- [chore] update packages & cleanup & work on improving documentation

README.md

+13-21
Original file line numberDiff line numberDiff line change
@@ -52,43 +52,35 @@ AMP Website | [removed](https://plausible.io/blog/google-amp) | -
5252
npm i -g npm@latest
5353

5454

55-
## Install And Migrate DB And Seed DB
55+
## Getting Started
56+
### Install
5657

5758
```bash
5859
# clone repo
5960
git clone https://github.com/ais-one/cookbook.git
6061
cd cookbook
6162

6263
# install dependencies for all workspace projects
63-
npm i
64+
# see package.json for shortcut scripts
65+
npm i --workspace=js-node/expressjs
66+
npm i --workspace=js-node/dbdeploy
6467

6568
# OR install only for express backend
6669
npm run ex:build # see ./package.json scripts
67-
68-
# seed data for the express backend
69-
# create and seed relational db on SQLite, (delete the dev.sqlite file each time before you run this)
70-
# command: npm run knex -- <development / uat / production> <custom app name> <seed / migrate>
71-
npm run ex:migrate # see ./package.json scripts
72-
npm run ex:seed # see ./package.json scripts
73-
74-
# create and seed MongoDB requires MongoDB - you can skip this but MongoDB examples will not work
75-
# command: npm run mongo -- <development / uat / production> <custom app name> <seed / update>
76-
# npm run mongo --workspace=js-node/expressjs -- development app-template seed
7770
```
7871

79-
## Run ExpressJS Backend - development environment
72+
### Migrate DB And Seed DB
8073

81-
```bash
82-
npm run ex:start # see ./package.json scripts
74+
Go to [dbdeploy](../dbdeploy/README.md) project and follow instructions for creating local development db on sqlite
8375

84-
# OR
85-
# command: npm run app --workspace=js-node/expressjs -- <development / uat / production> <custom app name, default = app-template>
86-
npm run app --workspace=js-node/expressjs -- development
87-
npm run app --workspace=js-node/expressjs -- development app-template # app name specified
76+
### Run ExpressJS Backend - development environment
8877

78+
```bash
79+
npm run ex:start # NODE_ENV=development npm run app --workspace=js-node/expressjs in package.json
80+
# use ex:start:win for Windows OS
8981

9082
# OR to include eslint checks
91-
npm run app:lint --workspace=js-node/expressjs -- development app-template
83+
NODE_ENV=development npm run app:lint --workspace=js-node/expressjs
9284
```
9385

9486
**NOTES**
@@ -144,7 +136,7 @@ Why No SSR or SSG:
144136
- SAML & OIDC: requires keycloak to be setup and express server to be run
145137
- Setup and Configure [Keycloak](docker-devenv/keycloak/README.md)
146138
- You can test out on [sso.html](http://127.0.0.1:3000/sso.html). The file source is [js-node/expressjs/public/demo-express/sso.html]()
147-
- for SAML and OIDC... credentials is `user` / `user`, redirect to the keycloak IDP
139+
- for SAML and OIDC... credentials is `test` / `test`, redirect to the keycloak IDP
148140
- Refer also to the following files
149141
- ./js-node/expressjs/router/saml.js
150142
- ./js-node/expressjs/router/oidc.js

docker-devenv/keycloak/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ Add new realm with import using the file [realm-export.json](realm-export.json)
2929

3030
### Realm User
3131

32-
- Create User named: user
33-
- Add password credentials named: user
32+
- Create User named: test
33+
- Add password credentials named: test
3434

3535
### Realm Client - OIDC
3636

docker-devenv/keycloak/realm-export.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,9 @@
426426
"otpPolicyPeriod": 30,
427427
"otpPolicyCodeReusable": false,
428428
"otpSupportedApplications": [
429-
"totpAppFreeOTPName",
430429
"totpAppGoogleName",
431-
"totpAppMicrosoftAuthenticatorName"
430+
"totpAppMicrosoftAuthenticatorName",
431+
"totpAppFreeOTPName"
432432
],
433433
"webAuthnPolicyRpEntityName": "keycloak",
434434
"webAuthnPolicySignatureAlgorithms": [

js-node/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Below are a list of NodeJS applications
44

5+
- dbdeploy
6+
- see [dbdeploy/README.md](expressjs/README.md)
57
- expressjs
68
- see [expressjs/README.md](expressjs/README.md)
79
- jsdoc-ts

js-node/expressjs/app.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const server = HTTPS_CERTIFICATE ? https.createServer(https_opts, app) : http.cr
4848

4949
require('@es-labs/node/express/preRoute')(app, express)
5050
const graphqlWsServer = require('@es-labs/node/express/graphql')(app, server)
51-
const Sentry = require('@es-labs/node/express/sentry')(app)
51+
// add APM tool here
5252

5353
// CLEANUP
5454
const cleanup = async (message, exitCode = 0, coreDump = false, timeOutMs = 1000) => {
@@ -101,8 +101,6 @@ server.on('upgrade', (request, socket, head) => {
101101

102102
require('@es-labs/node/express/postRoute')(app, express)
103103

104-
if (Sentry) app.use(Sentry.Handlers.errorHandler())
105-
106104
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
107105
// 'Bad Request': 400, 'Unauthorized': 401, 'Forbidden': 403, 'Not Found': 404, 'Conflict': 409, 'Unprocessable Entity': 422, 'Internal Server Error': 500,
108106
app.use((error, req, res, next) => { // error middleware - 200s should not reach here

js-node/expressjs/apps/app-template/.env.sample

-6
Original file line numberDiff line numberDiff line change
@@ -361,12 +361,6 @@ GRAPHQL_SCHEMA_PATH=
361361
GRAPHQL_URL=/graphql
362362
GRAPHQL_SUB_URL=/subscriptions
363363

364-
# sentry.io
365-
SENTRY_DSN=
366-
# SENTRY_DSN=https://[email protected]/5868141
367-
SENTRY_SAMPLE_RATE=1.0
368-
SENTRY_REQOPTS=
369-
370364

371365
JWT_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----
372366
MIICXgIBAAKBgQDQIwMrGPHdUNJJaZaPCtU+mD+/4C3WVuYpHUdUKWc1BBX4/FPo

js-node/expressjs/apps/app-template/deploy/db/icc.json

-1
This file was deleted.

js-node/expressjs/apps/app-template/deploy/db/knex/index.js

-14
This file was deleted.

js-node/expressjs/apps/app-template/deploy/db/knex/migrations/20180927133438_create_users.js

-41
This file was deleted.

0 commit comments

Comments
 (0)