@emseepea/create-mongodb-backed-server 0.0.8 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -84,9 +84,13 @@ Stop the server with Control-C. Remove the local database and volume when you
84
84
  no longer need them:
85
85
 
86
86
  ```sh
87
- docker compose down --volumes
87
+ npm run db:reset
88
88
  ```
89
89
 
90
+ `npm run db:reset` deletes the local MongoDB volume and its data. You cannot
91
+ undo this action. Docker Compose starts MongoDB for local development only. It
92
+ is not a production deployment recipe.
93
+
90
94
  For a managed MongoDB deployment, set `MONGODB_URL`, build, apply the collection
91
95
  schema once, then start the server:
92
96
 
@@ -103,6 +107,23 @@ Use the database name in the connection URL, such as
103
107
  Protect `MONGODB_URL` as a secret. Do not put it in source control or send it to
104
108
  an MCP client.
105
109
 
110
+ ## Build a production container
111
+
112
+ Run `npm install` first so the project has a lockfile. Then run:
113
+
114
+ ```sh
115
+ npm run container:build
116
+ ```
117
+
118
+ The image is for a production deployment behind a trusted proxy. It starts with
119
+ the fail-closed production profile and needs a runtime-mounted deployment
120
+ configuration file. Keep secrets, including `MONGODB_URL`, in your platform's
121
+ runtime secret store, not in the Dockerfile, build arguments, or deployment
122
+ configuration file.
123
+
124
+ For the production proxy, runtime configuration, and hardening requirements, see
125
+ the [container guide](https://emseepea.github.io/emseepea/examples/#build-a-production-container).
126
+
106
127
  ## Tools
107
128
 
108
129
  - `add-pea-variety` validates and inserts one document.
@@ -0,0 +1,17 @@
1
+ .env
2
+ .env.*
3
+ .git
4
+ .github
5
+ .npmrc
6
+ artifacts
7
+ coverage
8
+ dist
9
+ docs
10
+ eval
11
+ initializer-dist
12
+ node_modules
13
+ release-artifacts
14
+ test
15
+ test-support
16
+ *.log
17
+ *.tsbuildinfo
@@ -0,0 +1,19 @@
1
+ FROM docker.io/library/node:24.21.0-trixie-slim@sha256:db3ae80f5d8df06e04dabdf7b44cbf008d32de168205fa0294444aabbc08c590 AS build
2
+ WORKDIR /app
3
+ COPY . .
4
+ RUN test "$(node --version)" = "v24.21.0" \
5
+ && test -f package-lock.json \
6
+ && npm ci --ignore-scripts \
7
+ && npm run build \
8
+ && npm prune --omit=dev --ignore-scripts
9
+
10
+ FROM gcr.io/distroless/nodejs24-debian13:nonroot@sha256:7781e8b4fccf59240bd539af6738cccf8dad4be303165c3a1fa065c48699b937
11
+ WORKDIR /app
12
+ ENV EMSEEPEA_DEPLOYMENT_MODE=production-behind-proxy
13
+ COPY --from=build --chown=65532:65532 /app/package.json ./package.json
14
+ COPY --from=build --chown=65532:65532 /app/node_modules ./node_modules
15
+ COPY --from=build --chown=65532:65532 /app/dist ./dist
16
+ USER 65532:65532
17
+ EXPOSE 3000
18
+ HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 CMD ["/nodejs/bin/node", "-e", "const port=process.env.PORT||'3000';fetch(`http://127.0.0.1:${port}/healthz`).then((r)=>process.exit(r.ok?0:1),()=>process.exit(1));"]
19
+ CMD ["dist/server.js"]
@@ -55,9 +55,13 @@ Stop the server with Control-C. Remove the local database and volume when you
55
55
  no longer need them:
56
56
 
57
57
  ```sh
58
- docker compose down --volumes
58
+ npm run db:reset
59
59
  ```
60
60
 
61
+ `npm run db:reset` deletes the local MongoDB volume and its data. You cannot
62
+ undo this action. Docker Compose starts MongoDB for local development only. It
63
+ is not a production deployment recipe.
64
+
61
65
  For a managed MongoDB deployment, set `MONGODB_URL`, build, apply the collection
62
66
  schema once, then start the server:
63
67
 
@@ -74,6 +78,23 @@ Use the database name in the connection URL, such as
74
78
  Protect `MONGODB_URL` as a secret. Do not put it in source control or send it to
75
79
  an MCP client.
76
80
 
81
+ ## Build a production container
82
+
83
+ Run `npm install` first so the project has a lockfile. Then run:
84
+
85
+ ```sh
86
+ npm run container:build
87
+ ```
88
+
89
+ The image is for a production deployment behind a trusted proxy. It starts with
90
+ the fail-closed production profile and needs a runtime-mounted deployment
91
+ configuration file. Keep secrets, including `MONGODB_URL`, in your platform's
92
+ runtime secret store, not in the Dockerfile, build arguments, or deployment
93
+ configuration file.
94
+
95
+ For the production proxy, runtime configuration, and hardening requirements, see
96
+ the [container guide](https://emseepea.github.io/emseepea/examples/#build-a-production-container).
97
+
77
98
  ## Tools
78
99
 
79
100
  - `add-pea-variety` validates and inserts one document.
@@ -8,16 +8,19 @@
8
8
  "build": "tsc -p tsconfig.json",
9
9
  "db:setup": "node dist/setup-database.js",
10
10
  "start": "node dist/server.js",
11
- "dev": "docker compose up --detach --wait database && npm run build && npm run db:setup && npm start",
11
+ "dev": "npm run db:start && npm run build && npm run db:setup && npm start",
12
+ "db:start": "docker compose up --detach --wait database",
13
+ "db:reset": "docker compose down --volumes",
12
14
  "test": "npm run build && npm run test:built",
13
15
  "test:built": "node test/with-mongodb.mjs node --test test/*.test.mjs",
14
16
  "test:llm": "npm run build && npm run test:llm:built",
15
17
  "test:llm:built": "node test/with-mongodb.mjs emseepea-test eval",
16
- "lint": "oxlint src test eval"
18
+ "lint": "oxlint src test eval",
19
+ "container:build": "docker build --tag emseepea-server:local ."
17
20
  },
18
21
  "devDependencies": {
19
- "@emseepea/feedback": "0.2.4",
20
- "@emseepea/testing": "0.9.7",
22
+ "@emseepea/feedback": "0.2.7",
23
+ "@emseepea/testing": "0.9.11",
21
24
  "@types/node": "24.13.3",
22
25
  "typescript": "6.0.3",
23
26
  "oxlint": "1.80.0"
@@ -27,7 +30,7 @@
27
30
  },
28
31
  "private": true,
29
32
  "dependencies": {
30
- "@emseepea/server": "0.9.0",
33
+ "@emseepea/server": "0.10.1",
31
34
  "ajv": "8.20.0",
32
35
  "json-schema-to-ts": "3.1.1",
33
36
  "mongodb": "7.6.0",
@@ -1,8 +1,8 @@
1
- import { serveEmseepea } from "@emseepea/server";
1
+ import { loadDeploymentProfile, serveEmseepea } from "@emseepea/server";
2
2
  import { createMongoExample } from "./app.js";
3
3
 
4
4
  const uri = process.env.MONGODB_URL ?? "mongodb://127.0.0.1:27017";
5
- const { app } = await createMongoExample({ uri });
5
+ const { app } = await createMongoExample({ uri, deployment: loadDeploymentProfile() });
6
6
  const running = await serveEmseepea(app, {
7
7
  port: Number.parseInt(process.env.PORT ?? "3000", 10),
8
8
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emseepea/create-mongodb-backed-server",
3
- "version": "0.0.8",
3
+ "version": "0.0.11",
4
4
  "description": "Create an Em See Pea server with schema-enforced and schemaless MongoDB collections.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -11,7 +11,9 @@
11
11
  "build:initializer": "node ../../scripts/build-initializer.mjs",
12
12
  "db:setup": "node dist/setup-database.js",
13
13
  "start": "node dist/server.js",
14
- "dev": "docker compose up --detach --wait database && npm run build && npm run db:setup && npm start",
14
+ "dev": "npm run db:start && npm run build && npm run db:setup && npm start",
15
+ "db:start": "docker compose up --detach --wait database",
16
+ "db:reset": "docker compose down --volumes",
15
17
  "test": "npm run build && npm run test:built",
16
18
  "test:built": "node test/with-mongodb.mjs node --test test/*.test.mjs",
17
19
  "test:llm": "npm run build && npm run test:llm:built",
@@ -20,13 +22,13 @@
20
22
  "prepack": "npm run build:initializer"
21
23
  },
22
24
  "devDependencies": {
23
- "@emseepea/feedback": "0.2.4",
24
- "@emseepea/server": "0.9.0",
25
+ "@emseepea/feedback": "0.2.7",
26
+ "@emseepea/server": "0.10.1",
25
27
  "ajv": "8.20.0",
26
28
  "json-schema-to-ts": "3.1.1",
27
29
  "mongodb": "7.6.0",
28
30
  "zod": "4.4.3",
29
- "@emseepea/testing": "0.9.7",
31
+ "@emseepea/testing": "0.9.11",
30
32
  "@types/node": "24.13.3",
31
33
  "typescript": "6.0.3",
32
34
  "oxlint": "1.80.0"