mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-13 21:01:21 +08:00
* added basic api testing framework * added credential signup test * added current user test * added github action * fixed bugs in action file * updated action * added pnpm setup * added dependency install * updated pnpm lock * only run server tests * added new package for e2e test * removed unused tests * updated action * updated test command * added env var reading * fixed typo * fixed typo * fixed unit tests with staging * added delay e2e test * added start server to action * fixed typo * fix aciton * updated github action * fixed bugs * fixed eslint error
26 lines
704 B
TypeScript
26 lines
704 B
TypeScript
// server.js
|
|
import { Server, createServer } from 'http';
|
|
import next from 'next';
|
|
|
|
const app = next({ dev: true });
|
|
const handle = app.getRequestHandler();
|
|
|
|
let serverInstance: Server | null = null;
|
|
|
|
export function startServer(port: number) {
|
|
return app.prepare().then(() => {
|
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
const server = createServer((req, res) => handle(req, res).catch((err) => console.error(err)));
|
|
serverInstance = server.listen(port);
|
|
console.log(`> Ready on http://localhost:${port}`);
|
|
return server;
|
|
});
|
|
}
|
|
|
|
export function stopServer() {
|
|
if (serverInstance) {
|
|
serverInstance.close();
|
|
console.log('> Server stopped');
|
|
}
|
|
}
|