Skip to content

Commit dcdfe02

Browse files
committed
Add containerized mock server for local dev
Introduces a TypeScript-based Express server with multi-stage Docker build Facilitates local testing and includes basic endpoints and usage instructions
1 parent 5cd64f1 commit dcdfe02

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

server/server/Dockerfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Dockerfile for editor mock API (TypeScript/Express)
2+
FROM node:18-alpine AS build
3+
WORKDIR /app
4+
# Copy only package.json from the build context. The repo root package-lock.json
5+
# is not available when building from the subfolder context, which caused
6+
# BuildKit checksum errors. Use npm ci when a lockfile exists, otherwise
7+
# fall back to npm install so the build doesn't fail.
8+
COPY package.json ./
9+
RUN npm ci --production=false || npm install --production=false
10+
COPY tsconfig.json ./
11+
COPY src ./src
12+
RUN npm run build
13+
14+
FROM node:18-alpine
15+
WORKDIR /app
16+
# Install only production deps
17+
COPY package.json ./
18+
# If a package-lock.json is present, npm ci will be used; if not, fall back
19+
# to npm install so the build doesn't fail when the lockfile is absent in the
20+
# build context (common when CI checkouts or subfolders don't include it).
21+
RUN npm ci --production || npm install --production
22+
COPY --from=build /app/dist ./dist
23+
EXPOSE 4000
24+
CMD ["node", "dist/index.js"]

server/server/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Editor mock server for local development (canonical server for this repo)
2+
3+
Run:
4+
5+
```powershell
6+
cd server/server
7+
npm install
8+
npm run dev
9+
```
10+
11+
Endpoints:
12+
- GET /health
13+
- GET /me
14+
- POST /logout

server/server/package.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "app-scripting-editor-server",
3+
"version": "0.1.0",
4+
"private": true,
5+
"main": "dist/index.js",
6+
"scripts": {
7+
"build": "tsc -p tsconfig.json",
8+
"start": "node dist/index.js",
9+
"dev": "ts-node-dev --respawn --transpile-only src/index.ts"
10+
},
11+
"dependencies": {
12+
"cors": "^2.8.5",
13+
"express": "^4.18.2"
14+
},
15+
"devDependencies": {
16+
"@types/express": "^4.17.17",
17+
"@types/cors": "^2.8.12",
18+
"@types/node": "^18.0.0",
19+
"ts-node-dev": "^2.0.0",
20+
"typescript": "^5.0.4"
21+
}
22+
}

0 commit comments

Comments
 (0)