Skip to content

Commit 7780923

Browse files
committed
feat(lit-auth-server, lit-login-server): make them nx node apps and executable via node eg. NODE_OPTIONS=--no-deprecation node ./dist/apps/lit-login-server/main.cjs
1 parent e62eee8 commit 7780923

File tree

18 files changed

+251
-150
lines changed

18 files changed

+251
-150
lines changed

apps/lit-auth-server/.gitignore

Lines changed: 0 additions & 34 deletions
This file was deleted.

apps/lit-auth-server/Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# This file is generated by Nx.
2+
#
3+
# Build the docker image with `npx nx docker-build lit-auth-server`.
4+
# Tip: Modify "docker-build" options in project.json to change docker build args.
5+
#
6+
# Run the container with `docker run -p 3000:3000 -t lit-auth-server`.
7+
FROM docker.io/node:lts-alpine
8+
9+
ENV HOST=0.0.0.0
10+
ENV PORT=3000
11+
12+
WORKDIR /app
13+
14+
RUN addgroup --system lit-auth-server && \
15+
adduser --system -G lit-auth-server lit-auth-server
16+
17+
COPY dist/apps/lit-auth-server lit-auth-server/
18+
COPY apps/lit-auth-server/package.json lit-auth-server/
19+
RUN chown -R lit-auth-server:lit-auth-server .
20+
21+
# You can remove this install step if you build with `--bundle` option.
22+
# The bundled output will include external dependencies.
23+
RUN npm --prefix lit-auth-server --omit=dev -f install
24+
25+
CMD [ "node", "lit-auth-server" ]

apps/lit-auth-server/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Getting started
2+
3+
## Building the server
4+
5+
```
6+
nx run lit-auth-server:build
7+
```
8+
9+
# Running the server
10+
11+
```
12+
pnpm nx run lit-auth-server:serve:production
13+
14+
or
15+
16+
node ./dist/apps/lit-auth-server/main.cjs
17+
```

apps/lit-auth-server/package.json

Lines changed: 0 additions & 22 deletions
This file was deleted.

apps/lit-auth-server/project.json

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"name": "lit-auth-server",
3+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "apps/lit-auth-server/src",
5+
"projectType": "application",
6+
"tags": [],
7+
"targets": {
8+
"build": {
9+
"executor": "@nx/esbuild:esbuild",
10+
"outputs": [
11+
"{options.outputPath}"
12+
],
13+
"defaultConfiguration": "production",
14+
"options": {
15+
"platform": "node",
16+
"outputPath": "dist/apps/lit-auth-server",
17+
"format": [
18+
"cjs"
19+
],
20+
"thirdParty": true,
21+
"main": "apps/lit-auth-server/src/main.ts",
22+
"tsConfig": "apps/lit-auth-server/tsconfig.app.json",
23+
"assets": [
24+
"apps/lit-auth-server/src/assets"
25+
],
26+
"generatePackageJson": true
27+
},
28+
"configurations": {
29+
"development": {},
30+
"production": {
31+
"generateLockfile": true
32+
}
33+
}
34+
},
35+
"serve": {
36+
"continuous": true,
37+
"executor": "@nx/js:node",
38+
"defaultConfiguration": "development",
39+
"dependsOn": [
40+
"build"
41+
],
42+
"options": {
43+
"buildTarget": "lit-auth-server:build",
44+
"runBuildTargetDependencies": false
45+
},
46+
"configurations": {
47+
"development": {
48+
"buildTarget": "lit-auth-server:build:development"
49+
},
50+
"production": {
51+
"buildTarget": "lit-auth-server:build:production"
52+
}
53+
}
54+
},
55+
"docker-build": {
56+
"dependsOn": [
57+
"build"
58+
],
59+
"command": "docker build -f apps/lit-auth-server/Dockerfile . -t lit-auth-server"
60+
}
61+
}
62+
}

apps/lit-auth-server/src/assets/.gitkeep

Whitespace-only changes.

apps/lit-auth-server/index.ts renamed to apps/lit-auth-server/src/main.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ const litAuthServer = createLitAuthServer({
1515
redisUrl: process.env['REDIS_URL'] as string,
1616
});
1717

18-
// Start the auth server
19-
await litAuthServer.start();
18+
async function main() {
19+
await litAuthServer.start();
20+
await startAuthServiceWorker();
21+
}
2022

21-
// Requires REDIS_URL
22-
await startAuthServiceWorker({
23-
litTxsenderRpcUrl: process.env['LIT_TXSENDER_RPC_URL'] as string,
24-
redisUrl: process.env['REDIS_URL'] as string,
23+
main().catch((err) => {
24+
console.error(err);
25+
process.exit(1);
2526
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../../dist/out-tsc",
5+
"module": "ES2022",
6+
"types": ["node"]
7+
},
8+
"include": ["src/**/*.ts"]
9+
}

apps/lit-auth-server/tsconfig.json

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
{
22
"extends": "../../tsconfig.base.json",
3+
"files": [],
4+
"include": [],
5+
"references": [
6+
{
7+
"path": "./tsconfig.app.json"
8+
}
9+
],
310
"compilerOptions": {
4-
"module": "ESNext",
511
"moduleResolution": "bundler",
6-
"strict": true,
7-
"skipLibCheck": true,
8-
"resolveJsonModule": true,
9-
"isolatedModules": true,
10-
"useDefineForClassFields": true,
11-
"types": ["node"],
12-
"allowJs": true,
1312
"esModuleInterop": true,
14-
"allowSyntheticDefaultImports": true
15-
},
16-
"include": ["**/*.ts", "**/*.tsx"],
17-
"exclude": ["node_modules"]
13+
"skipLibCheck": true
14+
}
1815
}

apps/lit-login-server/.gitignore

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)