Skip to content

Commit

Permalink
chore: easier test performance
Browse files Browse the repository at this point in the history
  • Loading branch information
juanfran committed Feb 20, 2025
1 parent 88bf1dd commit 157b313
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 6 deletions.
7 changes: 7 additions & 0 deletions apps/api/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@
"options": {
"command": "pnpm exec tsx apps/api/src/simulate-users.ts"
}
},
"serveDist": {
"executor": "nx:run-commands",
"outputs": [],
"options": {
"command": "pnpm exec tsx apps/api/src/serve-dist.ts"
}
}
},
"tags": ["scope:server"]
Expand Down
33 changes: 33 additions & 0 deletions apps/api/src/serve-dist.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import Fastify from 'fastify';
import fastifyStatic from '@fastify/static';
import path from 'path';

const PORT = 4300;

const fastify = Fastify({
logger: true,
maxParamLength: 5000,
});

console.log(path.join(import.meta.dirname, '../../../dist/apps/web'));

fastify.register(fastifyStatic, {
root: path.join(import.meta.dirname, '../../../dist/apps/web'),
wildcard: false,
});

fastify.get('/*', async (_, reply) => {
return reply.sendFile('index.html');
});

const start = async () => {
try {
await fastify.listen({ port: PORT });
console.log(`http://localhost:${PORT}`);
} catch (err) {
fastify.log.error(err);
process.exit(1);
}
};

start();
8 changes: 4 additions & 4 deletions apps/api/src/simulate-users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import { v4 as uuidv4 } from 'uuid';
/*
Tested scenario:
50+fps
pnpm build
pnpm serve-dist
pnpm demo
Production build false
50+fps
const NUM_CONNECTIONS = 100;
const PORT = 8000;
Expand All @@ -17,8 +19,6 @@ const MAX_EMITS = 250;
Text on
Color on
Position on
Without provideStoreDevtools
*/

const NUM_CONNECTIONS = 100;
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"lint": "nx run-many --all --target=lint --parallel",
"format": "nx format:write --libs-and-apps",
"demo": "nx run api:demo",
"prepare": "husky"
"prepare": "husky",
"serve-dist": "nx run api:serveDist"
},
"engines": {
"node": "^22.1.0",
Expand Down
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 157b313

Please sign in to comment.